#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 /*<<< orphan*/ assert(int /*<<< orphan*/);
int fprintf(int /*<<< orphan*/ *, char *, unsigned char);
int fputs(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ isprint(unsigned char);
int putc(int, int /*<<< orphan*/ *);
int escputc(int c, FILE *f) {
  size_t i;
  const struct {
    int c;
    const char *s;
  } a[] = {{'&', "&amp;"},   {'\"', "&quot;"}, {'\'', "&#x27;"},
           {'<', "&#x3C;"},  {'>', "&#x3E;"},  {'\f', "&#x0C;"},
           {'\n', "&#x0A;"}, {'\r', "&#x0D;"}, {'\t', "&#x09;"},
           {'\v', "&#x0B;"}};
  assert(f != NULL);
  for (i = 0; i < sizeof a / sizeof *a; i++) {
    if (a[i].c == c) {
      return fputs(a[i].s, f);
    }
  }
  if (!isprint((unsigned char)c)) {
    return fprintf(f, "&#x%X;", (unsigned char)c);
  }
  return putc(c, f);
}


x86 assembly (clang, -O0):
<escputc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0x2c00(%rip),%rsi
mov    $0xa0,%edx
call   1070 <memcpy@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movq   $0x0,-0x18(%rbp)
cmpq   $0xa,-0x18(%rbp)
jae    1209 <escputc+0xa9>
mov    -0x18(%rbp),%rcx
lea    -0xc0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    11f3 <escputc+0x93>
mov    -0x18(%rbp),%rcx
lea    -0xc0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fputs@plt>
mov    %eax,-0x4(%rbp)
jmp    124a <escputc+0xea>
jmp    11f8 <escputc+0x98>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a4 <escputc+0x44>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1080 <isprint@plt>
cmp    $0x0,%eax
jne    123b <escputc+0xdb>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%eax
lea    0xe1a(%rip),%rsi
movzbl %al,%edx
call   1060 <fprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    124a <escputc+0xea>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <putc@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escputc>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1050 <assert@plt>
lea    -0x9(%rbx),%ecx
cmp    $0x35,%ecx
ja     11a4 <escputc+0x54>
xor    %eax,%eax
lea    0xe88(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x8,%eax
jmp    11da <escputc+0x8a>
mov    $0x6,%eax
jmp    11da <escputc+0x8a>
mov    $0x9,%eax
jmp    11da <escputc+0x8a>
mov    $0x5,%eax
jmp    11da <escputc+0x8a>
mov    $0x7,%eax
jmp    11da <escputc+0x8a>
movzbl %bl,%ebp
mov    %ebp,%edi
call   1070 <isprint@plt>
test   %eax,%eax
je     11f6 <escputc+0xa6>
mov    %ebx,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <putc@plt>
mov    $0x1,%eax
jmp    11da <escputc+0x8a>
mov    $0x2,%eax
jmp    11da <escputc+0x8a>
mov    $0x3,%eax
jmp    11da <escputc+0x8a>
mov    $0x4,%eax
shl    $0x4,%rax
lea    0x2b9b(%rip),%rcx
mov    0x8(%rax,%rcx,1),%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fputs@plt>
lea    0xf20(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [7 x i8] c"&#x27;\00"
@.str.3 = [7 x i8] c"&#x3C;\00"
@.str.4 = [7 x i8] c"&#x3E;\00"
@.str.5 = [7 x i8] c"&#x0C;\00"
@.str.6 = [7 x i8] c"&#x0A;\00"
@.str.7 = [7 x i8] c"&#x0D;\00"
@.str.8 = [7 x i8] c"&#x09;\00"
@.str.9 = [7 x i8] c"&#x0B;\00"
@__const.escputc.a = [10 x %struct.anon] [%struct.anon { i32 38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0) }, %struct.anon { i32 13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0) }, %struct.anon { i32 11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0) }]
@.str.10 = [7 x i8] c"&#x%X;\00"
define i32 @escputc(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca [10 x %struct.anon]
store i32 %0, i32* %4
store i32* %1, i32** %5
%8 = bitcast [10 x %struct.anon]* %7 to i8*
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i64 0, i64* %6
br label %13
13: ; preds = %31, %2
%14 = load i64, i64* %6
%15 = icmp ult i64 %14, 10
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = load i64, i64* %6
%18 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* %7, i64 0, i64 %17
%19 = getelementptr inbounds %struct.anon, %struct.anon* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32, i32* %4
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %16
%24 = load i64, i64* %6
%25 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* %7, i64 0, i64 %24
%26 = getelementptr inbounds %struct.anon, %struct.anon* %25, i32 0, i32 1
%27 = load i8*, i8** %26
%28 = load i32*, i32** %5
%29 = call i32 @fputs(i8* %27, i32* %28)
store i32 %29, i32* %3
br label %48
30: ; preds = %16
br label %31
31: ; preds = %30
%32 = load i64, i64* %6
%33 = add i64 %32, 1
store i64 %33, i64* %6
br label %13
34: ; preds = %13
%35 = load i32, i32* %4
%36 = trunc i32 %35 to i8
%37 = call i32 @isprint(i8 zeroext %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = load i32*, i32** %5
%41 = load i32, i32* %4
%42 = trunc i32 %41 to i8
%43 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8 zeroext %42)
store i32 %43, i32* %3
br label %48
44: ; preds = %34
%45 = load i32, i32* %4
%46 = load i32*, i32** %5
%47 = call i32 @putc(i32 %45, i32* %46)
store i32 %47, i32* %3
br label %48
48: ; preds = %44, %39, %23
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
%struct.anon = type { i32, i8* }
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [7 x i8] c"&#x27;\00"
@.str.3 = [7 x i8] c"&#x3C;\00"
@.str.4 = [7 x i8] c"&#x3E;\00"
@.str.5 = [7 x i8] c"&#x0C;\00"
@.str.6 = [7 x i8] c"&#x0A;\00"
@.str.7 = [7 x i8] c"&#x0D;\00"
@.str.8 = [7 x i8] c"&#x09;\00"
@.str.9 = [7 x i8] c"&#x0B;\00"
@__const.escputc.a = [10 x %struct.anon] [%struct.anon { i32 38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0) }, %struct.anon { i32 13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0) }, %struct.anon { i32 11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0) }]
@.str.10 = [7 x i8] c"&#x%X;\00"
define i32 @escputc(i32 %0, i32* %1) {
%3 = icmp ne i32* %1, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
switch i32 %0, label %20 [
i32 38, label %15
i32 34, label %6
i32 39, label %7
i32 60, label %8
i32 62, label %9
i32 12, label %10
i32 10, label %11
i32 13, label %12
i32 9, label %13
i32 11, label %14
]
6: ; preds = %2
br label %15
7: ; preds = %2
br label %15
8: ; preds = %2
br label %15
9: ; preds = %2
br label %15
10: ; preds = %2
br label %15
11: ; preds = %2
br label %15
12: ; preds = %2
br label %15
13: ; preds = %2
br label %15
14: ; preds = %2
br label %15
15: ; preds = %2, %14, %13, %12, %11, %10, %9, %8, %7, %6
%16 = phi i64 [ 0, %2 ], [ 1, %6 ], [ 2, %7 ], [ 3, %8 ], [ 4, %9 ], [ 5, %10 ], [ 6, %11 ], [ 7, %12 ], [ 8, %13 ], [ 9, %14 ]
%17 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* @__const.escputc.a, i64 0, i64 %16, i32 1
%18 = load i8*, i8** %17
%19 = tail call i32 @fputs(i8* %18, i32* %1)
br label %28
20: ; preds = %2
%21 = trunc i32 %0 to i8
%22 = tail call i32 @isprint(i8 zeroext %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8 zeroext %21)
br label %28
26: ; preds = %20
%27 = tail call i32 @putc(i32 %0, i32* %1)
br label %28
28: ; preds = %26, %24, %15
%29 = phi i32 [ %19, %15 ], [ %27, %26 ], [ %25, %24 ]
ret i32 %29
}