#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 long volatile UART_LSR_THRE;
int /*<<< orphan*/ barrier();
void putc(int c) {
  int j = 0x1000;
  while (--j &&
         !(*((volatile unsigned long *)(0xc0030000 + 0x14)) & UART_LSR_THRE))
    barrier();
  *((volatile unsigned long *)(0xc0030000 + 0x00)) = c;
}


x86 assembly (clang, -O0):
<putc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1000,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
je     115a <putc+0x4a>
mov    $0xc0030014,%eax
mov    (%rax),%rax
mov    0x2ea0(%rip),%rcx
mov    (%rcx),%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    116a <putc+0x5a>
jmp    1176 <putc+0x66>
mov    $0x0,%al
call   1030 <barrier@plt>
jmp    1122 <putc+0x12>
movslq -0x4(%rbp),%rcx
mov    $0xc0030000,%eax
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
mov    $0xfffff001,%ebp
mov    $0xc0030000,%r15d
mov    0x2ebc(%rip),%rbx
nopl   0x0(%rax)
mov    0x14(%r15),%rax
and    (%rbx),%rax
jne    1144 <putc+0x34>
xor    %eax,%eax
call   1030 <barrier@plt>
inc    %ebp
jne    1130 <putc+0x20>
movslq %r14d,%rax
mov    %rax,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@UART_LSR_THRE = global i64 0
define void @putc(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 4096, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = add nsw i32 %5, -1
store i32 %6, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load volatile i64, i64* inttoptr (i64 3221422100 to i64*)
%10 = load volatile i64, i64* @UART_LSR_THRE
%11 = and i64 %9, %10
%12 = icmp ne i64 %11, 0
%13 = xor i1 %12, true
br label %14
14: ; preds = %8, %4
%15 = phi i1 [ false, %4 ], [ %13, %8 ]
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = call i32 (...) @barrier()
br label %4
18: ; preds = %14
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
store volatile i64 %20, i64* inttoptr (i64 3221422080 to i64*)
ret void
}

LLVM IR (-O2):
@UART_LSR_THRE = global i64 0
define void @putc(i32 %0) {
br label %2
2: ; preds = %1, %8
%3 = phi i32 [ 4095, %1 ], [ %10, %8 ]
%4 = load volatile i64, i64* inttoptr (i64 3221422100 to i64*)
%5 = load volatile i64, i64* @UART_LSR_THRE
%6 = and i64 %5, %4
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 (...) @barrier()
%10 = add nsw i32 %3, -1
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %2
12: ; preds = %8, %2
%13 = sext i32 %0 to i64
store volatile i64 %13, i64* inttoptr (i64 3221422080 to i64*)
ret void
}