#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*/ handleError(char);
int /*<<< orphan*/ serial_waitc();
char serial_getc(void) {
  char ch;
  char mySSR;
  while (!serial_waitc())
    ;
  ch = (*((volatile unsigned char *)0x05FFFECD));
  (*((volatile unsigned char *)0x05FFFECC)) &= ~0x40;
  mySSR = (*((volatile unsigned char *)0x05FFFECC)) & (0x08 | 0x10 | 0x20);
  if (mySSR)
    handleError(mySSR);
  return ch;
}


x86 assembly (clang, -O0):
<serial_getc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <serial_waitc@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1144 <serial_getc+0x24>
jmp    1149 <serial_getc+0x29>
jmp    1128 <serial_getc+0x8>
mov    $0x5fffecd,%eax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
mov    $0x5fffecc,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xffffffbf,%eax
mov    %al,%cl
mov    $0x5fffecc,%eax
mov    %cl,(%rax)
mov    $0x5fffecc,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0x38,%eax
mov    %al,-0x2(%rbp)
cmpb   $0x0,-0x2(%rbp)
je     118c <serial_getc+0x6c>
movsbl -0x2(%rbp),%edi
call   1040 <handleError@plt>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_getc>:
push   %rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <serial_waitc@plt>
test   %eax,%eax
je     1130 <serial_getc+0x10>
mov    0x5fffecd,%bl
andb   $0xbf,0x5fffecc
bf
mov    0x5fffecc,%al
and    $0x38,%al
je     115d <serial_getc+0x3d>
movsbl %al,%edi
call   1040 <handleError@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @serial_getc() {
%1 = alloca i8
%2 = alloca i8
br label %3
3: ; preds = %7, %0
%4 = call i32 (...) @serial_waitc()
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %8
7: ; preds = %3
br label %3
8: ; preds = %3
%9 = load volatile i8, i8* inttoptr (i64 100662989 to i8*)
store i8 %9, i8* %1
%10 = load volatile i8, i8* inttoptr (i64 100662988 to i8*)
%11 = zext i8 %10 to i32
%12 = and i32 %11, -65
%13 = trunc i32 %12 to i8
store volatile i8 %13, i8* inttoptr (i64 100662988 to i8*)
%14 = load volatile i8, i8* inttoptr (i64 100662988 to i8*)
%15 = zext i8 %14 to i32
%16 = and i32 %15, 56
%17 = trunc i32 %16 to i8
store i8 %17, i8* %2
%18 = load i8, i8* %2
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %8
%21 = load i8, i8* %2
%22 = call i32 @handleError(i8 signext %21)
br label %23
23: ; preds = %20, %8
%24 = load i8, i8* %1
ret i8 %24
}

LLVM IR (-O2):
define signext i8 @serial_getc() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @serial_waitc()
%3 = icmp eq i32 %2, 0
br i1 %3, label %1, label %4
4: ; preds = %1
%5 = load volatile i8, i8* inttoptr (i64 100662989 to i8*)
%6 = load volatile i8, i8* inttoptr (i64 100662988 to i8*)
%7 = and i8 %6, -65
store volatile i8 %7, i8* inttoptr (i64 100662988 to i8*)
%8 = load volatile i8, i8* inttoptr (i64 100662988 to i8*)
%9 = and i8 %8, 56
%10 = icmp eq i8 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call i32 @handleError(i8 signext %9)
br label %13
13: ; preds = %11, %4
ret i8 %5
}