#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 */
char ch();
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ gch();
char hexdigit(char);
int spechar(void) {
  char c;
  int r;
  c = ch();
  if (c == 'n')
    c = 10;
  else if (c == 't')
    c = 9;
  else if (c == 'r')
    c = 13;
  else if (c == 'f')
    c = 12;
  else if (c == 'b')
    c = 8;
  else if (c == 0)
    return 0;
  gch();
  if (c == 'x') {
    c = hexdigit(ch());
    if (c == 127) {
      error("bad escape");
      return '?';
    }
    r = c;
    gch();
    c = hexdigit(ch());
    if (c == 127)
      return r;
    r <<= 4;
    r |= c;
    gch();
    return r;
  }
  if (c == '0') {
    int n;
    n = 0;
    r = 0;
    while (n < 3) {
      c = ch();
      if (c < '0' || c > '7')
        return r;
      r <<= 3;
      r |= c - '0';
      n++;
      gch();
    }
    return r;
  }
  return (c);
}


x86 assembly (clang, -O0):
<spechar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <ch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
jne    1168 <spechar+0x28>
movb   $0xa,-0x5(%rbp)
jmp    11f2 <spechar+0xb2>
movsbl -0x5(%rbp),%eax
cmp    $0x74,%eax
jne    117e <spechar+0x3e>
movb   $0x9,-0x5(%rbp)
jmp    11ed <spechar+0xad>
movsbl -0x5(%rbp),%eax
cmp    $0x72,%eax
jne    1194 <spechar+0x54>
movb   $0xd,-0x5(%rbp)
jmp    11e8 <spechar+0xa8>
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jne    11aa <spechar+0x6a>
movb   $0xc,-0x5(%rbp)
jmp    11e3 <spechar+0xa3>
movsbl -0x5(%rbp),%eax
cmp    $0x62,%eax
jne    11c0 <spechar+0x80>
movb   $0x8,-0x5(%rbp)
jmp    11de <spechar+0x9e>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
jne    11d9 <spechar+0x99>
movl   $0x0,-0x4(%rbp)
jmp    132b <spechar+0x1eb>
jmp    11de <spechar+0x9e>
jmp    11e3 <spechar+0xa3>
jmp    11e8 <spechar+0xa8>
jmp    11ed <spechar+0xad>
jmp    11f2 <spechar+0xb2>
mov    $0x0,%al
call   1060 <gch@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x78,%eax
jne    129a <spechar+0x15a>
mov    $0x0,%al
call   1030 <ch@plt>
movsbl %al,%edi
call   1040 <hexdigit@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x7f,%eax
jne    123d <spechar+0xfd>
lea    0xdd4(%rip),%rdi
call   1050 <error@plt>
movl   $0x3f,-0x4(%rbp)
jmp    132b <spechar+0x1eb>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <gch@plt>
mov    $0x0,%al
call   1030 <ch@plt>
movsbl %al,%edi
call   1040 <hexdigit@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x7f,%eax
jne    1275 <spechar+0x135>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    132b <spechar+0x1eb>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <gch@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    132b <spechar+0x1eb>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jne    1324 <spechar+0x1e4>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    1319 <spechar+0x1d9>
mov    $0x0,%al
call   1030 <ch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     12e3 <spechar+0x1a3>
movsbl -0x5(%rbp),%eax
cmp    $0x37,%eax
jle    12ee <spechar+0x1ae>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    132b <spechar+0x1eb>
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <gch@plt>
jmp    12b5 <spechar+0x175>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    132b <spechar+0x1eb>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spechar>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%ebx
lea    -0x62(%rbx),%eax
cmp    $0x12,%al
ja     1177 <spechar+0x37>
mov    $0xa,%ebp
movzbl %al,%eax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x8,%ebp
jmp    1206 <spechar+0xc6>
test   %bl,%bl
je     120d <spechar+0xcd>
xor    %eax,%eax
call   1060 <gch@plt>
cmp    $0x78,%bl
je     1216 <spechar+0xd6>
cmp    $0x30,%bl
jne    123c <spechar+0xfc>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
lea    -0x38(%rax),%ecx
cmp    $0xf8,%cl
jb     120d <spechar+0xcd>
movzbl %al,%ebp
add    $0xffffffd0,%ebp
xor    %eax,%eax
call   1060 <gch@plt>
xor    %eax,%eax
call   1030 <ch@plt>
lea    -0x38(%rax),%ecx
cmp    $0xf8,%cl
jb     120d <spechar+0xcd>
mov    %ebp,%ecx
movzbl %al,%ebp
shl    $0x3,%ecx
add    $0xffffffd0,%ebp
or     %ecx,%ebp
xor    %eax,%eax
call   1060 <gch@plt>
xor    %eax,%eax
call   1030 <ch@plt>
lea    -0x38(%rax),%ecx
cmp    $0xf8,%cl
jb     120d <spechar+0xcd>
movzbl %al,%eax
shl    $0x3,%ebp
add    $0xffffffd0,%eax
jmp    1264 <spechar+0x124>
mov    $0xc,%ebp
jmp    1206 <spechar+0xc6>
mov    $0xd,%ebp
jmp    1206 <spechar+0xc6>
mov    $0x9,%ebp
xor    %eax,%eax
call   1060 <gch@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1030 <ch@plt>
movsbl %al,%edi
call   1040 <hexdigit@plt>
cmp    $0x7f,%al
jne    1241 <spechar+0x101>
lea    0xe1c(%rip),%rdi
call   1050 <error@plt>
mov    $0x3f,%ebp
jmp    120d <spechar+0xcd>
movsbl %bl,%ebp
jmp    120d <spechar+0xcd>
movsbl %al,%ebp
xor    %eax,%eax
call   1060 <gch@plt>
xor    %eax,%eax
call   1030 <ch@plt>
movsbl %al,%edi
call   1040 <hexdigit@plt>
cmp    $0x7f,%al
je     120d <spechar+0xcd>
movsbl %al,%eax
shl    $0x4,%ebp
or     %eax,%ebp
jmp    1206 <spechar+0xc6>

