#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 put_scaped_char(struct buf *ob, char c) {
  switch (c) {
  case '<':
    bufput(ob, "&lt;", sizeof "&lt;" - 1);
    return 1;
  case '>':
    bufput(ob, "&gt;", sizeof "&gt;" - 1);
    return 1;
  case '&':
    bufput(ob, "&amp;", sizeof "&amp;" - 1);
    return 1;
  case '"':
    bufput(ob, "&quot;", sizeof "&quot;" - 1);
    return 1;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<put_scaped_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x1c,%eax
ja     11d0 <put_scaped_char+0xc0>
mov    -0x20(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xf1d(%rip),%rsi
mov    $0x4,%edx
call   1030 <bufput@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <put_scaped_char+0xc7>
mov    -0x10(%rbp),%rdi
lea    0xf01(%rip),%rsi
mov    $0x4,%edx
call   1030 <bufput@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <put_scaped_char+0xc7>
mov    -0x10(%rbp),%rdi
lea    0xee5(%rip),%rsi
mov    $0x5,%edx
call   1030 <bufput@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <put_scaped_char+0xc7>
mov    -0x10(%rbp),%rdi
lea    0xeca(%rip),%rsi
mov    $0x6,%edx
call   1030 <bufput@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <put_scaped_char+0xc7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_scaped_char>:
push   %rax
xor    %eax,%eax
add    $0xffffffde,%esi
cmp    $0x1c,%esi
ja     1166 <put_scaped_char+0x56>
lea    0xede(%rip),%rcx
movslq (%rcx,%rsi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf52(%rip),%rsi
mov    $0x6,%edx
jmp    115c <put_scaped_char+0x4c>
lea    0xf3e(%rip),%rsi
mov    $0x5,%edx
jmp    115c <put_scaped_char+0x4c>
lea    0xf26(%rip),%rsi
jmp    1157 <put_scaped_char+0x47>
lea    0xf22(%rip),%rsi
mov    $0x4,%edx
call   1030 <bufput@plt>
mov    $0x1,%eax
pop    %rcx
ret

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

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 i32 @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 %12
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 %12
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 %12
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 %12
12: ; preds = %2, %10, %8, %6, %4
%13 = phi i32 [ 1, %10 ], [ 1, %8 ], [ 1, %6 ], [ 1, %4 ], [ 0, %2 ]
ret i32 %13
}