#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 */
int EOF;
int html_putc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int html_puts(const char *str, FILE *fp) {
  int rc = 0;
  if (!str)
    return 0;
  while (*str && rc != EOF)
    rc = html_putc(*str++, fp);
  return rc;
}


x86 assembly (clang, -O0):
<html_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113e <html_puts+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <html_puts+0x93>
jmp    1143 <html_puts+0x33>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     116a <html_puts+0x5a>
mov    -0x1c(%rbp),%eax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    117a <html_puts+0x6a>
jmp    119d <html_puts+0x8d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <html_putc@plt>
mov    %eax,-0x1c(%rbp)
jmp    1143 <html_puts+0x33>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_puts>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
test   %rdi,%rdi
je     115b <html_puts+0x4b>
mov    %rdi,%rbx
mov    (%rdi),%cl
test   %cl,%cl
je     115b <html_puts+0x4b>
mov    0x2ebc(%rip),%r15
cmpl   $0x0,(%r15)
je     115b <html_puts+0x4b>
mov    %rsi,%r14
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %cl,%edi
mov    %r14,%rsi
call   1030 <html_putc@plt>
movzbl (%rbx),%ecx
test   %cl,%cl
je     115b <html_puts+0x4b>
add    $0x1,%rbx
cmp    (%r15),%eax
jne    1140 <html_puts+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @html_puts(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %3
br label %31
10: ; preds = %2
br label %11
11: ; preds = %22, %10
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* %6
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br label %20
20: ; preds = %16, %11
%21 = phi i1 [ false, %11 ], [ %19, %16 ]
br i1 %21, label %22, label %29
22: ; preds = %20
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
%25 = load i8, i8* %23
%26 = sext i8 %25 to i32
%27 = load i32*, i32** %5
%28 = call i32 @html_putc(i32 %26, i32* %27)
store i32 %28, i32* %6
br label %11
29: ; preds = %20
%30 = load i32, i32* %6
store i32 %30, i32* %3
br label %31
31: ; preds = %29, %9
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @html_puts(i8* %0, i32* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp ne i8 %5, 0
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %7, 0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %21
10: ; preds = %4, %10
%11 = phi i8 [ %16, %10 ], [ %5, %4 ]
%12 = phi i8* [ %14, %10 ], [ %0, %4 ]
%13 = sext i8 %11 to i32
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = tail call i32 @html_putc(i32 %13, i32* %1)
%16 = load i8, i8* %14
%17 = icmp ne i8 %16, 0
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %15, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %10, label %21
21: ; preds = %10, %4, %2
%22 = phi i32 [ 0, %2 ], [ 0, %4 ], [ %15, %10 ]
ret i32 %22
}