void puts(const char *s) {
  int i;
  for (i = 0; *s; i++, s++) {
    while (*((volatile unsigned long *)(0xc0030000 + 0x14)) & !0x20)
      ;
    *((volatile unsigned long *)(0xc0030000 + 0x00)) = *s;
    if (*s == 10) {
      while (*((volatile unsigned long *)(0xc0030000 + 0x14)) & !0x20)
        ;
      *((volatile unsigned long *)(0xc0030000 + 0x00)) = 13;
    }
  }
}


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a7 <puts+0xa7>
jmp    1121 <puts+0x21>
mov    $0xc0030014,%eax
mov    (%rax),%rax
and    $0x0,%rax
cmp    $0x0,%rax
je     113c <puts+0x3c>
jmp    1121 <puts+0x21>
mov    -0x8(%rbp),%rax
movsbq (%rax),%rcx
mov    $0xc0030000,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1188 <puts+0x88>
jmp    1161 <puts+0x61>
mov    $0xc0030014,%eax
mov    (%rax),%rax
and    $0x0,%rax
cmp    $0x0,%rax
je     117c <puts+0x7c>
jmp    1161 <puts+0x61>
mov    $0xc0030000,%eax
movq   $0xd,(%rax)
jmp    118d <puts+0x8d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <puts+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
mov    (%rdi),%cl
test   %cl,%cl
je     1149 <puts+0x49>
mov    $0xc0030000,%eax
add    $0x1,%rdi
jmp    112b <puts+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
je     1149 <puts+0x49>
mov    0x14(%rax),%rdx
movsbq %cl,%rcx
mov    %rcx,(%rax)
cmpb   $0xa,-0x1(%rdi)
jne    1120 <puts+0x20>
mov    0x14(%rax),%rcx
movq   $0xd,(%rax)
jmp    1120 <puts+0x20>
ret

LLVM IR (-O0):
define void @puts(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %30, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %4
br label %9
9: ; preds = %13, %8
%10 = load volatile i64, i64* inttoptr (i64 3221422100 to i64*)
%11 = and i64 %10, 0
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %9
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i64
store volatile i64 %17, i64* inttoptr (i64 3221422080 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 %29
22: ; preds = %14
br label %23
23: ; preds = %27, %22
%24 = load volatile i64, i64* inttoptr (i64 3221422100 to i64*)
%25 = and i64 %24, 0
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
br label %23
28: ; preds = %23
store volatile i64 13, i64* inttoptr (i64 3221422080 to i64*)
br label %29
29: ; preds = %28, %14
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %2
br label %4
35: ; preds = %4
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 %17, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %15, %13 ], [ %2, %1 ]
%6 = phi i8* [ %14, %13 ], [ %0, %1 ]
%7 = load volatile i64, i64* inttoptr (i64 3221422100 to i64*)
%8 = sext i8 %5 to i64
store volatile i64 %8, i64* inttoptr (i64 3221422080 to i64*)
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = load volatile i64, i64* inttoptr (i64 3221422100 to i64*)
store volatile i64 13, i64* inttoptr (i64 3221422080 to i64*)
br label %13
13: ; preds = %4, %11
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %13, %1
ret void
}