#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 readl(int);
int /*<<< orphan*/ writel(char const, int);
void serial_putc(const char c) {
  if (c == '\n') {
    while ((readl((0xf3100000 + (((0x01 << 10) | (0x33 << 2))))) & (1 << 21)))
      ;
    writel('\r', (0xf3100000 + (((0x01 << 10) | (0x30 << 2)))));
  }
  while ((readl((0xf3100000 + (((0x01 << 10) | (0x33 << 2))))) & (1 << 21)))
    ;
  writel(c, (0xf3100000 + (((0x01 << 10) | (0x30 << 2)))));
}


x86 assembly (clang, -O0):
<serial_putc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
jne    116c <serial_putc+0x4c>
jmp    1140 <serial_putc+0x20>
mov    $0xf31004cc,%edi
call   1030 <readl@plt>
and    $0x200000,%eax
cmp    $0x0,%eax
je     115d <serial_putc+0x3d>
jmp    1140 <serial_putc+0x20>
mov    $0xd,%edi
mov    $0xf31004c0,%esi
call   1040 <writel@plt>
jmp    1171 <serial_putc+0x51>
mov    $0xf31004cc,%edi
call   1030 <readl@plt>
and    $0x200000,%eax
cmp    $0x0,%eax
je     118e <serial_putc+0x6e>
jmp    1171 <serial_putc+0x51>
mov    $0xf31004c0,%esi
movsbl -0x1(%rbp),%edi
call   1040 <writel@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_putc>:
push   %rbx
mov    %edi,%ebx
cmp    $0xa,%bl
jne    1150 <serial_putc+0x30>
nopl   0x0(%rax,%rax,1)
mov    $0xf31004cc,%edi
call   1030 <readl@plt>
test   $0x200000,%eax
jne    1130 <serial_putc+0x10>
mov    $0xd,%edi
mov    $0xf31004c0,%esi
call   1040 <writel@plt>
mov    $0xf31004cc,%edi
call   1030 <readl@plt>
test   $0x200000,%eax
jne    1150 <serial_putc+0x30>
movsbl %bl,%edi
mov    $0xf31004c0,%esi
pop    %rbx
jmp    1040 <writel@plt>

LLVM IR (-O0):
define void @serial_putc(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %14
6: ; preds = %1
br label %7
7: ; preds = %11, %6
%8 = call i32 @readl(i32 -217054004)
%9 = and i32 %8, 2097152
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = call i32 @writel(i8 signext 13, i32 -217054016)
br label %14
14: ; preds = %12, %1
br label %15
15: ; preds = %19, %14
%16 = call i32 @readl(i32 -217054004)
%17 = and i32 %16, 2097152
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
br label %15
20: ; preds = %15
%21 = load i8, i8* %2
%22 = call i32 @writel(i8 signext %21, i32 -217054016)
ret void
}

LLVM IR (-O2):
define void @serial_putc(i8 signext %0) {
%2 = icmp eq i8 %0, 10
br i1 %2, label %3, label %9
3: ; preds = %1, %3
%4 = tail call i32 @readl(i32 -217054004)
%5 = and i32 %4, 2097152
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %3
7: ; preds = %3
%8 = tail call i32 @writel(i8 signext 13, i32 -217054016)
br label %9
9: ; preds = %7, %1
br label %10
10: ; preds = %9, %10
%11 = tail call i32 @readl(i32 -217054004)
%12 = and i32 %11, 2097152
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %10
14: ; preds = %10
%15 = tail call i32 @writel(i8 signext %0, i32 -217054016)
ret void
}