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


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2eb2(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    114d <puts+0x3d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <puts+0x82>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1030 <fputs@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1183 <puts+0x73>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <puts+0x82>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%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   %r14
push   %rbx
push   %rax
mov    0x2ec5(%rip),%r14
mov    (%r14),%esi
call   1030 <fputs@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1141 <puts+0x31>
mov    (%r14),%esi
lea    0xecd(%rip),%rdi
call   1030 <fputs@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmovs  %ecx,%ebx
add    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [2 x i8] c"\0A\00"
define i32 @puts(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* @stdout
%8 = call i32 @fputs(i8* %6, i32 %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i32, i32* %5
store i32 %12, i32* %2
br label %28
13: ; preds = %1
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = add nsw i32 %15, %14
store i32 %16, i32* %4
%17 = load i32, i32* @stdout
%18 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = load i32, i32* %5
store i32 %22, i32* %2
br label %28
23: ; preds = %13
%24 = load i32, i32* %5
%25 = load i32, i32* %4
%26 = add nsw i32 %25, %24
store i32 %26, i32* %4
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %28
28: ; preds = %23, %21, %11
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [2 x i8] c"\0A\00"
define i32 @puts(i8* %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 @fputs(i8* %0, i32 %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = load i32, i32* @stdout
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp slt i32 %7, 0
%9 = select i1 %8, i32 0, i32 %3
%10 = add nsw i32 %9, %7
br label %11
11: ; preds = %5, %1
%12 = phi i32 [ %3, %1 ], [ %10, %5 ]
ret i32 %12
}