#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 _get_char(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int _get_result(int fd) {
  while (1) {
    char c = _get_char(fd);
    switch (c) {
    case 0:
      continue;
    case '.':
      printf("\r");
      return 0;
    case '?':
      puts("CRC Error");
      return 1;
    case '!':
      puts("Illegal Address");
      return -1;
    default:
      putchar(c);
    }
  };
}


x86 assembly (clang, -O0):
<_get_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <_get_char@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     119d <_get_result+0x5d>
jmp    116a <_get_result+0x2a>
mov    -0x10(%rbp),%eax
sub    $0x21,%eax
je     11d2 <_get_result+0x92>
jmp    117b <_get_result+0x3b>
mov    -0x10(%rbp),%eax
sub    $0x2e,%eax
je     11a2 <_get_result+0x62>
jmp    118c <_get_result+0x4c>
mov    -0x10(%rbp),%eax
sub    $0x3f,%eax
je     11ba <_get_result+0x7a>
jmp    11ea <_get_result+0xaa>
jmp    114b <_get_result+0xb>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f8 <_get_result+0xb8>
lea    0xe41(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <_get_result+0xb8>
lea    0xe33(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <_get_result+0xb8>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    114b <_get_result+0xb>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_result>:
push   %rbx
mov    %edi,%ebx
jmp    1145 <_get_result+0x15>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1050 <_get_char@plt>
movsbl %al,%edi
cmp    $0x20,%edi
jg     1160 <_get_result+0x30>
test   %edi,%edi
je     1145 <_get_result+0x15>
jmp    1140 <_get_result+0x10>
nopw   0x0(%rax,%rax,1)
cmp    $0x21,%edi
je     117d <_get_result+0x4d>
cmp    $0x3f,%edi
je     1190 <_get_result+0x60>
cmp    $0x2e,%edi
jne    1140 <_get_result+0x10>
mov    $0xd,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0D\00"
@.str.1 = [10 x i8] c"CRC Error\00"
@.str.2 = [16 x i8] c"Illegal Address\00"
define i32 @_get_result(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
br label %5
5: ; preds = %1, %10, %20
%6 = load i32, i32* %3
%7 = call signext i8 @_get_char(i32 %6)
store i8 %7, i8* %4
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
switch i32 %9, label %17 [
i32 0, label %10
i32 46, label %11
i32 63, label %13
i32 33, label %15
]
10: ; preds = %5
br label %5
11: ; preds = %5
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %21
13: ; preds = %5
%14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %21
15: ; preds = %5
%16 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %21
17: ; preds = %5
%18 = load i8, i8* %4
%19 = call i32 @putchar(i8 signext %18)
br label %20
20: ; preds = %17
br label %5
21: ; preds = %15, %13, %11
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"CRC Error\00"
@.str.2 = [16 x i8] c"Illegal Address\00"
define i32 @_get_result(i32 %0) {
br label %2
2: ; preds = %5, %1
%3 = tail call signext i8 @_get_char(i32 %0)
%4 = sext i8 %3 to i32
switch i32 %4, label %12 [
i32 0, label %5
i32 46, label %6
i32 63, label %8
i32 33, label %10
]
5: ; preds = %2, %12
br label %2
6: ; preds = %2
%7 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 13)
br label %14
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %14
12: ; preds = %2
%13 = tail call i32 @putchar(i8 signext %3)
br label %5
14: ; preds = %10, %8, %6
%15 = phi i32 [ 0, %6 ], [ 1, %8 ], [ -1, %10 ]
ret i32 %15
}