#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 /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
void html_puts(char *string) {
  unsigned int i;
  for (i = 0; string[i] != '\0'; i++) {
    switch (string[i]) {
    case '&':
      fputs("&amp;", stdout);
      break;
    case '\"':
      fputs("&quot;", stdout);
      break;
    case '\'':
      fputs("&apos;", stdout);
      break;
    case '>':
      fputs("&lt;", stdout);
      break;
    case '<':
      fputs("&gt;", stdout);
      break;
    default:
      putchar(string[i]);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<html_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     121d <html_puts+0xfd>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1c,%eax
ja     11fa <html_puts+0xda>
mov    -0x18(%rbp),%rax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
lea    0xeec(%rip),%rdi
call   1040 <fputs@plt>
jmp    120a <html_puts+0xea>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
lea    0xed8(%rip),%rdi
call   1040 <fputs@plt>
jmp    120a <html_puts+0xea>
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
lea    0xec5(%rip),%rdi
call   1040 <fputs@plt>
jmp    120a <html_puts+0xea>
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
lea    0xeb2(%rip),%rdi
call   1040 <fputs@plt>
jmp    120a <html_puts+0xea>
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
lea    0xe9d(%rip),%rdi
call   1040 <fputs@plt>
jmp    120a <html_puts+0xea>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    120f <html_puts+0xef>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <html_puts+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_puts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11e5 <html_puts+0xc5>
mov    %rdi,%rbx
mov    $0x1,%r14d
lea    0xebb(%rip),%r15
mov    0x2e94(%rip),%r12
lea    0xf3a(%rip),%r13
lea    0xf2e(%rip),%rbp
jmp    117f <html_puts+0x5f>
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%eax
movzbl (%rbx,%rax,1),%eax
add    $0x1,%r14d
test   %al,%al
je     11e5 <html_puts+0xc5>
movsbl %al,%edi
lea    -0x22(%rdi),%eax
cmp    $0x1c,%eax
ja     115c <html_puts+0x3c>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r12),%esi
lea    0xedc(%rip),%rdi
call   1040 <fputs@plt>
jmp    1170 <html_puts+0x50>
mov    (%r12),%esi
lea    0xec4(%rip),%rdi
call   1040 <fputs@plt>
jmp    1170 <html_puts+0x50>
mov    (%r12),%esi
lea    0xebf(%rip),%rdi
call   1040 <fputs@plt>
jmp    1170 <html_puts+0x50>
mov    (%r12),%esi
mov    %r13,%rdi
call   1040 <fputs@plt>
jmp    1170 <html_puts+0x50>
mov    (%r12),%esi
mov    %rbp,%rdi
call   1040 <fputs@plt>
jmp    1170 <html_puts+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"&amp;\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [7 x i8] c"&apos;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [5 x i8] c"&gt;\00"
define void @html_puts(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %42, %1
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %45
12: ; preds = %4
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %34 [
i32 38, label %19
i32 34, label %22
i32 39, label %25
i32 62, label %28
i32 60, label %31
]
19: ; preds = %12
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %41
22: ; preds = %12
%23 = load i32, i32* @stdout
%24 = call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %41
25: ; preds = %12
%26 = load i32, i32* @stdout
%27 = call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %41
28: ; preds = %12
%29 = load i32, i32* @stdout
%30 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %41
31: ; preds = %12
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %41
34: ; preds = %12
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @putchar(i8 signext %39)
br label %41
41: ; preds = %34, %31, %28, %25, %22, %19
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add i32 %43, 1
store i32 %44, i32* %3
br label %4
45: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"&amp;\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [7 x i8] c"&apos;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [5 x i8] c"&gt;\00"
define void @html_puts(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %31, label %4
4: ; preds = %1, %25
%5 = phi i8 [ %29, %25 ], [ %2, %1 ]
%6 = phi i32 [ %26, %25 ], [ 0, %1 ]
%7 = sext i8 %5 to i32
switch i32 %7, label %23 [
i32 38, label %8
i32 34, label %11
i32 39, label %14
i32 62, label %17
i32 60, label %20
]
8: ; preds = %4
%9 = load i32, i32* @stdout
%10 = tail call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %25
11: ; preds = %4
%12 = load i32, i32* @stdout
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %25
14: ; preds = %4
%15 = load i32, i32* @stdout
%16 = tail call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %25
17: ; preds = %4
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %25
20: ; preds = %4
%21 = load i32, i32* @stdout
%22 = tail call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %25
23: ; preds = %4
%24 = tail call i32 @putchar(i8 signext %5)
br label %25
25: ; preds = %8, %11, %14, %17, %20, %23
%26 = add i32 %6, 1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %4
31: ; preds = %25, %1
ret void
}