LLVM IR (-O0):
@.str = [11 x i8] c"bad escape\00"
define i32 @spechar() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = call signext i8 (...) @ch()
store i8 %5, i8* %2
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 110
br i1 %8, label %9, label %10
9: ; preds = %0
store i8 10, i8* %2
br label %40
10: ; preds = %0
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 116
br i1 %13, label %14, label %15
14: ; preds = %10
store i8 9, i8* %2
br label %39
15: ; preds = %10
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 114
br i1 %18, label %19, label %20
19: ; preds = %15
store i8 13, i8* %2
br label %38
20: ; preds = %15
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 102
br i1 %23, label %24, label %25
24: ; preds = %20
store i8 12, i8* %2
br label %37
25: ; preds = %20
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 98
br i1 %28, label %29, label %30
29: ; preds = %25
store i8 8, i8* %2
br label %36
30: ; preds = %25
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 0, i32* %1
br label %108
35: ; preds = %30
br label %36
36: ; preds = %35, %29
br label %37
37: ; preds = %36, %24
br label %38
38: ; preds = %37, %19
br label %39
39: ; preds = %38, %14
br label %40
40: ; preds = %39, %9
%41 = call i32 (...) @gch()
%42 = load i8, i8* %2
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 120
br i1 %44, label %45, label %73
45: ; preds = %40
%46 = call signext i8 (...) @ch()
%47 = call signext i8 @hexdigit(i8 signext %46)
store i8 %47, i8* %2
%48 = load i8, i8* %2
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 127
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = call i32 @error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 63, i32* %1
br label %108
53: ; preds = %45
%54 = load i8, i8* %2
%55 = sext i8 %54 to i32
store i32 %55, i32* %3
%56 = call i32 (...) @gch()
%57 = call signext i8 (...) @ch()
%58 = call signext i8 @hexdigit(i8 signext %57)
store i8 %58, i8* %2
%59 = load i8, i8* %2
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 127
br i1 %61, label %62, label %64
62: ; preds = %53
%63 = load i32, i32* %3
store i32 %63, i32* %1
br label %108
64: ; preds = %53
%65 = load i32, i32* %3
%66 = shl i32 %65, 4
store i32 %66, i32* %3
%67 = load i8, i8* %2
%68 = sext i8 %67 to i32
%69 = load i32, i32* %3
%70 = or i32 %69, %68
store i32 %70, i32* %3
%71 = call i32 (...) @gch()
%72 = load i32, i32* %3
store i32 %72, i32* %1
br label %108
73: ; preds = %40
%74 = load i8, i8* %2
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 48
br i1 %76, label %77, label %105
77: ; preds = %73
store i32 0, i32* %4
store i32 0, i32* %3
br label %78
78: ; preds = %92, %77
%79 = load i32, i32* %4
%80 = icmp slt i32 %79, 3
br i1 %80, label %81, label %103
81: ; preds = %78
%82 = call signext i8 (...) @ch()
store i8 %82, i8* %2
%83 = load i8, i8* %2
%84 = sext i8 %83 to i32
%85 = icmp slt i32 %84, 48
br i1 %85, label %90, label %86
86: ; preds = %81
%87 = load i8, i8* %2
%88 = sext i8 %87 to i32
%89 = icmp sgt i32 %88, 55
br i1 %89, label %90, label %92
90: ; preds = %86, %81
%91 = load i32, i32* %3
store i32 %91, i32* %1
br label %108
92: ; preds = %86
%93 = load i32, i32* %3
%94 = shl i32 %93, 3
store i32 %94, i32* %3
%95 = load i8, i8* %2
%96 = sext i8 %95 to i32
%97 = sub nsw i32 %96, 48
%98 = load i32, i32* %3
%99 = or i32 %98, %97
store i32 %99, i32* %3
%100 = load i32, i32* %4
%101 = add nsw i32 %100, 1
store i32 %101, i32* %4
%102 = call i32 (...) @gch()
br label %78
103: ; preds = %78
%104 = load i32, i32* %3
store i32 %104, i32* %1
br label %108
105: ; preds = %73
%106 = load i8, i8* %2
%107 = sext i8 %106 to i32
store i32 %107, i32* %1
br label %108
108: ; preds = %105, %103, %90, %64, %62, %51, %34
%109 = load i32, i32* %1
ret i32 %109
}

