#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;
size_t const fwrite(void *, int, size_t const, int /*<<< orphan*/ *);
scalar_t__ putc(char const, int /*<<< orphan*/ *);
size_t strlen(char const *);
int fputs(const char *s, FILE *stream) {
  const size_t len = strlen(s);
  if (len == 1)
    return putc(*s, stream) == EOF ? EOF : 0;
  if (fwrite((void *)s, 1, len, stream) != len)
    return EOF;
  return 0;
}


x86 assembly (clang, -O0):
<fputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
jne    11a4 <fputs+0x74>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%rax
jne    118d <fputs+0x5d>
mov    0x2e67(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1198 <fputs+0x68>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1198 <fputs+0x68>
mov    -0x28(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    11dd <fputs+0xad>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fwrite@plt>
cmp    -0x20(%rbp),%rax
je     11d6 <fputs+0xa6>
mov    0x2e1d(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    11dd <fputs+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputs>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x1,%rax
jne    1168 <fputs+0x38>
movsbl (%rbx),%edi
mov    %r14,%rsi
call   1040 <putc@plt>
mov    %rax,%rcx
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
xor    %edx,%edx
cmp    %rax,%rcx
cmovne %edx,%eax
jmp    1191 <fputs+0x61>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %r15,%rcx
je     1191 <fputs+0x61>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
pop    %rbx
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*
%6 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %6
%9 = load i64, i64* %6
%10 = icmp eq i64 %9, 1
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = load i32*, i32** %5
%15 = call i64 @putc(i8 signext %13, i32* %14)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = load i64, i64* @EOF
br label %21
20: ; preds = %11
br label %21
21: ; preds = %20, %18
%22 = phi i64 [ %19, %18 ], [ 0, %20 ]
%23 = trunc i64 %22 to i32
store i32 %23, i32* %3
br label %35
24: ; preds = %2
%25 = load i8*, i8** %4
%26 = load i64, i64* %6
%27 = load i32*, i32** %5
%28 = call i64 @fwrite(i8* %25, i32 1, i64 %26, i32* %27)
%29 = load i64, i64* %6
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i64, i64* @EOF
%33 = trunc i64 %32 to i32
store i32 %33, i32* %3
br label %35
34: ; preds = %24
store i32 0, i32* %3
br label %35
35: ; preds = %34, %31, %21
%36 = load i32, i32* %3
ret i32 %36
}

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