void puts(const char *s) {
  while (*s) {
    while (!((*(volatile unsigned long *)0xf0000010) & (1 << 2)))
      ;
    (*(volatile unsigned long *)0xf0000020) = *s;
    if (*s == '\n') {
      while (!((*(volatile unsigned long *)0xf0000010) & (1 << 2)))
        ;
      (*(volatile unsigned long *)0xf0000020) = '\r';
    }
    s++;
  }
  while (!((*(volatile unsigned long *)0xf0000010) & (1 << 2)))
    ;
}


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11aa <puts+0xaa>
jmp    111a <puts+0x1a>
mov    $0xf0000010,%eax
mov    (%rax),%rax
and    $0x4,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    113c <puts+0x3c>
jmp    1141 <puts+0x41>
jmp    111a <puts+0x1a>
mov    -0x8(%rbp),%rax
movsbq (%rax),%rcx
mov    $0xf0000020,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1199 <puts+0x99>
jmp    1166 <puts+0x66>
mov    $0xf0000010,%eax
mov    (%rax),%rax
and    $0x4,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1188 <puts+0x88>
jmp    118d <puts+0x8d>
jmp    1166 <puts+0x66>
mov    $0xf0000020,%eax
movq   $0xd,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <puts+0x8>
jmp    11af <puts+0xaf>
mov    $0xf0000010,%eax
mov    (%rax),%rax
and    $0x4,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d1 <puts+0xd1>
jmp    11d6 <puts+0xd6>
jmp    11af <puts+0xaf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
mov    $0xf0000010,%eax
mov    (%rdi),%cl
jmp    1117 <puts+0x17>
nopl   0x0(%rax)
mov    0x1(%rdi),%cl
add    $0x1,%rdi
test   %cl,%cl
je     1160 <puts+0x60>
nopl   0x0(%rax,%rax,1)
testq  $0x4,(%rax)
je     1120 <puts+0x20>
movsbq %cl,%rcx
mov    %rcx,0x10(%rax)
cmpb   $0xa,(%rdi)
jne    1110 <puts+0x10>
cs nopw 0x0(%rax,%rax,1)
testq  $0x4,(%rax)
je     1140 <puts+0x40>
movq   $0xd,0x10(%rax)
jmp    1110 <puts+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testq  $0x4,(%rax)
je     1160 <puts+0x60>
ret

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

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