#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(char const, int /*<<< orphan*/ *);
int fputs(const char *str, FILE *stream) {
  while (*str) {
    if (fputc(*str, stream) == EOF)
      return EOF;
    str++;
  }
  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
cmpb   $0x0,(%rax)
je     1172 <fputs+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
jne    1161 <fputs+0x51>
mov    0x2e92(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1179 <fputs+0x69>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <fputs+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     1161 <fputs+0x51>
mov    %rsi,%rbx
mov    %rdi,%rbp
add    $0x1,%rbp
mov    0x2eb7(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     115e <fputs+0x4e>
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1140 <fputs+0x30>
jmp    1161 <fputs+0x51>
mov    %eax,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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 = %20, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = load i32*, i32** %5
%14 = call i64 @fputc(i8 signext %12, i32* %13)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i64, i64* @EOF
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
br label %24
20: ; preds = %10
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
br label %6
23: ; preds = %6
store i32 0, i32* %3
br label %24
24: ; preds = %23, %17
%25 = load i32, i32* %3
ret i32 %25
}

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