#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 /*<<< orphan*/ get_user_input(char *, char *);
int handle_create(char **, char **, char **, char *, char *, char *, int);
int handle_delete(char **, char **, char **, char *, int);
int /*<<< orphan*/ handle_list(char **, char **, char **, int);
int /*<<< orphan*/ handle_retrieve(char **, char **, char **, char *);
int /*<<< orphan*/ handle_update(char **, char **, char **, char *, char *,
                                 char *, char *, int);
int load_contacts(char **, char **, char **);
int handle_command(char cmd) {
  char name[10][20];
  char address[10][200];
  char phoneNumber[10][10];
  int curLength = load_contacts(name, address, phoneNumber);
  if (cmd == 'C') {
    char newName[80];
    char newAddress[80];
    char newPhone[80];
    get_user_input("Name: ", newName);
    get_user_input("Address: ", newAddress);
    get_user_input("Phone: ", newPhone);
    curLength = handle_create(name, address, phoneNumber, newName, newAddress,
                              newPhone, curLength);
  } else if (cmd == 'R') {
    char index[80];
    get_user_input("Index: ", index);
    handle_retrieve(name, address, phoneNumber, index);
  } else if (cmd == 'U') {
    char newName[80];
    char newAddress[80];
    char newPhone[80];
    char index[80];
    get_user_input("Index: ", index);
    get_user_input("Name: ", newName);
    get_user_input("Address: ", newAddress);
    get_user_input("Phone: ", newPhone);
    handle_update(name, address, phoneNumber, newName, newAddress, newPhone,
                  index, curLength);
  } else if (cmd == 'D') {
    char index[80];
    get_user_input("Index: ", index);
    curLength = handle_delete(name, address, phoneNumber, index, curLength);
  } else if (cmd == 'L') {
    handle_list(name, address, phoneNumber, curLength);
  }
}


