#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 */
struct buf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bufput(struct buf *, char *, int);
int /*<<< orphan*/ bufputc(struct buf *, char);
void put_scaped_char(struct buf *ob, char c) {
  switch (c) {
  case '<':
    bufput(ob, "&lt;", sizeof "&lt;" - 1);
    break;
  case '>':
    bufput(ob, "&gt;", sizeof "&gt;" - 1);
    break;
  case '&':
    bufput(ob, "&amp;", sizeof "&amp;" - 1);
    break;
  case '"':
    bufput(ob, "&quot;", sizeof "&quot;" - 1);
    break;
  default:
    bufputc(ob, c);
    break;
  }
}


x86 assembly (clang, -O0):
<put_scaped_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1c,%eax
ja     11c4 <put_scaped_char+0xa4>
mov    -0x18(%rbp),%rax
lea    0xead(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xf0d(%rip),%rsi
mov    $0x4,%edx
call   1040 <bufput@plt>
jmp    11d1 <put_scaped_char+0xb1>
mov    -0x8(%rbp),%rdi
lea    0xef8(%rip),%rsi
mov    $0x4,%edx
call   1040 <bufput@plt>
jmp    11d1 <put_scaped_char+0xb1>
mov    -0x8(%rbp),%rdi
lea    0xee3(%rip),%rsi
mov    $0x5,%edx
call   1040 <bufput@plt>
jmp    11d1 <put_scaped_char+0xb1>
mov    -0x8(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x6,%edx
call   1040 <bufput@plt>
jmp    11d1 <put_scaped_char+0xb1>
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <bufputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_scaped_char>:
lea    -0x22(%rsi),%eax
cmp    $0x1c,%eax
ja     1149 <put_scaped_char+0x29>
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf45(%rip),%rsi
mov    $0x6,%edx
jmp    1040 <bufput@plt>
movsbl %sil,%esi
jmp    1030 <bufputc@plt>
lea    0xf25(%rip),%rsi
mov    $0x5,%edx
jmp    1040 <bufput@plt>
lea    0xf0a(%rip),%rsi
mov    $0x4,%edx
jmp    1040 <bufput@plt>
lea    0xefe(%rip),%rsi
mov    $0x4,%edx
jmp    1040 <bufput@plt>

LLVM IR (-O0):
%struct.buf = type { i32 }
@.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 void @put_scaped_char(%struct.buf* %0, i8 signext %1) {
%3 = alloca %struct.buf*
%4 = alloca i8
store %struct.buf* %0, %struct.buf** %3
store i8 %1, i8* %4
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
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 %struct.buf*, %struct.buf** %3
%9 = call i32 @bufput(%struct.buf* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
br label %23
10: ; preds = %2
%11 = load %struct.buf*, %struct.buf** %3
%12 = call i32 @bufput(%struct.buf* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
br label %23
13: ; preds = %2
%14 = load %struct.buf*, %struct.buf** %3
%15 = call i32 @bufput(%struct.buf* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
br label %23
16: ; preds = %2
%17 = load %struct.buf*, %struct.buf** %3
%18 = call i32 @bufput(%struct.buf* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
br label %23
19: ; preds = %2
%20 = load %struct.buf*, %struct.buf** %3
%21 = load i8, i8* %4
%22 = call i32 @bufputc(%struct.buf* %20, i8 signext %21)
br label %23
23: ; preds = %19, %16, %13, %10, %7
ret void
}

LLVM IR (-O2):
%struct.buf = type { i32 }
@.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 void @put_scaped_char(%struct.buf* %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %12 [
i32 60, label %4
i32 62, label %6
i32 38, label %8
i32 34, label %10
]
4: ; preds = %2
%5 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
br label %14
6: ; preds = %2
%7 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
br label %14
8: ; preds = %2
%9 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
br label %14
10: ; preds = %2
%11 = tail call i32 @bufput(%struct.buf* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
br label %14
12: ; preds = %2
%13 = tail call i32 @bufputc(%struct.buf* %0, i8 signext %1)
br label %14
14: ; preds = %12, %10, %8, %6, %4
ret void
}