#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 scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int getOperation() {
  printf("Choose operation (\"install\" or \"uninstall\")\n");
  char op[128];
  int res;
  do {
    printf("Operation: ");
    res = scanf("%s", op);
  } while (strcmp(op, "install") != 0 && strcmp(op, "uninstall") != 0);
  if (strcmp(op, "install") == 0) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<getOperation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xed8(%rip),%rdi
call   1050 <scanf@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xec4(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x95(%rbp)
je     11b4 <getOperation+0x84>
lea    -0x90(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
test   $0x1,%al
jne    1147 <getOperation+0x17>
lea    -0x90(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <getOperation+0xbb>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <getOperation+0xc2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOperation>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9d(%rip),%r14
lea    0xea2(%rip),%r15
mov    %rsp,%rbx
lea    0xe9d(%rip),%r12
lea    0xe94(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b3 <getOperation+0x73>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1180 <getOperation+0x40>
lea    0xe57(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Choose operation (\22install\22 or \22uninstall\22)\0A\00"
@.str.1 = [12 x i8] c"Operation: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [8 x i8] c"install\00"
@.str.4 = [10 x i8] c"uninstall\00"
define i32 @getOperation() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %17, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
store i32 %8, i32* %3
br label %9
9: ; preds = %5
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br label %17
17: ; preds = %13, %9
%18 = phi i1 [ false, %9 ], [ %16, %13 ]
br i1 %18, label %5, label %19
19: ; preds = %17
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 0, i32* %1
br label %25
24: ; preds = %19
store i32 1, i32* %1
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"Operation: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [8 x i8] c"install\00"
@.str.4 = [10 x i8] c"uninstall\00"
@str = [44 x i8] c"Choose operation (\22install\22 or \22uninstall\22)\00"
define i32 @getOperation() {
%1 = alloca [128 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %9, %0
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%7 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %4
12: ; preds = %4, %9
%13 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
ret i32 %15
}