#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 */
unsigned int UARTRegConfigModeEnable(unsigned int, int);
signed char UARTCharGet(unsigned int baseAdd) {
  unsigned int lcrRegValue = 0;
  signed char retVal = 0;
  lcrRegValue = UARTRegConfigModeEnable(baseAdd, (0x007F));
  while (0 ==
         ((*((volatile unsigned int *)(baseAdd + (0x14)))) & (0x00000001u)))
    ;
  retVal = ((signed char)(*((volatile unsigned int *)(baseAdd + (0x0)))));
  (*((volatile unsigned int *)(baseAdd + (0xC)))) = lcrRegValue;
  return retVal;
}


x86 assembly (clang, -O0):
<UARTCharGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x7f,%esi
call   1030 <UARTRegConfigModeEnable@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x14,%eax
mov    %eax,%eax
mov    (%rax),%ecx
and    $0x1,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1152 <UARTCharGet+0x42>
jmp    1136 <UARTCharGet+0x26>
mov    -0x4(%rbp),%eax
add    $0x0,%eax
mov    %eax,%eax
mov    (%rax),%eax
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xc,%eax
mov    %eax,%eax
mov    %ecx,(%rax)
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UARTCharGet>:
push   %rbx
mov    %edi,%ebx
mov    $0x7f,%esi
call   1030 <UARTRegConfigModeEnable@plt>
lea    0x14(%rbx),%ecx
testl  $0x1,(%rcx)
je     1120 <UARTCharGet+0x10>
mov    %ebx,%ecx
mov    (%rcx),%ecx
add    $0xc,%ebx
mov    %eax,(%rbx)
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @UARTCharGet(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %2
store i32 0, i32* %3
store i8 0, i8* %4
%5 = load i32, i32* %2
%6 = call i32 @UARTRegConfigModeEnable(i32 %5, i32 127)
store i32 %6, i32* %3
br label %7
7: ; preds = %15, %1
%8 = load i32, i32* %2
%9 = add i32 %8, 20
%10 = zext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = load volatile i32, i32* %11
%13 = and i32 %12, 1
%14 = icmp eq i32 0, %13
br i1 %14, label %15, label %16
15: ; preds = %7
br label %7
16: ; preds = %7
%17 = load i32, i32* %2
%18 = add i32 %17, 0
%19 = zext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
%21 = load volatile i32, i32* %20
%22 = trunc i32 %21 to i8
store i8 %22, i8* %4
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = add i32 %24, 12
%26 = zext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
store volatile i32 %23, i32* %27
%28 = load i8, i8* %4
ret i8 %28
}

LLVM IR (-O2):
define signext i8 @UARTCharGet(i32 %0) {
%2 = tail call i32 @UARTRegConfigModeEnable(i32 %0, i32 127)
%3 = add i32 %0, 20
%4 = zext i32 %3 to i64
%5 = inttoptr i64 %4 to i32*
br label %6
6: ; preds = %6, %1
%7 = load volatile i32, i32* %5
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %6, label %10
10: ; preds = %6
%11 = zext i32 %0 to i64
%12 = inttoptr i64 %11 to i32*
%13 = load volatile i32, i32* %12
%14 = trunc i32 %13 to i8
%15 = add i32 %0, 12
%16 = zext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
store volatile i32 %2, i32* %17
ret i8 %14
}