x86 assembly (clang, -O0):
<handle_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc00,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
lea    -0xd0(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
lea    -0x910(%rbp),%rdx
call   1040 <load_contacts@plt>
mov    %eax,-0x914(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x43,%eax
jne    122a <handle_command+0xba>
lea    -0x970(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0x9c0(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xa10(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
lea    -0x910(%rbp),%rdx
lea    -0x970(%rbp),%rcx
lea    -0x9c0(%rbp),%r8
lea    -0xa10(%rbp),%r9
mov    -0x914(%rbp),%eax
mov    %eax,(%rsp)
call   1070 <handle_create@plt>
mov    %eax,-0x914(%rbp)
jmp    13a6 <handle_command+0x236>
movsbl -0x5(%rbp),%eax
cmp    $0x52,%eax
jne    1270 <handle_command+0x100>
lea    -0xa60(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
lea    -0x910(%rbp),%rdx
lea    -0xa60(%rbp),%rcx
call   1080 <handle_retrieve@plt>
jmp    13a1 <handle_command+0x231>
movsbl -0x5(%rbp),%eax
cmp    $0x55,%eax
jne    1312 <handle_command+0x1a2>
lea    -0xba0(%rbp),%rsi
lea    0xd8e(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xab0(%rbp),%rsi
lea    0xd62(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xb00(%rbp),%rsi
lea    0xd56(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xb50(%rbp),%rsi
lea    0xd4d(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
lea    -0x910(%rbp),%rdx
lea    -0xab0(%rbp),%rcx
lea    -0xb00(%rbp),%r8
lea    -0xb50(%rbp),%r9
lea    -0xba0(%rbp),%r10
mov    -0x914(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <handle_update@plt>
jmp    139c <handle_command+0x22c>
movsbl -0x5(%rbp),%eax
cmp    $0x44,%eax
jne    1365 <handle_command+0x1f5>
lea    -0xbf0(%rbp),%rsi
lea    0xcec(%rip),%rdi
call   1030 <get_user_input@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
lea    -0x910(%rbp),%rdx
lea    -0xbf0(%rbp),%rcx
mov    -0x914(%rbp),%r8d
call   1050 <handle_delete@plt>
mov    %eax,-0x914(%rbp)
jmp    1397 <handle_command+0x227>
movsbl -0x5(%rbp),%eax
cmp    $0x4c,%eax
jne    1392 <handle_command+0x222>
lea    -0xd0(%rbp),%rdi
lea    -0x8a0(%rbp),%rsi
lea    -0x910(%rbp),%rdx
mov    -0x914(%rbp),%ecx
call   1090 <handle_list@plt>
jmp    1397 <handle_command+0x227>
jmp    139c <handle_command+0x22c>
jmp    13a1 <handle_command+0x231>
jmp    13a6 <handle_command+0x236>
mov    -0x4(%rbp),%eax
add    $0xc00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_command>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa50,%rsp
mov    %edi,%ebp
lea    0xc0(%rsp),%rdi
lea    0x280(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <load_contacts@plt>
add    $0xbd,%bpl
cmp    $0x12,%bpl
ja     1337 <handle_command+0x1c7>
mov    %eax,%ebx
movzbl %bpl,%eax
lea    0xe4c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe88(%rip),%rdi
lea    0x70(%rsp),%r14
mov    %r14,%rsi
call   1030 <get_user_input@plt>
lea    0xe7b(%rip),%rdi
lea    0x1e0(%rsp),%r15
mov    %r15,%rsi
call   1030 <get_user_input@plt>
lea    0xe6e(%rip),%rdi
lea    0x190(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <get_user_input@plt>
sub    $0x8,%rsp
lea    0xc8(%rsp),%rdi
lea    0x288(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %rbp,%r9
push   %rbx
call   1070 <handle_create@plt>
jmp    1333 <handle_command+0x1c3>
lea    0xe32(%rip),%rdi
lea    0x70(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <get_user_input@plt>
lea    0xc0(%rsp),%rdi
lea    0x280(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbp,%rcx
mov    %ebx,%r8d
call   1050 <handle_delete@plt>
jmp    1337 <handle_command+0x1c7>
lea    0xc0(%rsp),%rdi
lea    0x280(%rsp),%rsi
mov    %rsp,%rdx
mov    %ebx,%ecx
call   1090 <handle_list@plt>
jmp    1337 <handle_command+0x1c7>
lea    0xddc(%rip),%rdi
lea    0x70(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <get_user_input@plt>
lea    0xc0(%rsp),%rdi
lea    0x280(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbx,%rcx
call   1080 <handle_retrieve@plt>
jmp    1337 <handle_command+0x1c7>
lea    0xda8(%rip),%rdi
lea    0x230(%rsp),%r14
mov    %r14,%rsi
call   1030 <get_user_input@plt>
lea    0xd78(%rip),%rdi
lea    0x70(%rsp),%r15
mov    %r15,%rsi
call   1030 <get_user_input@plt>
lea    0xd6b(%rip),%rdi
lea    0x1e0(%rsp),%r12
mov    %r12,%rsi
call   1030 <get_user_input@plt>
lea    0xd5e(%rip),%rdi
lea    0x190(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <get_user_input@plt>
lea    0xc0(%rsp),%rdi
lea    0x280(%rsp),%rsi
mov    %rsp,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %rbp,%r9
push   %rbx
push   %r14
call   1060 <handle_update@plt>
add    $0x10,%rsp
add    $0xa50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Name: \00"
@.str.1 = [10 x i8] c"Address: \00"
@.str.2 = [8 x i8] c"Phone: \00"
@.str.3 = [8 x i8] c"Index: \00"
define i32 @handle_command(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca [10 x [20 x i8]]
%5 = alloca [10 x [200 x i8]]
%6 = alloca [10 x [10 x i8]]
%7 = alloca i32
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca [80 x i8]
%11 = alloca [80 x i8]
%12 = alloca [80 x i8]
%13 = alloca [80 x i8]
%14 = alloca [80 x i8]
%15 = alloca [80 x i8]
%16 = alloca [80 x i8]
store i8 %0, i8* %3
%17 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %4, i64 0, i64 0
%18 = bitcast [20 x i8]* %17 to i8**
%19 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %5, i64 0, i64 0
%20 = bitcast [200 x i8]* %19 to i8**
%21 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %6, i64 0, i64 0
%22 = bitcast [10 x i8]* %21 to i8**
%23 = call i32 @load_contacts(i8** %18, i8** %20, i8** %22)
store i32 %23, i32* %7
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 67
br i1 %26, label %27, label %45
27: ; preds = %1
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%29 = call i32 @get_user_input(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%31 = call i32 @get_user_input(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%33 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %4, i64 0, i64 0
%35 = bitcast [20 x i8]* %34 to i8**
%36 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %5, i64 0, i64 0
%37 = bitcast [200 x i8]* %36 to i8**
%38 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %6, i64 0, i64 0
%39 = bitcast [10 x i8]* %38 to i8**
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%43 = load i32, i32* %7
%44 = call i32 @handle_create(i8** %35, i8** %37, i8** %39, i8* %40, i8* %41, i8* %42, i32 %43)
store i32 %44, i32* %7
br label %118
45: ; preds = %1
%46 = load i8, i8* %3
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 82
br i1 %48, label %49, label %60
49: ; preds = %45
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%51 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %4, i64 0, i64 0
%53 = bitcast [20 x i8]* %52 to i8**
%54 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %5, i64 0, i64 0
%55 = bitcast [200 x i8]* %54 to i8**
%56 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %6, i64 0, i64 0
%57 = bitcast [10 x i8]* %56 to i8**
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%59 = call i32 @handle_retrieve(i8** %53, i8** %55, i8** %57, i8* %58)
br label %117
60: ; preds = %45
%61 = load i8, i8* %3
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 85
br i1 %63, label %64, label %85
64: ; preds = %60
%65 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%66 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %65)
%67 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%68 = call i32 @get_user_input(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %67)
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%70 = call i32 @get_user_input(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %69)
%71 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%72 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %4, i64 0, i64 0
%74 = bitcast [20 x i8]* %73 to i8**
%75 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %5, i64 0, i64 0
%76 = bitcast [200 x i8]* %75 to i8**
%77 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %6, i64 0, i64 0
%78 = bitcast [10 x i8]* %77 to i8**
%79 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%80 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%81 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%82 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%83 = load i32, i32* %7
%84 = call i32 @handle_update(i8** %74, i8** %76, i8** %78, i8* %79, i8* %80, i8* %81, i8* %82, i32 %83)
br label %116
85: ; preds = %60
%86 = load i8, i8* %3
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 68
br i1 %88, label %89, label %101
89: ; preds = %85
%90 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%91 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %90)
%92 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %4, i64 0, i64 0
%93 = bitcast [20 x i8]* %92 to i8**
%94 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %5, i64 0, i64 0
%95 = bitcast [200 x i8]* %94 to i8**
%96 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %6, i64 0, i64 0
%97 = bitcast [10 x i8]* %96 to i8**
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %16, i64 0, i64 0
%99 = load i32, i32* %7
%100 = call i32 @handle_delete(i8** %93, i8** %95, i8** %97, i8* %98, i32 %99)
store i32 %100, i32* %7
br label %115
101: ; preds = %85
%102 = load i8, i8* %3
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 76
br i1 %104, label %105, label %114
105: ; preds = %101
%106 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %4, i64 0, i64 0
%107 = bitcast [20 x i8]* %106 to i8**
%108 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %5, i64 0, i64 0
%109 = bitcast [200 x i8]* %108 to i8**
%110 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %6, i64 0, i64 0
%111 = bitcast [10 x i8]* %110 to i8**
%112 = load i32, i32* %7
%113 = call i32 @handle_list(i8** %107, i8** %109, i8** %111, i32 %112)
br label %114
114: ; preds = %105, %101
br label %115
115: ; preds = %114, %89
br label %116
116: ; preds = %115, %64
br label %117
117: ; preds = %116, %49
br label %118
118: ; preds = %117, %27
%119 = load i32, i32* %2
ret i32 %119
}

LLVM IR (-O2):
@.str = [7 x i8] c"Name: \00"
@.str.1 = [10 x i8] c"Address: \00"
@.str.2 = [8 x i8] c"Phone: \00"
@.str.3 = [8 x i8] c"Index: \00"
define i32 @handle_command(i8 signext %0) {
%2 = alloca [10 x [20 x i8]]
%3 = alloca [10 x [200 x i8]]
%4 = alloca [10 x [10 x i8]]
%5 = alloca [80 x i8]
%6 = alloca [80 x i8]
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca [80 x i8]
%10 = alloca [80 x i8]
%11 = alloca [80 x i8]
%12 = alloca [80 x i8]
%13 = alloca [80 x i8]
%14 = getelementptr inbounds [10 x [20 x i8]], [10 x [20 x i8]]* %2, i64 0, i64 0, i64 0
%15 = getelementptr inbounds [10 x [200 x i8]], [10 x [200 x i8]]* %3, i64 0, i64 0, i64 0
%16 = getelementptr inbounds [10 x [10 x i8]], [10 x [10 x i8]]* %4, i64 0, i64 0, i64 0
%17 = bitcast [10 x [20 x i8]]* %2 to i8**
%18 = bitcast [10 x [200 x i8]]* %3 to i8**
%19 = bitcast [10 x [10 x i8]]* %4 to i8**
%20 = call i32 @load_contacts(i8** %17, i8** %18, i8** %19)
switch i8 %0, label %49 [
i8 67, label %21
i8 82, label %29
i8 85, label %33
i8 68, label %43
i8 76, label %47
]
21: ; preds = %1
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%25 = call i32 @get_user_input(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %22)
%26 = call i32 @get_user_input(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%27 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%28 = call i32 @handle_create(i8** %17, i8** %18, i8** %19, i8* %22, i8* %23, i8* %24, i32 %20)
br label %49
29: ; preds = %1
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%31 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = call i32 @handle_retrieve(i8** %17, i8** %18, i8** %19, i8* %30)
br label %49
33: ; preds = %1
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%38 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = call i32 @get_user_input(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %34)
%40 = call i32 @get_user_input(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%41 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%42 = call i32 @handle_update(i8** %17, i8** %18, i8** %19, i8* %34, i8* %35, i8* %36, i8* %37, i32 %20)
br label %49
43: ; preds = %1
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%45 = call i32 @get_user_input(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = call i32 @handle_delete(i8** %17, i8** %18, i8** %19, i8* %44, i32 %20)
br label %49
47: ; preds = %1
%48 = call i32 @handle_list(i8** %17, i8** %18, i8** %19, i32 %20)
br label %49
49: ; preds = %1, %29, %43, %47, %33, %21
ret i32 undef
}