#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int File_DeleteRecordByIndex(char *, int, int);
int File_GetNumberOfRecords(char *, int);
int File_GetRecordByIndex(char *, char *, int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int SMS_DelPhone(char *phone) {
  int num = 0;
  int i;
  char buf[16] = {0};
  num = File_GetNumberOfRecords("/CMD_Data/.sms_phone.txt", 16);
  for (i = 0; i < num; i++) {
    memset(buf, 0, 16);
    if (File_GetRecordByIndex("/CMD_Data/.sms_phone.txt", buf, 16, i) == 16) {
      if (strcmp(buf, phone) == 0) {
        return File_DeleteRecordByIndex("/CMD_Data/.sms_phone.txt", 16, i);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<SMS_DelPhone>:
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   1050 <memset@plt>
lea    0xe86(%rip),%rdi
mov    $0x10,%esi
call   1040 <File_GetNumberOfRecords@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1216 <SMS_DelPhone+0xc6>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%ecx
lea    0xe48(%rip),%rdi
mov    $0x10,%edx
call   1070 <File_GetRecordByIndex@plt>
cmp    $0x10,%eax
jne    1203 <SMS_DelPhone+0xb3>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11fe <SMS_DelPhone+0xae>
mov    -0x18(%rbp),%edx
lea    0xe14(%rip),%rdi
mov    $0x10,%esi
call   1030 <File_DeleteRecordByIndex@plt>
mov    %eax,-0x4(%rbp)
jmp    121d <SMS_DelPhone+0xcd>
jmp    1203 <SMS_DelPhone+0xb3>
jmp    1208 <SMS_DelPhone+0xb8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118e <SMS_DelPhone+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SMS_DelPhone>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
lea    0xe93(%rip),%rdi
mov    $0x10,%esi
call   1040 <File_GetNumberOfRecords@plt>
test   %eax,%eax
jle    11e3 <SMS_DelPhone+0x93>
mov    %eax,%r15d
xor    %ebp,%ebp
mov    %rsp,%rbx
lea    0xe76(%rip),%r12
jmp    1198 <SMS_DelPhone+0x48>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %ebp,%r15d
je     11e3 <SMS_DelPhone+0x93>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
mov    %ebp,%ecx
call   1070 <File_GetRecordByIndex@plt>
cmp    $0x10,%eax
jne    1190 <SMS_DelPhone+0x40>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1190 <SMS_DelPhone+0x40>
lea    0xe2b(%rip),%rdi
mov    $0x10,%esi
mov    %ebp,%edx
call   1030 <File_DeleteRecordByIndex@plt>
jmp    11e5 <SMS_DelPhone+0x95>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"/CMD_Data/.sms_phone.txt\00"
define i32 @SMS_DelPhone(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 @File_GetNumberOfRecords(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 16)
store i32 %8, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %30, %1
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 16)
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%17 = load i32, i32* %5
%18 = call i32 @File_GetRecordByIndex(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16, i32 16, i32 %17)
%19 = icmp eq i32 %18, 16
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* %5
%27 = call i32 @File_DeleteRecordByIndex(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 16, i32 %26)
store i32 %27, i32* %2
br label %34
28: ; preds = %20
br label %29
29: ; preds = %28, %13
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %9
33: ; preds = %9
store i32 0, i32* %2
br label %34
34: ; preds = %33, %25
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [25 x i8] c"/CMD_Data/.sms_phone.txt\00"
define i32 @SMS_DelPhone(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 @File_GetNumberOfRecords(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 16)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1, %16
%7 = phi i32 [ %17, %16 ], [ 0, %1 ]
%8 = call i32 @memset(i8* %3, i32 0, i32 16)
%9 = call i32 @File_GetRecordByIndex(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %3, i32 16, i32 %7)
%10 = icmp eq i32 %9, 16
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = call i64 @strcmp(i8* %3, i8* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @File_DeleteRecordByIndex(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 16, i32 %7)
br label %19
16: ; preds = %6, %11
%17 = add nuw nsw i32 %7, 1
%18 = icmp eq i32 %17, %4
br i1 %18, label %19, label %6
19: ; preds = %16, %1, %14
%20 = phi i32 [ %15, %14 ], [ 0, %1 ], [ 0, %16 ]
ret i32 %20
}