#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 atoi(char *);
int /*<<< orphan*/ save_contacts(char **, char **, char **, int);
int /*<<< orphan*/ strcpy(char *, char *);
int handle_delete(char names[10][20], char addresses[10][200],
                  char phoneNumbers[10][10], char *index, int curLength) {
  int item = atoi(index) - 1;
  int i;
  for (i = item - 1; i++; i < curLength) {
    strcpy(names[i], names[i + 1]);
    strcpy(addresses[i], addresses[i + 1]);
    strcpy(phoneNumbers[i], phoneNumbers[i + 1]);
  }
  curLength--;
  save_contacts(names, addresses, phoneNumbers, curLength);
  return curLength;
}


x86 assembly (clang, -O0):
<handle_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
cmp    $0x0,%eax
je     11f8 <handle_delete+0xc8>
mov    -0x8(%rbp),%rdi
movslq -0x2c(%rbp),%rax
imul   $0x14,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x14,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
movslq -0x2c(%rbp),%rax
imul   $0xc8,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0xc8,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0x2c(%rbp),%rax
imul   $0xa,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0xa,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
jmp    1164 <handle_delete+0x34>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <save_contacts@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_delete>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,0x24(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
mov    %rcx,%rdi
call   1050 <atoi@plt>
cmp    $0x2,%eax
je     11eb <handle_delete+0xbb>
mov    %eax,%ebp
add    $0xffffffff,%eax
cltq
lea    -0x1(%rax),%r12
lea    (%rax,%rax,4),%rcx
mov    0x8(%rsp),%rdx
lea    (%rdx,%rcx,4),%rbx
imul   $0xc8,%rax,%r14
add    0x10(%rsp),%r14
mov    0x18(%rsp),%rax
lea    (%rax,%rcx,2),%r15
movslq %ebp,%rbp
lea    0x0(,%rbp,4),%r13
add    %rbp,%r13
mov    0x8(%rsp),%rax
lea    (%rax,%r13,4),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
imul   $0xc8,%rbp,%rsi
add    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x18(%rsp),%rax
lea    (%rax,%r13,2),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
add    $0x1,%ebp
add    $0x14,%rbx
add    $0xc8,%r14
add    $0xa,%r15
inc    %r12
jne    1190 <handle_delete+0x60>
mov    0x24(%rsp),%ebx
add    $0xffffffff,%ebx
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    %ebx,%ecx
call   1040 <save_contacts@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @handle_delete([20 x i8]* %0, [200 x i8]* %1, [10 x i8]* %2, i8* %3, i32 %4) {
%6 = alloca [20 x i8]*
%7 = alloca [200 x i8]*
%8 = alloca [10 x i8]*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store [20 x i8]* %0, [20 x i8]** %6
store [200 x i8]* %1, [200 x i8]** %7
store [10 x i8]* %2, [10 x i8]** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = load i8*, i8** %9
%14 = call i32 @atoi(i8* %13)
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %12
br label %18
18: ; preds = %59, %5
%19 = load i32, i32* %12
%20 = add nsw i32 %19, 1
store i32 %20, i32* %12
%21 = icmp ne i32 %19, 0
br i1 %21, label %22, label %64
22: ; preds = %18
%23 = load [20 x i8]*, [20 x i8]** %6
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %23, i64 %25
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %26, i64 0, i64 0
%28 = load [20 x i8]*, [20 x i8]** %6
%29 = load i32, i32* %12
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %28, i64 %31
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %32, i64 0, i64 0
%34 = call i32 @strcpy(i8* %27, i8* %33)
%35 = load [200 x i8]*, [200 x i8]** %7
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %35, i64 %37
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %38, i64 0, i64 0
%40 = load [200 x i8]*, [200 x i8]** %7
%41 = load i32, i32* %12
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [200 x i8], [200 x i8]* %40, i64 %43
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %44, i64 0, i64 0
%46 = call i32 @strcpy(i8* %39, i8* %45)
%47 = load [10 x i8]*, [10 x i8]** %8
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [10 x i8], [10 x i8]* %47, i64 %49
%51 = getelementptr inbounds [10 x i8], [10 x i8]* %50, i64 0, i64 0
%52 = load [10 x i8]*, [10 x i8]** %8
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [10 x i8], [10 x i8]* %52, i64 %55
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %56, i64 0, i64 0
%58 = call i32 @strcpy(i8* %51, i8* %57)
br label %59
59: ; preds = %22
%60 = load i32, i32* %12
%61 = load i32, i32* %10
%62 = icmp slt i32 %60, %61
%63 = zext i1 %62 to i32
br label %18
64: ; preds = %18
%65 = load i32, i32* %10
%66 = add nsw i32 %65, -1
store i32 %66, i32* %10
%67 = load [20 x i8]*, [20 x i8]** %6
%68 = bitcast [20 x i8]* %67 to i8**
%69 = load [200 x i8]*, [200 x i8]** %7
%70 = bitcast [200 x i8]* %69 to i8**
%71 = load [10 x i8]*, [10 x i8]** %8
%72 = bitcast [10 x i8]* %71 to i8**
%73 = load i32, i32* %10
%74 = call i32 @save_contacts(i8** %68, i8** %70, i8** %72, i32 %73)
%75 = load i32, i32* %10
ret i32 %75
}

LLVM IR (-O2):
define i32 @handle_delete([20 x i8]* %0, [200 x i8]* %1, [10 x i8]* %2, i8* nocapture %3, i32 %4) {
%6 = tail call i32 @atoi(i8* %3)
%7 = add nsw i32 %6, -2
%8 = icmp eq i32 %7, 0
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = add i32 %6, -1
%11 = sext i32 %10 to i64
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ %11, %9 ], [ %26, %12 ]
%14 = phi i32 [ %7, %9 ], [ %28, %12 ]
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %0, i64 %13, i64 0
%16 = add nsw i32 %14, 2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %0, i64 %17, i64 0
%19 = tail call i32 @strcpy(i8* %15, i8* %18)
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 %13, i64 0
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 %17, i64 0
%22 = tail call i32 @strcpy(i8* %20, i8* %21)
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 %13, i64 0
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 %17, i64 0
%25 = tail call i32 @strcpy(i8* %23, i8* %24)
%26 = add nsw i64 %13, 1
%27 = icmp eq i64 %13, 0
%28 = trunc i64 %13 to i32
br i1 %27, label %29, label %12
29: ; preds = %12, %5
%30 = add nsw i32 %4, -1
%31 = bitcast [20 x i8]* %0 to i8**
%32 = bitcast [200 x i8]* %1 to i8**
%33 = bitcast [10 x i8]* %2 to i8**
%34 = tail call i32 @save_contacts(i8** %31, i8** %32, i8** %33, i32 %30)
ret i32 %30
}