void putstr(const char *s) {
  while (*s) {
    while ((*(volatile unsigned char *)0x16000018) & (1 << 5))
      ;
    (*(volatile unsigned char *)0x16000000) = *s;
    if (*s == '\n') {
      while ((*(volatile unsigned char *)0x16000018) & (1 << 5))
        ;
      (*(volatile unsigned char *)0x16000000) = '\r';
    }
    s++;
  }
  while ((*(volatile unsigned char *)0x16000018) & (1 << 3))
    ;
}


x86 assembly (clang, -O0):
<putstr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     118b <putstr+0x8b>
jmp    111a <putstr+0x1a>
mov    $0x16000018,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1135 <putstr+0x35>
jmp    111a <putstr+0x1a>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    $0x16000000,%eax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    117a <putstr+0x7a>
jmp    1157 <putstr+0x57>
mov    $0x16000018,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1172 <putstr+0x72>
jmp    1157 <putstr+0x57>
mov    $0x16000000,%eax
movb   $0xd,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <putstr+0x8>
jmp    1190 <putstr+0x90>
mov    $0x16000018,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ab <putstr+0xab>
jmp    1190 <putstr+0x90>
pop    %rbp
ret

x86 assembly (clang, -O2):
<putstr>:
mov    (%rdi),%al
jmp    1117 <putstr+0x17>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x1(%rdi),%al
add    $0x1,%rdi
test   %al,%al
je     1160 <putstr+0x60>
nopl   0x0(%rax,%rax,1)
testb  $0x20,0x16000018
20
jne    1120 <putstr+0x20>
mov    %al,0x16000000
cmpb   $0xa,(%rdi)
jne    1110 <putstr+0x10>
cs nopw 0x0(%rax,%rax,1)
testb  $0x20,0x16000018
20
jne    1140 <putstr+0x40>
movb   $0xd,0x16000000
0d
jmp    1110 <putstr+0x10>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
testb  $0x8,0x16000018
08
jne    1160 <putstr+0x60>
ret

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

LLVM IR (-O2):
define void @putstr(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1, %19
%5 = phi i8 [ %21, %19 ], [ %2, %1 ]
%6 = phi i8* [ %20, %19 ], [ %0, %1 ]
br label %7
7: ; preds = %4, %7
%8 = load volatile i8, i8* inttoptr (i64 369098776 to i8*)
%9 = and i8 %8, 32
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %7
11: ; preds = %7
store volatile i8 %5, i8* inttoptr (i64 369098752 to i8*)
%12 = load i8, i8* %6
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %19
14: ; preds = %11, %14
%15 = load volatile i8, i8* inttoptr (i64 369098776 to i8*)
%16 = and i8 %15, 32
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %14
18: ; preds = %14
store volatile i8 13, i8* inttoptr (i64 369098752 to i8*)
br label %19
19: ; preds = %18, %11
%20 = getelementptr inbounds i8, i8* %6, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %4
23: ; preds = %19, %1
br label %24
24: ; preds = %23, %24
%25 = load volatile i8, i8* inttoptr (i64 369098776 to i8*)
%26 = and i8 %25, 8
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %24
28: ; preds = %24
ret void
}