void UART1_send(unsigned char *buffer, unsigned char length) {
  unsigned char cnt = 0;
  while (length--) {
    while (!((*(volatile unsigned long *)(0xE0010000 + 0x14)) & 0x20))
      ;
    (*(volatile unsigned long *)(0xE0010000 + 0x00)) = buffer[cnt++];
  }
}


x86 assembly (clang, -O0):
<UART1_send>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movb   $0x0,-0xa(%rbp)
mov    -0x9(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x9(%rbp)
cmp    $0x0,%al
je     1176 <UART1_send+0x76>
jmp    112a <UART1_send+0x2a>
mov    $0xe0010014,%eax
mov    (%rax),%rax
and    $0x20,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    114c <UART1_send+0x4c>
jmp    1151 <UART1_send+0x51>
jmp    112a <UART1_send+0x2a>
mov    -0x8(%rbp),%rax
mov    -0xa(%rbp),%cl
mov    %cl,%dl
add    $0x1,%dl
mov    %dl,-0xa(%rbp)
movzbl %cl,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,%ecx
mov    $0xe0010000,%eax
mov    %rcx,(%rax)
jmp    1112 <UART1_send+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<UART1_send>:
test   %esi,%esi
je     1181 <UART1_send+0x81>
mov    $0xe0010000,%eax
cmp    $0x1,%sil
jne    1113 <UART1_send+0x13>
xor    %ecx,%ecx
jmp    115b <UART1_send+0x5b>
mov    %esi,%r8d
and    $0xfe,%r8b
xor    %ecx,%ecx
nopl   0x0(%rax)
testq  $0x20,0x14(%rax)
je     1120 <UART1_send+0x20>
mov    %rcx,%r9
or     $0x1,%r9
movzbl (%rdi,%rcx,1),%edx
mov    %rdx,(%rax)
nopl   0x0(%rax,%rax,1)
testq  $0x20,0x14(%rax)
je     1140 <UART1_send+0x40>
add    $0x2,%rcx
movzbl (%rdi,%r9,1),%edx
mov    %rdx,(%rax)
cmp    %r8b,%cl
jne    1120 <UART1_send+0x20>
test   $0x1,%sil
je     1181 <UART1_send+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
testq  $0x20,0x14(%rax)
je     1170 <UART1_send+0x70>
movzbl (%rdi,%rcx,1),%ecx
mov    %rcx,(%rax)
ret

LLVM IR (-O0):
define void @UART1_send(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8
store i8* %0, i8** %3
store i8 %1, i8* %4
store i8 0, i8* %5
br label %6
6: ; preds = %17, %2
%7 = load i8, i8* %4
%8 = add i8 %7, -1
store i8 %8, i8* %4
%9 = icmp ne i8 %7, 0
br i1 %9, label %10, label %25
10: ; preds = %6
br label %11
11: ; preds = %16, %10
%12 = load volatile i64, i64* inttoptr (i64 3758161940 to i64*)
%13 = and i64 %12, 32
%14 = icmp ne i64 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %17
16: ; preds = %11
br label %11
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = load i8, i8* %5
%20 = add i8 %19, 1
store i8 %20, i8* %5
%21 = zext i8 %19 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i64
store volatile i64 %24, i64* inttoptr (i64 3758161920 to i64*)
br label %6
25: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @UART1_send(i8* nocapture %0, i8 zeroext %1) {
%3 = icmp eq i8 %1, 0
br i1 %3, label %43, label %4
4: ; preds = %2
%5 = and i8 %1, 1
%6 = icmp eq i8 %1, 1
br i1 %6, label %32, label %7
7: ; preds = %4
%8 = and i8 %1, -2
br label %9
9: ; preds = %25, %7
%10 = phi i64 [ 0, %7 ], [ %26, %25 ]
%11 = phi i8 [ 0, %7 ], [ %30, %25 ]
br label %12
12: ; preds = %9, %12
%13 = load volatile i64, i64* inttoptr (i64 3758161940 to i64*)
%14 = and i64 %13, 32
%15 = icmp eq i64 %14, 0
br i1 %15, label %12, label %16
16: ; preds = %12
%17 = or i64 %10, 1
%18 = getelementptr inbounds i8, i8* %0, i64 %10
%19 = load i8, i8* %18
%20 = zext i8 %19 to i64
store volatile i64 %20, i64* inttoptr (i64 3758161920 to i64*)
br label %21
21: ; preds = %21, %16
%22 = load volatile i64, i64* inttoptr (i64 3758161940 to i64*)
%23 = and i64 %22, 32
%24 = icmp eq i64 %23, 0
br i1 %24, label %21, label %25
25: ; preds = %21
%26 = add nuw nsw i64 %10, 2
%27 = getelementptr inbounds i8, i8* %0, i64 %17
%28 = load i8, i8* %27
%29 = zext i8 %28 to i64
store volatile i64 %29, i64* inttoptr (i64 3758161920 to i64*)
%30 = add i8 %11, 2
%31 = icmp eq i8 %30, %8
br i1 %31, label %32, label %9
32: ; preds = %25, %4
%33 = phi i64 [ 0, %4 ], [ %26, %25 ]
%34 = icmp eq i8 %5, 0
br i1 %34, label %43, label %35
35: ; preds = %32, %35
%36 = load volatile i64, i64* inttoptr (i64 3758161940 to i64*)
%37 = and i64 %36, 32
%38 = icmp eq i64 %37, 0
br i1 %38, label %35, label %39
39: ; preds = %35
%40 = getelementptr inbounds i8, i8* %0, i64 %33
%41 = load i8, i8* %40
%42 = zext i8 %41 to i64
store volatile i64 %42, i64* inttoptr (i64 3758161920 to i64*)
br label %43
43: ; preds = %39, %32, %2
ret void
}