#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 */

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int h_putc(char const);
int /*<<< orphan*/ stdout;
int h_puts_br(const char *str) {
  int rc = 0;
  if (!str)
    return 0;
  while (*str && rc != EOF) {
    if (*str == '\n')
      fputs("<br>", stdout);
    else
      rc = h_putc(*str);
    ++str;
  }
  return rc;
}


x86 assembly (clang, -O0):
<h_puts_br>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <h_puts_br+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <h_puts_br+0xb6>
jmp    114f <h_puts_br+0x2f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     1176 <h_puts_br+0x56>
mov    -0x14(%rbp),%eax
mov    0x2e7a(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1186 <h_puts_br+0x66>
jmp    11d0 <h_puts_br+0xb0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11b0 <h_puts_br+0x90>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
lea    0xe5a(%rip),%rdi
call   1040 <fputs@plt>
jmp    11bf <h_puts_br+0x9f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <h_putc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114f <h_puts_br+0x2f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<h_puts_br>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebp,%ebp
test   %rdi,%rdi
je     119a <h_puts_br+0x7a>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     119a <h_puts_br+0x7a>
mov    0x2ea9(%rip),%r15
cmpl   $0x0,(%r15)
je     119a <h_puts_br+0x7a>
add    $0x1,%rbx
xor    %ebp,%ebp
mov    0x2e86(%rip),%r12
lea    0xea7(%rip),%r14
nopl   0x0(%rax)
cmp    $0xa,%al
jne    1180 <h_puts_br+0x60>
mov    (%r12),%esi
mov    %r14,%rdi
call   1040 <fputs@plt>
jmp    118a <h_puts_br+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <h_putc@plt>
mov    %eax,%ebp
movzbl (%rbx),%eax
test   %al,%al
je     119a <h_puts_br+0x7a>
add    $0x1,%rbx
cmp    (%r15),%ebp
jne    1160 <h_puts_br+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"<br>\00"
@stdout = global i32 0
define i32 @h_puts_br(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %37
8: ; preds = %1
br label %9
9: ; preds = %32, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* %4
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br label %18
18: ; preds = %14, %9
%19 = phi i1 [ false, %9 ], [ %17, %14 ]
br i1 %19, label %20, label %35
20: ; preds = %18
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* @stdout
%27 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %32
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = call i32 @h_putc(i8 signext %30)
store i32 %31, i32* %4
br label %32
32: ; preds = %28, %25
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %9
35: ; preds = %18
%36 = load i32, i32* %4
store i32 %36, i32* %2
br label %37
37: ; preds = %35, %7
%38 = load i32, i32* %2
ret i32 %38
}

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