int SMS_CheckPhone(char *phone) {
  int num = 0;
  int i;
  char buf[16] = {0};
  logcat("Enter func: %s ------\n", __func__);
  if ((strcmp(phone, "13811187586") == 0) ||
      (strcmp(phone, "18576420690") == 0)) {
    return 0;
  }
  if (File_Exist("/CMD_Data/.sms_phone.txt") == 0)
    return -1;
  num = File_GetNumberOfRecords("/CMD_Data/.sms_phone.txt", 16);
  if (num == 0)
    return -1;
  for (i = 0; i < num; i++) {
    memset(buf, 0, 16);
    if (File_GetRecordByIndex("/CMD_Data/.sms_phone.txt", buf, 16, i) == 16) {
      logcat("buf = %s, phone = %s\n", buf, phone);
      if (strncmp(buf, phone, 11) == 0)
        return 0;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<SMS_CheckPhone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    0xe66(%rip),%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1070 <logcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     11da <SMS_CheckPhone+0x6a>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <SMS_CheckPhone+0x76>
movl   $0x0,-0x4(%rbp)
jmp    12d7 <SMS_CheckPhone+0x167>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <File_Exist@plt>
cmp    $0x0,%eax
jne    1209 <SMS_CheckPhone+0x99>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <SMS_CheckPhone+0x167>
lea    0xe2e(%rip),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1050 <File_GetNumberOfRecords@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1235 <SMS_CheckPhone+0xc5>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <SMS_CheckPhone+0x167>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12d0 <SMS_CheckPhone+0x160>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%ecx
lea    0xdd8(%rip),%rdi
mov    $0x10,%edx
mov    $0x0,%al
call   1090 <File_GetRecordByIndex@plt>
cmp    $0x10,%eax
jne    12bd <SMS_CheckPhone+0x14d>
lea    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1070 <logcat@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12b8 <SMS_CheckPhone+0x148>
movl   $0x0,-0x4(%rbp)
jmp    12d7 <SMS_CheckPhone+0x167>
jmp    12bd <SMS_CheckPhone+0x14d>
jmp    12c2 <SMS_CheckPhone+0x152>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123c <SMS_CheckPhone+0xcc>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SMS_CheckPhone>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xe98(%rip),%rdi
lea    0xea8(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <logcat@plt>
lea    0xea7(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1259 <SMS_CheckPhone+0xf9>
lea    0xe9c(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1259 <SMS_CheckPhone+0xf9>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <File_Exist@plt>
test   %eax,%eax
je     1254 <SMS_CheckPhone+0xf4>
lea    0xe7b(%rip),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1050 <File_GetNumberOfRecords@plt>
test   %eax,%eax
jle    1254 <SMS_CheckPhone+0xf4>
mov    %eax,%ebx
lea    0xe62(%rip),%r15
mov    %rsp,%r12
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    1209 <SMS_CheckPhone+0xa9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    %r13d,%ebx
je     1254 <SMS_CheckPhone+0xf4>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x10,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1080 <File_GetRecordByIndex@plt>
cmp    $0x10,%eax
jne    1200 <SMS_CheckPhone+0xa0>
lea    0xe36(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <logcat@plt>
mov    $0xb,%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1200 <SMS_CheckPhone+0xa0>
jmp    1259 <SMS_CheckPhone+0xf9>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter func: %s ------\0A\00"
@__func__.SMS_CheckPhone = [15 x i8] c"SMS_CheckPhone\00"
@.str.1 = [12 x i8] c"13811187586\00"
@.str.2 = [12 x i8] c"18576420690\00"
@.str.3 = [25 x i8] c"/CMD_Data/.sms_phone.txt\00"
@.str.4 = [22 x i8] c"buf = %s, phone = %s\0A\00"
define i32 @SMS_CheckPhone(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
%7 = bitcast [16 x i8]* %6 to i8*
%8 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @logcat to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.SMS_CheckPhone, i64 0, i64 0))
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12, %1
store i32 0, i32* %2
br label %52
17: ; preds = %12
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @File_Exist to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 -1, i32* %2
br label %52
21: ; preds = %17
%22 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @File_GetNumberOfRecords to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 16)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 -1, i32* %2
br label %52
26: ; preds = %21
store i32 0, i32* %5
br label %27
27: ; preds = %48, %26
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %51
31: ; preds = %27
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* %5
%35 = call i32 (i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @File_GetRecordByIndex to i32 (i8*, i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %33, i32 16, i32 %34)
%36 = icmp eq i32 %35, 16
br i1 %36, label %37, label %47
37: ; preds = %31
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%39 = load i8*, i8** %3
%40 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @logcat to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %38, i8* %39)
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%42 = load i8*, i8** %3
%43 = call i32 @strncmp(i8* %41, i8* %42, i64 11)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %37
store i32 0, i32* %2
br label %52
46: ; preds = %37
br label %47
47: ; preds = %46, %31
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %27
51: ; preds = %27
store i32 -1, i32* %2
br label %52
52: ; preds = %51, %45, %25, %20, %16
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter func: %s ------\0A\00"
@__func__.SMS_CheckPhone = [15 x i8] c"SMS_CheckPhone\00"
@.str.1 = [12 x i8] c"13811187586\00"
@.str.2 = [12 x i8] c"18576420690\00"
@.str.3 = [25 x i8] c"/CMD_Data/.sms_phone.txt\00"
@.str.4 = [22 x i8] c"buf = %s, phone = %s\0A\00"
define i32 @SMS_CheckPhone(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @logcat to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__func__.SMS_CheckPhone, i64 0, i64 0))
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %1
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %7
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @File_Exist to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %10
%14 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @File_GetNumberOfRecords to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 16)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %13, %24
%17 = phi i32 [ %25, %24 ], [ 0, %13 ]
%18 = call i32 (i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @File_GetRecordByIndex to i32 (i8*, i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 16, i32 %17)
%19 = icmp eq i32 %18, 16
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @logcat to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %3, i8* %0)
%22 = call i32 @strncmp(i8* %3, i8* dereferenceable(1) %0, i64 11)
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %16, %20
%25 = add nuw nsw i32 %17, 1
%26 = icmp eq i32 %25, %14
br i1 %26, label %27, label %16
27: ; preds = %20, %24, %13, %10, %1, %7
%28 = phi i32 [ 0, %7 ], [ 0, %1 ], [ -1, %10 ], [ -1, %13 ], [ 0, %20 ], [ -1, %24 ]
ret i32 %28
}