void BSP_UART_SendByte(unsigned int port, unsigned char byte) {
  if (port == 0) {
    while (!((*(volatile unsigned *)0X50000010) & 0X04))
      ;
    (*(volatile unsigned char *)0X50000020) = byte;
  } else if (port == 1) {
    while (!((*(volatile unsigned *)0X50004010) & 0X04))
      ;
    (*(volatile unsigned char *)0X50004020) = byte;
  } else {
    while (!((*(volatile unsigned *)0X50008010) & 0X04))
      ;
    (*(volatile unsigned char *)0X50008020) = byte;
  }
}


x86 assembly (clang, -O0):
<BSP_UART_SendByte>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    114f <BSP_UART_SendByte+0x4f>
jmp    111c <BSP_UART_SendByte+0x1c>
mov    $0x50000010,%eax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    113b <BSP_UART_SendByte+0x3b>
jmp    1140 <BSP_UART_SendByte+0x40>
jmp    111c <BSP_UART_SendByte+0x1c>
mov    -0x5(%rbp),%cl
mov    $0x50000020,%eax
mov    %cl,(%rax)
jmp    11c9 <BSP_UART_SendByte+0xc9>
cmpl   $0x1,-0x4(%rbp)
jne    1191 <BSP_UART_SendByte+0x91>
jmp    115e <BSP_UART_SendByte+0x5e>
mov    $0x50004010,%eax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117d <BSP_UART_SendByte+0x7d>
jmp    1182 <BSP_UART_SendByte+0x82>
jmp    115e <BSP_UART_SendByte+0x5e>
mov    -0x5(%rbp),%cl
mov    $0x50004020,%eax
mov    %cl,(%rax)
jmp    11c4 <BSP_UART_SendByte+0xc4>
jmp    1196 <BSP_UART_SendByte+0x96>
mov    $0x50008010,%eax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b5 <BSP_UART_SendByte+0xb5>
jmp    11ba <BSP_UART_SendByte+0xba>
jmp    1196 <BSP_UART_SendByte+0x96>
mov    -0x5(%rbp),%cl
mov    $0x50008020,%eax
mov    %cl,(%rax)
jmp    11c9 <BSP_UART_SendByte+0xc9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_UART_SendByte>:
test   %edi,%edi
je     1130 <BSP_UART_SendByte+0x30>
cmp    $0x1,%edi
jne    1150 <BSP_UART_SendByte+0x50>
nopl   0x0(%rax)
testl  $0x4,0x50004010
je     1110 <BSP_UART_SendByte+0x10>
mov    $0x50004020,%eax
mov    %sil,(%rax)
ret
cs nopw 0x0(%rax,%rax,1)
testl  $0x4,0x50000010
je     1130 <BSP_UART_SendByte+0x30>
mov    $0x50000020,%eax
mov    %sil,(%rax)
ret
cs nopw 0x0(%rax,%rax,1)
testl  $0x4,0x50008010
je     1150 <BSP_UART_SendByte+0x50>
mov    $0x50008020,%eax
mov    %sil,(%rax)
ret

LLVM IR (-O0):
define void @BSP_UART_SendByte(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
store i8 %1, i8* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2
br label %8
8: ; preds = %13, %7
%9 = load volatile i32, i32* inttoptr (i64 1342177296 to i32*)
%10 = and i32 %9, 4
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %14
13: ; preds = %8
br label %8
14: ; preds = %8
%15 = load i8, i8* %4
store volatile i8 %15, i8* inttoptr (i64 1342177312 to i8*)
br label %38
16: ; preds = %2
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %28
19: ; preds = %16
br label %20
20: ; preds = %25, %19
%21 = load volatile i32, i32* inttoptr (i64 1342193680 to i32*)
%22 = and i32 %21, 4
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %25, label %26
25: ; preds = %20
br label %20
26: ; preds = %20
%27 = load i8, i8* %4
store volatile i8 %27, i8* inttoptr (i64 1342193696 to i8*)
br label %37
28: ; preds = %16
br label %29
29: ; preds = %34, %28
%30 = load volatile i32, i32* inttoptr (i64 1342210064 to i32*)
%31 = and i32 %30, 4
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
br i1 %33, label %34, label %35
34: ; preds = %29
br label %29
35: ; preds = %29
%36 = load i8, i8* %4
store volatile i8 %36, i8* inttoptr (i64 1342210080 to i8*)
br label %37
37: ; preds = %35, %26
br label %38
38: ; preds = %37, %14
ret void
}

LLVM IR (-O2):
define void @BSP_UART_SendByte(i32 %0, i8 zeroext %1) {
switch i32 %0, label %11 [
i32 0, label %3
i32 1, label %7
]
3: ; preds = %2, %3
%4 = load volatile i32, i32* inttoptr (i64 1342177296 to i32*)
%5 = and i32 %4, 4
%6 = icmp eq i32 %5, 0
br i1 %6, label %3, label %15
7: ; preds = %2, %7
%8 = load volatile i32, i32* inttoptr (i64 1342193680 to i32*)
%9 = and i32 %8, 4
%10 = icmp eq i32 %9, 0
br i1 %10, label %7, label %15
11: ; preds = %2, %11
%12 = load volatile i32, i32* inttoptr (i64 1342210064 to i32*)
%13 = and i32 %12, 4
%14 = icmp eq i32 %13, 0
br i1 %14, label %11, label %15
15: ; preds = %7, %3, %11
%16 = phi i8* [ inttoptr (i64 1342210080 to i8*), %11 ], [ inttoptr (i64 1342177312 to i8*), %3 ], [ inttoptr (i64 1342193696 to i8*), %7 ]
store volatile i8 %1, i8* %16
ret void
}