#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 EOF;
scalar_t__ putchar_unlocked(char);
int puts_unlocked(const char *s) {
  while (*s) {
    if (putchar_unlocked(*s++) < 0)
      return EOF;
  }
  if (putchar_unlocked('\n') < 0)
    return EOF;
  return 1;
}


x86 assembly (clang, -O0):
<puts_unlocked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1160 <puts_unlocked+0x50>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <putchar_unlocked@plt>
cmp    $0x0,%rax
jge    115b <puts_unlocked+0x4b>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <puts_unlocked+0x7c>
jmp    111c <puts_unlocked+0xc>
mov    $0xa,%edi
call   1030 <putchar_unlocked@plt>
cmp    $0x0,%rax
jge    1185 <puts_unlocked+0x75>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <puts_unlocked+0x7c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts_unlocked>:
push   %rbx
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%eax
test   %al,%al
je     113a <puts_unlocked+0x2a>
add    $0x1,%rbx
movsbl %al,%edi
call   1030 <putchar_unlocked@plt>
test   %rax,%rax
jns    1120 <puts_unlocked+0x10>
jmp    1151 <puts_unlocked+0x41>
mov    $0xa,%edi
call   1030 <putchar_unlocked@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jns    115a <puts_unlocked+0x4a>
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @puts_unlocked(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %16, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %3
%11 = load i8, i8* %9
%12 = call i64 @putchar_unlocked(i8 signext %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = load i32, i32* @EOF
store i32 %15, i32* %2
br label %23
16: ; preds = %8
br label %4
17: ; preds = %4
%18 = call i64 @putchar_unlocked(i8 signext 10)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32, i32* @EOF
store i32 %21, i32* %2
br label %23
22: ; preds = %17
store i32 1, i32* %2
br label %23
23: ; preds = %22, %20, %14
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @puts_unlocked(i8* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i8* [ %0, %1 ], [ %7, %6 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = tail call i64 @putchar_unlocked(i8 signext %4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %2
10: ; preds = %6
%11 = load i32, i32* @EOF
br label %17
12: ; preds = %2
%13 = tail call i64 @putchar_unlocked(i8 signext 10)
%14 = icmp slt i64 %13, 0
%15 = load i32, i32* @EOF
%16 = select i1 %14, i32 %15, i32 1
br label %17
17: ; preds = %12, %10
%18 = phi i32 [ %11, %10 ], [ %16, %12 ]
ret i32 %18
}