#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 fputs(char const *, int /*<<< orphan*/);
int putchar(char);
int /*<<< orphan*/ stdout;
int puts(const char *s) {
  int ret = fputs(s, stdout);
  if (ret == EOF) {
    return EOF;
  }
  int ret2 = putchar('\n');
  if (ret2 == EOF) {
    return EOF;
  }
  return ret + 1;
}


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%eax
jne    1164 <puts+0x44>
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <puts+0x7d>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%eax
jne    1194 <puts+0x74>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <puts+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    %eax,%ebx
mov    0x2ead(%rip),%r14
cmp    (%r14),%eax
je     1155 <puts+0x35>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r14),%ecx
add    $0x1,%ebx
cmp    %ecx,%eax
cmove  %ecx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@EOF = global i32 0
define i32 @puts(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i32, i32* @stdout
%8 = call i32 @fputs(i8* %6, i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = load i32, i32* @EOF
store i32 %13, i32* %2
br label %24
14: ; preds = %1
%15 = call i32 @putchar(i8 signext 10)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32, i32* @EOF
store i32 %20, i32* %2
br label %24
21: ; preds = %14
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %24
24: ; preds = %21, %19, %12
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@stdout = global i32 0
@EOF = global i32 0
define i32 @puts(i8* %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 @fputs(i8* %0, i32 %2)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = tail call i32 @putchar(i8 signext 10)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
%10 = add nsw i32 %3, 1
%11 = select i1 %9, i32 %8, i32 %10
br label %12
12: ; preds = %1, %6
%13 = phi i32 [ %11, %6 ], [ %3, %1 ]
ret i32 %13
}