#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ uart0_putchar(char const);
int uart0_puts(const char *s) {
  int len = 0;
  (*(volatile unsigned short *)0xF0110) |= 0x0001U;
  while ('\0' != *s) {
    uart0_putchar(*s);
    s++;
    ++len;
  }
  (*(volatile unsigned short *)0xF0110) &= ~0x0001U;
  uart0_putchar('\n');
  return len;
}


x86 assembly (clang, -O0):
<uart0_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0xf0110,%eax
mov    (%rax),%ax
movzwl %ax,%eax
or     $0x1,%eax
mov    %ax,%cx
mov    $0xf0110,%eax
mov    %cx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1173 <uart0_puts+0x63>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <uart0_putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <uart0_puts+0x2c>
mov    $0xf0110,%eax
mov    (%rax),%ax
movzwl %ax,%eax
and    $0xfffffffe,%eax
mov    %ax,%cx
mov    $0xf0110,%eax
mov    %cx,(%rax)
mov    $0xa,%edi
call   1030 <uart0_putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart0_puts>:
push   %r14
push   %rbx
push   %rax
orw    $0x1,0xf0110
mov    (%rdi),%al
test   %al,%al
je     1148 <uart0_puts+0x38>
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <uart0_putchar@plt>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <uart0_puts+0x20>
jmp    114a <uart0_puts+0x3a>
xor    %ebx,%ebx
andw   $0xfffe,0xf0110
mov    $0xa,%edi
call   1030 <uart0_putchar@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @uart0_puts(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load volatile i16, i16* inttoptr (i64 983312 to i16*)
%5 = zext i16 %4 to i32
%6 = or i32 %5, 1
%7 = trunc i32 %6 to i16
store volatile i16 %7, i16* inttoptr (i64 983312 to i16*)
br label %8
8: ; preds = %13, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 0, %11
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = call i32 @uart0_putchar(i8 signext %15)
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %8
21: ; preds = %8
%22 = load volatile i16, i16* inttoptr (i64 983312 to i16*)
%23 = zext i16 %22 to i32
%24 = and i32 %23, -2
%25 = trunc i32 %24 to i16
store volatile i16 %25, i16* inttoptr (i64 983312 to i16*)
%26 = call i32 @uart0_putchar(i8 signext 10)
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @uart0_puts(i8* nocapture %0) {
%2 = load volatile i16, i16* inttoptr (i64 983312 to i16*)
%3 = or i16 %2, 1
store volatile i16 %3, i16* inttoptr (i64 983312 to i16*)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %13, %6 ], [ %4, %1 ]
%8 = phi i32 [ %12, %6 ], [ 0, %1 ]
%9 = phi i8* [ %11, %6 ], [ %0, %1 ]
%10 = tail call i32 @uart0_putchar(i8 signext %7)
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = add nuw nsw i32 %8, 1
%13 = load i8, i8* %11
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %1
%16 = phi i32 [ 0, %1 ], [ %12, %6 ]
%17 = load volatile i16, i16* inttoptr (i64 983312 to i16*)
%18 = and i16 %17, -2
store volatile i16 %18, i16* inttoptr (i64 983312 to i16*)
%19 = tail call i32 @uart0_putchar(i8 signext 10)
ret i32 %16
}