#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 fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ iscntrl(int);
int putc(char, int /*<<< orphan*/ *);
int html_putc(int c, FILE *fp) {
  int rc;
  switch (c) {
  case '<':
    rc = fputs("&lt;", fp);
    break;
  case '>':
    rc = fputs("&gt;", fp);
    break;
  case '&':
    rc = fputs("&amp;", fp);
    break;
  case '"':
    rc = fputs("&quot;", fp);
    break;
  default:
    if (!iscntrl(c) || c == '\t' || c == '\r' || c == '\n')
      rc = putc(c, fp);
    else
      rc = putc('?', fp);
  }
  return rc;
}


x86 assembly (clang, -O0):
<html_putc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1c,%eax
ja     11c8 <html_putc+0x98>
mov    -0x20(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
lea    0xf01(%rip),%rdi
call   1040 <fputs@plt>
mov    %eax,-0x14(%rbp)
jmp    1224 <html_putc+0xf4>
mov    -0x10(%rbp),%rsi
lea    0xeee(%rip),%rdi
call   1040 <fputs@plt>
mov    %eax,-0x14(%rbp)
jmp    1224 <html_putc+0xf4>
mov    -0x10(%rbp),%rsi
lea    0xedb(%rip),%rdi
call   1040 <fputs@plt>
mov    %eax,-0x14(%rbp)
jmp    1224 <html_putc+0xf4>
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1040 <fputs@plt>
mov    %eax,-0x14(%rbp)
jmp    1224 <html_putc+0xf4>
mov    -0x4(%rbp),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%eax
je     11f7 <html_putc+0xc7>
cmpl   $0x9,-0x4(%rbp)
je     11f7 <html_putc+0xc7>
cmpl   $0xd,-0x4(%rbp)
je     11f7 <html_putc+0xc7>
cmpl   $0xa,-0x4(%rbp)
jne    120e <html_putc+0xde>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
mov    %eax,-0x14(%rbp)
jmp    121f <html_putc+0xef>
mov    -0x10(%rbp),%rsi
mov    $0x3f,%edi
call   1050 <putc@plt>
mov    %eax,-0x14(%rbp)
jmp    1224 <html_putc+0xf4>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_putc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x22(%rbx),%eax
cmp    $0x1c,%eax
ja     115a <html_putc+0x2a>
lea    0xeb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf2c(%rip),%rdi
jmp    119f <html_putc+0x6f>
mov    %ebx,%edi
call   1030 <iscntrl@plt>
test   %eax,%eax
je     1174 <html_putc+0x44>
cmp    $0xd,%ebx
ja     11ae <html_putc+0x7e>
mov    $0x2600,%eax
bt     %ebx,%eax
jae    11ae <html_putc+0x7e>
movsbl %bl,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <putc@plt>
lea    0xef1(%rip),%rdi
jmp    119f <html_putc+0x6f>
lea    0xede(%rip),%rdi
jmp    119f <html_putc+0x6f>
lea    0xeda(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fputs@plt>
mov    $0x3f,%edi
jmp    1177 <html_putc+0x47>

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

LLVM IR (-O2):
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [5 x i8] c"&gt;\00"
@.str.2 = [6 x i8] c"&amp;\00"
@.str.3 = [7 x i8] c"&quot;\00"
define i32 @html_putc(i32 %0, i32* nocapture %1) {
switch i32 %0, label %11 [
i32 60, label %3
i32 62, label %5
i32 38, label %7
i32 34, label %9
]
3: ; preds = %2
%4 = tail call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %21
5: ; preds = %2
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %21
7: ; preds = %2
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1)
br label %21
9: ; preds = %2
%10 = tail call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %1)
br label %21
11: ; preds = %2
%12 = tail call i32 @iscntrl(i32 %0)
%13 = freeze i32 %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
switch i32 %0, label %19 [
i32 13, label %16
i32 10, label %16
i32 9, label %16
]
16: ; preds = %15, %15, %15, %11
%17 = trunc i32 %0 to i8
%18 = tail call i32 @putc(i8 signext %17, i32* %1)
br label %21
19: ; preds = %15
%20 = tail call i32 @putc(i8 signext 63, i32* %1)
br label %21
21: ; preds = %16, %19, %9, %7, %5, %3
%22 = phi i32 [ %18, %16 ], [ %20, %19 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
ret i32 %22
}