#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 EOF;
char fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int readCommand(char *command) {
  *command = fgetc(stdin);
  if (*command == EOF)
    return EOF;
  else if (*command == '+' || *command == '?')
    return 1;
  else if (*command == '\n')
    return 0;
  else {
    while (fgetc(stdin) != '\n') {
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<readCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    0x2ea0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    115d <readCommand+0x4d>
mov    0x2e8e(%rip),%rax
movsbl (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11df <readCommand+0xcf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     117d <readCommand+0x6d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1189 <readCommand+0x79>
movl   $0x1,-0x4(%rbp)
jmp    11df <readCommand+0xcf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11a5 <readCommand+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11df <readCommand+0xcf>
jmp    11aa <readCommand+0x9a>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11c9 <readCommand+0xb9>
jmp    11aa <readCommand+0x9a>
jmp    11ce <readCommand+0xbe>
jmp    11d3 <readCommand+0xc3>
jmp    11d8 <readCommand+0xc8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readCommand>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eca(%rip),%r14
mov    (%r14),%edi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    %al,(%rbx)
mov    0x2eaf(%rip),%rax
cmp    (%rax),%cl
jne    113a <readCommand+0x2a>
movsbl %cl,%eax
jmp    115e <readCommand+0x4e>
cmp    $0xa,%cl
je     115c <readCommand+0x4c>
mov    $0x1,%eax
cmp    $0x2b,%cl
je     115e <readCommand+0x4e>
cmp    $0x3f,%cl
je     115e <readCommand+0x4e>
xchg   %ax,%ax
mov    (%r14),%edi
call   1030 <fgetc@plt>
cmp    $0xa,%al
jne    1150 <readCommand+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i8 0
define i32 @readCommand(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i32, i32* @stdin
%5 = call signext i8 @fgetc(i32 %4)
%6 = load i8*, i8** %3
store i8 %5, i8* %6
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = load i8, i8* @EOF
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %9, %11
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
store i32 %15, i32* %2
br label %44
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 43
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 63
br i1 %25, label %26, label %27
26: ; preds = %21, %16
store i32 1, i32* %2
br label %44
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* %2
br label %44
33: ; preds = %27
br label %34
34: ; preds = %39, %33
%35 = load i32, i32* @stdin
%36 = call signext i8 @fgetc(i32 %35)
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 10
br i1 %38, label %39, label %40
39: ; preds = %34
br label %34
40: ; preds = %34
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41
br label %43
43: ; preds = %42
store i32 0, i32* %2
br label %44
44: ; preds = %43, %32, %26, %13
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i8 0
define i32 @readCommand(i8* nocapture writeonly %0) {
%2 = load i32, i32* @stdin
%3 = tail call signext i8 @fgetc(i32 %2)
store i8 %3, i8* %0
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = sext i8 %3 to i32
br label %14
8: ; preds = %1
switch i8 %3, label %10 [
i8 43, label %14
i8 63, label %14
i8 10, label %9
]
9: ; preds = %8
br label %14
10: ; preds = %8, %10
%11 = load i32, i32* @stdin
%12 = tail call signext i8 @fgetc(i32 %11)
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %10
14: ; preds = %10, %8, %8, %9, %6
%15 = phi i32 [ %7, %6 ], [ 0, %9 ], [ 1, %8 ], [ 1, %8 ], [ 0, %10 ]
ret i32 %15
}