#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;
int putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int puts(const char *s) {
  int i = 0;
  if (!s) {
    return (EOF);
  }
  while (*s) {
    if (putc(*s++, stdout) == EOF) {
      return (EOF);
    }
    ++i;
  }
  if (putc('\n', stdout) == EOF) {
    return (EOF);
  }
  ++i;
  return (i);
}


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113f <puts+0x2f>
mov    0x2eb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <puts+0xd3>
jmp    1144 <puts+0x34>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a1 <puts+0x91>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    0x2e6f(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <putc@plt>
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%eax
jne    1193 <puts+0x83>
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <puts+0xd3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <puts+0x34>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%eax
jne    11d4 <puts+0xc4>
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <puts+0xd3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdi,%rdi
je     1162 <puts+0x52>
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     116d <puts+0x5d>
mov    $0x1,%ebx
mov    0x2ea6(%rip),%r15
mov    0x2eaf(%rip),%r12
nopl   0x0(%rax)
mov    (%r15),%esi
movsbl %al,%edi
call   1030 <putc@plt>
cmp    (%r12),%eax
je     1195 <puts+0x85>
movzbl (%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <puts+0x30>
mov    %ebx,%ebp
jmp    1172 <puts+0x62>
mov    0x2e7f(%rip),%rax
mov    (%rax),%ebp
jmp    1197 <puts+0x87>
mov    $0x1,%ebp
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
mov    0x2e5c(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%eax
cmove  %ecx,%ebp
jmp    1197 <puts+0x87>
mov    %eax,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stdout = global i32 0
define i32 @puts(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = load i32, i32* @EOF
store i32 %8, i32* %2
br label %38
9: ; preds = %1
br label %10
10: ; preds = %24, %9
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
%17 = load i8, i8* %15
%18 = load i32, i32* @stdout
%19 = call i32 @putc(i8 signext %17, i32 %18)
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = load i32, i32* @EOF
store i32 %23, i32* %2
br label %38
24: ; preds = %14
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %10
27: ; preds = %10
%28 = load i32, i32* @stdout
%29 = call i32 @putc(i8 signext 10, i32 %28)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = load i32, i32* @EOF
store i32 %33, i32* %2
br label %38
34: ; preds = %27
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
%37 = load i32, i32* %4
store i32 %37, i32* %2
br label %38
38: ; preds = %34, %32, %22, %7
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@EOF = global i32 0
@stdout = global i32 0
define i32 @puts(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %8
6: ; preds = %1
%7 = load i32, i32* @EOF
br label %28
8: ; preds = %3, %16
%9 = phi i8 [ %19, %16 ], [ %4, %3 ]
%10 = phi i32 [ %18, %16 ], [ 1, %3 ]
%11 = phi i8* [ %17, %16 ], [ %0, %3 ]
%12 = load i32, i32* @stdout
%13 = tail call i32 @putc(i8 signext %9, i32 %12)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %28, label %16
16: ; preds = %8
%17 = getelementptr inbounds i8, i8* %11, i64 1
%18 = add i32 %10, 1
%19 = load i8, i8* %17
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %16, %3
%22 = phi i32 [ 1, %3 ], [ %18, %16 ]
%23 = load i32, i32* @stdout
%24 = tail call i32 @putc(i8 signext 10, i32 %23)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
%27 = select i1 %26, i32 %25, i32 %22
br label %28
28: ; preds = %8, %21, %6
%29 = phi i32 [ %7, %6 ], [ %27, %21 ], [ %13, %8 ]
ret i32 %29
}