void puts(const char *s) {
  int i;
  for (i = 0; *s; i++, s++) {
    while (*(volatile unsigned long *)(0x90003400) & (1 << 7))
      ;
    *(volatile unsigned long *)(0x90003c00) = *s;
    if (*s == 10) {
      while (*(volatile unsigned long *)(0x90003400) & (1 << 7))
        ;
      *(volatile unsigned long *)(0x90003c00) = 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     11ab <puts+0xab>
jmp    1121 <puts+0x21>
mov    $0x90003400,%eax
mov    (%rax),%rax
and    $0x80,%rax
cmp    $0x0,%rax
je     113e <puts+0x3e>
jmp    1121 <puts+0x21>
mov    -0x8(%rbp),%rax
movsbq (%rax),%rcx
mov    $0x90003c00,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    118c <puts+0x8c>
jmp    1163 <puts+0x63>
mov    $0x90003400,%eax
mov    (%rax),%rax
and    $0x80,%rax
cmp    $0x0,%rax
je     1180 <puts+0x80>
jmp    1163 <puts+0x63>
mov    $0x90003c00,%eax
movq   $0xd,(%rax)
jmp    1191 <puts+0x91>
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     1156 <puts+0x56>
mov    $0x90003400,%eax
jmp    1120 <puts+0x20>
mov    0x1(%rdi),%cl
add    $0x1,%rdi
test   %cl,%cl
je     1156 <puts+0x56>
nopl   0x0(%rax,%rax,1)
testq  $0x80,(%rax)
jne    1120 <puts+0x20>
movsbq %cl,%rcx
mov    %rcx,0x800(%rax)
cmpb   $0xa,(%rdi)
jne    110d <puts+0xd>
nopl   0x0(%rax)
testq  $0x80,(%rax)
jne    1140 <puts+0x40>
movq   $0xd,0x800(%rax)
jmp    110d <puts+0xd>
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 2415932416 to i64*)
%11 = and i64 %10, 128
%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 2415934464 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 2415932416 to i64*)
%25 = and i64 %24, 128
%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 2415934464 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 %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 2415932416 to i64*)
%9 = and i64 %8, 128
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %7
11: ; preds = %7
%12 = sext i8 %5 to i64
store volatile i64 %12, i64* inttoptr (i64 2415934464 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 2415932416 to i64*)
%17 = and i64 %16, 128
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %15
19: ; preds = %15
store volatile i64 13, i64* inttoptr (i64 2415934464 to i64*)
br label %20
20: ; preds = %11, %19
%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
ret void
}