I want to use binary search without locating the rotate number, and this is my code.My algorithm contains so many If-Else, so please help me to improve my code making it more understandable and concise.

```
class Solution {
public:
int search(int A[], int n, int target) {
int index=-1;
if(n!=0){
int first=0,last=n-1;
while(first<=last){
int mid=(first+last)/2;
if(A[mid]==target){
index=mid;
break;
}
else if(A[mid]>target){
if(A[mid]>=A[first]){
if(target<A[first]){
first=mid+1;
}
else if(target>A[first]){
last=mid-1;
}
else{
index=first;
break;
}
}
else{
last=mid-1;
}
}
else{
if(A[mid]>=A[last]){
first=mid+1;
}
else{
if(target<A[last]){
first=mid+1;
}
else if(target>A[last]){
last=mid-1;
}
else{
index=last;
break;
}
}
}
}
}
return index;
}
};
```