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


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1181 <puts+0x61>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    0x2e92(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <putc@plt>
cmp    $0x0,%rax
jge    116b <puts+0x4b>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c0 <puts+0xa0>
jmp    1170 <puts+0x50>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <puts+0xc>
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
cmp    $0x0,%rax
jge    11af <puts+0x8f>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c0 <puts+0xa0>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     115b <puts+0x3b>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    0x2ea0(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r14),%esi
movsbl %al,%edi
call   1030 <putc@plt>
test   %rax,%rax
js     1181 <puts+0x61>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <puts+0x20>
mov    0x2e76(%rip),%rbx
mov    (%rbx),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
test   %rax,%rax
js     1181 <puts+0x61>
mov    (%rbx),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fflush@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%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*
store i8* %0, i8** %3
br label %4
4: ; preds = %17, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = load i32, i32* @stdout
%12 = call i64 @putc(i8 signext %10, i32 %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 %29
16: ; preds = %8
br label %17
17: ; preds = %16
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %4
20: ; preds = %4
%21 = load i32, i32* @stdout
%22 = call i64 @putc(i8 signext 10, i32 %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* @EOF
store i32 %25, i32* %2
br label %29
26: ; preds = %20
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
store i32 %28, i32* %2
br label %29
29: ; preds = %26, %24, %14
%30 = load i32, i32* %2
ret i32 %30
}

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