#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 */
char getchar();
char getCommand(int flag) {
  char ch, result;
  short first = 1;
  if (flag == 2) {
    while (getchar() != '\n')
      continue;
    return 0;
  }
  if (flag == 1) {
    while ((ch = getchar()) != '\n') {
      if (first) {
        first = 0;
        result = ch;
      } else {
        continue;
      }
    }
    return result;
  }
}


x86 assembly (clang, -O0):
<getCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movw   $0x1,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1151 <getCommand+0x41>
jmp    1130 <getCommand+0x20>
mov    $0x0,%al
call   1030 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1148 <getCommand+0x38>
jmp    1130 <getCommand+0x20>
movb   $0x0,-0x1(%rbp)
jmp    11a2 <getCommand+0x92>
cmpl   $0x1,-0x8(%rbp)
jne    11a2 <getCommand+0x92>
jmp    1160 <getCommand+0x50>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     119c <getCommand+0x8c>
cmpw   $0x0,-0xc(%rbp)
je     1192 <getCommand+0x82>
movw   $0x0,-0xc(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0xa(%rbp)
jmp    1197 <getCommand+0x87>
jmp    1160 <getCommand+0x50>
jmp    1160 <getCommand+0x50>
mov    -0xa(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCommand>:
push   %rbx
cmp    $0x1,%edi
je     112f <getCommand+0x1f>
cmp    $0x2,%edi
jne    112b <getCommand+0x1b>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1120 <getCommand+0x10>
mov    %ebx,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%al
je     112b <getCommand+0x1b>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1140 <getCommand+0x30>
jmp    112b <getCommand+0x1b>

LLVM IR (-O0):
define signext i8 @getCommand(i32 %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i16
store i32 %0, i32* %3
store i16 1, i16* %6
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %1
br label %10
10: ; preds = %14, %9
%11 = call signext i8 (...) @getchar()
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
store i8 0, i8* %2
br label %33
16: ; preds = %1
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %33
19: ; preds = %16
br label %20
20: ; preds = %30, %29, %19
%21 = call signext i8 (...) @getchar()
store i8 %21, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i16, i16* %6
%26 = icmp ne i16 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
store i16 0, i16* %6
%28 = load i8, i8* %4
store i8 %28, i8* %5
br label %30
29: ; preds = %24
br label %20
30: ; preds = %27
br label %20
31: ; preds = %20
%32 = load i8, i8* %5
store i8 %32, i8* %2
br label %33
33: ; preds = %15, %31, %16
%34 = load i8, i8* %2
ret i8 %34
}

LLVM IR (-O2):
define signext i8 @getCommand(i32 %0) {
switch i32 %0, label %11 [
i32 2, label %5
i32 1, label %2
]
2: ; preds = %1
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %11, label %8
5: ; preds = %1, %5
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %11, label %5
8: ; preds = %2, %8
%9 = tail call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %8
11: ; preds = %8, %5, %2, %1
%12 = phi i8 [ undef, %1 ], [ undef, %2 ], [ 0, %5 ], [ %3, %8 ]
ret i8 %12
}