#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*/ disable_servo(int);
int /*<<< orphan*/ enable_servo(int);
int get_servo_enabled(int);
int get_servo_position(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_servo_position(int, int);
void openGate(int servo) {
  enable_servo(servo);
  if (servo == 2) {
    printf("GREEEEN!!!!!!");
    set_servo_position(servo, 1200);
  } else if (servo == 0) {
    printf("RED!!!!\n");
    printf("%d\n", get_servo_enabled(servo));
    printf("%d\n", get_servo_position(servo));
    set_servo_position(servo, 590);
    printf("%d\n", get_servo_position(servo));
  }
  printf("papapa");
  disable_servo(servo);
}


x86 assembly (clang, -O0):
<openGate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <enable_servo@plt>
cmpl   $0x2,-0x4(%rbp)
jne    119d <openGate+0x3d>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x4b0,%esi
call   1080 <set_servo_position@plt>
jmp    120f <openGate+0xaf>
cmpl   $0x0,-0x4(%rbp)
jne    120a <openGate+0xaa>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <get_servo_enabled@plt>
mov    %eax,%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <get_servo_position@plt>
mov    %eax,%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x24e,%esi
call   1080 <set_servo_position@plt>
mov    -0x4(%rbp),%edi
call   1030 <get_servo_position@plt>
mov    %eax,%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120f <openGate+0xaf>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1070 <disable_servo@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openGate>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1070 <enable_servo@plt>
test   %ebx,%ebx
je     11a3 <openGate+0x33>
cmp    $0x2,%ebx
jne    11fb <openGate+0x8b>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%edi
mov    $0x4b0,%esi
call   1090 <set_servo_position@plt>
jmp    11fb <openGate+0x8b>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <get_servo_enabled@plt>
lea    0xe51(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1040 <get_servo_position@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x24e,%esi
call   1090 <set_servo_position@plt>
xor    %edi,%edi
call   1040 <get_servo_position@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <disable_servo@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"GREEEEN!!!!!!\00"
@.str.1 = [9 x i8] c"RED!!!!\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [7 x i8] c"papapa\00"
define void @openGate(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @enable_servo(i32 %3)
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = call i32 @set_servo_position(i32 %9, i32 1200)
br label %28
11: ; preds = %1
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = call i32 @get_servo_enabled(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @get_servo_position(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = call i32 @set_servo_position(i32 %22, i32 590)
%24 = load i32, i32* %2
%25 = call i32 @get_servo_position(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %14, %11
br label %28
28: ; preds = %27, %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %2
%31 = call i32 @disable_servo(i32 %30)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"GREEEEN!!!!!!\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [7 x i8] c"papapa\00"
@str = [8 x i8] c"RED!!!!\00"
define void @openGate(i32 %0) {
%2 = tail call i32 @enable_servo(i32 %0)
switch i32 %0, label %15 [
i32 2, label %3
i32 0, label %6
]
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @set_servo_position(i32 2, i32 1200)
br label %15
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @get_servo_enabled(i32 0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 @get_servo_position(i32 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 @set_servo_position(i32 0, i32 590)
%13 = tail call i32 @get_servo_position(i32 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %1, %6, %3
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @disable_servo(i32 %0)
ret void
}