LLVM IR (-O2):
@.str = [11 x i8] c"bad escape\00"
define i32 @spechar() {
%1 = tail call signext i8 (...) @ch()
switch i8 %1, label %9 [
i8 110, label %6
i8 116, label %2
i8 114, label %3
i8 102, label %4
i8 98, label %5
i8 0, label %55
]
2: ; preds = %0
br label %6
3: ; preds = %0
br label %6
4: ; preds = %0
br label %6
5: ; preds = %0
br label %6
6: ; preds = %2, %3, %4, %5, %0
%7 = phi i32 [ 10, %0 ], [ 8, %5 ], [ 12, %4 ], [ 13, %3 ], [ 9, %2 ]
%8 = tail call i32 (...) @gch()
br label %55
9: ; preds = %0
%10 = tail call i32 (...) @gch()
%11 = sext i8 %1 to i32
switch i8 %1, label %55 [
i8 120, label %16
i8 48, label %12
]
12: ; preds = %9
%13 = tail call signext i8 (...) @ch()
%14 = add i8 %13, -56
%15 = icmp ult i8 %14, -8
br i1 %15, label %55, label %33
16: ; preds = %9
%17 = tail call signext i8 (...) @ch()
%18 = tail call signext i8 @hexdigit(i8 signext %17)
%19 = sext i8 %18 to i32
%20 = icmp eq i8 %18, 127
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = tail call i32 @error(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %55
23: ; preds = %16
%24 = tail call i32 (...) @gch()
%25 = tail call signext i8 (...) @ch()
%26 = tail call signext i8 @hexdigit(i8 signext %25)
%27 = icmp eq i8 %26, 127
br i1 %27, label %55, label %28
28: ; preds = %23
%29 = sext i8 %26 to i32
%30 = shl nsw i32 %19, 4
%31 = or i32 %30, %29
%32 = tail call i32 (...) @gch()
br label %55
33: ; preds = %12
%34 = zext i8 %13 to i32
%35 = add nsw i32 %34, -48
%36 = tail call i32 (...) @gch()
%37 = tail call signext i8 (...) @ch()
%38 = add i8 %37, -56
%39 = icmp ult i8 %38, -8
br i1 %39, label %55, label %40
40: ; preds = %33
%41 = zext i8 %37 to i32
%42 = shl nuw nsw i32 %35, 3
%43 = add nsw i32 %41, -48
%44 = or i32 %43, %42
%45 = tail call i32 (...) @gch()
%46 = tail call signext i8 (...) @ch()
%47 = add i8 %46, -56
%48 = icmp ult i8 %47, -8
br i1 %48, label %55, label %49
49: ; preds = %40
%50 = zext i8 %46 to i32
%51 = shl nsw i32 %44, 3
%52 = add nsw i32 %50, -48
%53 = or i32 %52, %51
%54 = tail call i32 (...) @gch()
br label %55
55: ; preds = %12, %33, %40, %49, %6, %9, %23, %0, %28, %21
%56 = phi i32 [ 63, %21 ], [ %31, %28 ], [ 0, %0 ], [ %19, %23 ], [ %11, %9 ], [ %7, %6 ], [ 0, %12 ], [ %35, %33 ], [ %44, %40 ], [ %53, %49 ]
ret i32 %56
}