#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int fputs(const char *s, FILE *f) {
  while (*s != '\0') {
    if (EOF == fputc(*s++, f)) {
      return EOF;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<fputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1180 <fputs+0x70>
mov    0x2eb1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <fputc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    117b <fputs+0x6b>
mov    0x2e78(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1187 <fputs+0x77>
jmp    1120 <fputs+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ec3(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rbx),%edi
test   %edi,%edi
je     1150 <fputs+0x40>
mov    (%r15),%r12
add    $0x1,%rbx
mov    %r14,%rsi
call   1030 <fputc@plt>
cmp    %rax,%r12
jne    1130 <fputs+0x20>
mov    (%r15),%eax
jmp    1152 <fputs+0x42>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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