#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*/ printf(char *);
int /*<<< orphan*/ read_word(char *, int *, char *);
scalar_t__ str_equal(char *, char *);
int parse_command(char *command) {
  int result = 0;
  int choice;
  char word[20];
  int command_reader = 0;
  read_word(command, &command_reader, word);
  if (str_equal(word, "merge")) {
    char f1[50], f2[50];
    printf("\nMerge Records");
    return 1;
  } else if (str_equal(word, "display")) {
    printf("\nDisplay records");
    return 1;
  } else if (str_equal(word, "Create")) {
    printf("\nCreate a new record");
    return 1;
  } else if (str_equal(word, "select")) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rsi
call   1040 <read_word@plt>
lea    -0x30(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1050 <str_equal@plt>
cmp    $0x0,%rax
je     1190 <parse_command+0x60>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1230 <parse_command+0x100>
lea    -0x30(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <str_equal@plt>
cmp    $0x0,%rax
je     11c2 <parse_command+0x92>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1230 <parse_command+0x100>
lea    -0x30(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1050 <str_equal@plt>
cmp    $0x0,%rax
je     11f4 <parse_command+0xc4>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1230 <parse_command+0x100>
lea    -0x30(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <str_equal@plt>
cmp    $0x0,%rax
je     121a <parse_command+0xea>
movl   $0x1,-0x4(%rbp)
jmp    1230 <parse_command+0x100>
jmp    121f <parse_command+0xef>
jmp    1224 <parse_command+0xf4>
jmp    1229 <parse_command+0xf9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_command>:
push   %rbx
sub    $0x30,%rsp
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
call   1040 <read_word@plt>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1050 <str_equal@plt>
test   %rax,%rax
je     116c <parse_command+0x3c>
lea    0xe9c(%rip),%rdi
jmp    11a8 <parse_command+0x78>
lea    0xea2(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <str_equal@plt>
test   %rax,%rax
je     118b <parse_command+0x5b>
lea    0xe94(%rip),%rdi
jmp    11a8 <parse_command+0x78>
lea    0xe9c(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <str_equal@plt>
test   %rax,%rax
je     11b8 <parse_command+0x88>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
ret
lea    0xe8b(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <str_equal@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    11b2 <parse_command+0x82>

LLVM IR (-O0):
@.str = [6 x i8] c"merge\00"
@.str.1 = [15 x i8] c"\0AMerge Records\00"
@.str.2 = [8 x i8] c"display\00"
@.str.3 = [17 x i8] c"\0ADisplay records\00"
@.str.4 = [7 x i8] c"Create\00"
@.str.5 = [21 x i8] c"\0ACreate a new record\00"
@.str.6 = [7 x i8] c"select\00"
define i32 @parse_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [20 x i8]
%7 = alloca i32
%8 = alloca [50 x i8]
%9 = alloca [50 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %7
%10 = load i8*, i8** %3
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%12 = call i32 @read_word(i8* %10, i32* %7, i8* %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%14 = call i64 @str_equal(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %39
18: ; preds = %1
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%20 = call i64 @str_equal(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %39
24: ; preds = %18
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%26 = call i64 @str_equal(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %39
30: ; preds = %24
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%32 = call i64 @str_equal(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %2
br label %39
35: ; preds = %30
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
store i32 0, i32* %2
br label %39
39: ; preds = %38, %34, %28, %22, %16
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [6 x i8] c"merge\00"
@.str.1 = [15 x i8] c"\0AMerge Records\00"
@.str.2 = [8 x i8] c"display\00"
@.str.3 = [17 x i8] c"\0ADisplay records\00"
@.str.4 = [7 x i8] c"Create\00"
@.str.5 = [21 x i8] c"\0ACreate a new record\00"
@.str.6 = [7 x i8] c"select\00"
define i32 @parse_command(i8* %0) {
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = call i32 @read_word(i8* %0, i32* %3, i8* %4)
%7 = call i64 @str_equal(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %25
11: ; preds = %1
%12 = call i64 @str_equal(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %25
16: ; preds = %11
%17 = call i64 @str_equal(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %25
21: ; preds = %16
%22 = call i64 @str_equal(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %19, %14, %9
%26 = phi i32 [ 1, %9 ], [ 1, %14 ], [ 1, %19 ], [ %24, %21 ]
ret i32 %26
}