#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 fputs(char *, int /*<<< orphan*/ *);
int html_putc(char const, int /*<<< orphan*/ *);
int html_putbody(const char *str, FILE *fp) {
  int rc = 0;
  if (!str)
    return 0;
  while (*str && rc != EOF) {
    switch (*str) {
    case '\n':
      rc = fputs("<br>", fp);
      break;
    default:
      rc = html_putc(*str, fp);
    }
    ++str;
  }
  return rc;
}


x86 assembly (clang, -O0):
<html_putbody>:
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    114e <html_putbody+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <html_putbody+0xc1>
jmp    1153 <html_putbody+0x33>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     117a <html_putbody+0x5a>
mov    -0x1c(%rbp),%eax
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    118a <html_putbody+0x6a>
jmp    11db <html_putbody+0xbb>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
sub    $0xa,%al
jne    11b5 <html_putbody+0x95>
jmp    119d <html_putbody+0x7d>
mov    -0x18(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1030 <fputs@plt>
mov    %eax,-0x1c(%rbp)
jmp    11ca <html_putbody+0xaa>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <html_putc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <html_putbody+0x33>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_putbody>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     119c <html_putbody+0x7c>
mov    %rdi,%rbx
mov    (%rdi),%cl
test   %cl,%cl
je     119c <html_putbody+0x7c>
mov    0x2ea9(%rip),%r12
cmpl   $0x0,(%r12)
je     119c <html_putbody+0x7c>
mov    %rsi,%r14
add    $0x1,%rbx
lea    0xeac(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xa,%cl
jne    1180 <html_putbody+0x60>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
jmp    118b <html_putbody+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %cl,%edi
mov    %r14,%rsi
call   1040 <html_putc@plt>
movzbl (%rbx),%ecx
test   %cl,%cl
je     119c <html_putbody+0x7c>
add    $0x1,%rbx
cmp    (%r12),%eax
jne    1160 <html_putbody+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"<br>\00"
define i32 @html_putbody(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 %39
10: ; preds = %2
br label %11
11: ; preds = %34, %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 %37
22: ; preds = %20
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
switch i32 %25, label %29 [
i32 10, label %26
]
26: ; preds = %22
%27 = load i32*, i32** %5
%28 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %27)
store i32 %28, i32* %6
br label %34
29: ; preds = %22
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = load i32*, i32** %5
%33 = call i32 @html_putc(i8 signext %31, i32* %32)
store i32 %33, i32* %6
br label %34
34: ; preds = %29, %26
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %11
37: ; preds = %20
%38 = load i32, i32* %6
store i32 %38, i32* %3
br label %39
39: ; preds = %37, %9
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"<br>\00"
define i32 @html_putbody(i8* %0, i32* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %26, 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 %26
10: ; preds = %4, %18
%11 = phi i8 [ %21, %18 ], [ %5, %4 ]
%12 = phi i8* [ %20, %18 ], [ %0, %4 ]
%13 = icmp eq i8 %11, 10
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %18
16: ; preds = %10
%17 = tail call i32 @html_putc(i8 signext %11, i32* %1)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %15, %14 ], [ %17, %16 ]
%20 = getelementptr inbounds i8, i8* %12, i64 1
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %19, %23
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %10, label %26
26: ; preds = %18, %4, %2
%27 = phi i32 [ 0, %2 ], [ 0, %4 ], [ %19, %18 ]
ret i32 %27
}