#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int fescape(FILE *f) {
  int n, k, c = fgetc(f);
  switch (c) {
  case 'n':
    return '\n';
  case 'b':
    return '\b';
  case 't':
    return '\t';
  case 'r':
    return '\r';
  }
  if (c < '0' || c > '7')
    return c;
  n = c - '0';
  k = 2;
  while ((c = fgetc(f)) >= '0' && c <= '7') {
    n = n * 8 | c - '0';
    if (--k <= 0)
      return n;
  }
  if (c != EOF)
    ungetc(c, f);
  return n;
}


x86 assembly (clang, -O0):
<fescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x12,%eax
ja     1191 <fescape+0x71>
mov    -0x28(%rbp),%rax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x4(%rbp)
jmp    124d <fescape+0x12d>
movl   $0x8,-0x4(%rbp)
jmp    124d <fescape+0x12d>
movl   $0x9,-0x4(%rbp)
jmp    124d <fescape+0x12d>
movl   $0xd,-0x4(%rbp)
jmp    124d <fescape+0x12d>
cmpl   $0x30,-0x1c(%rbp)
jl     11a5 <fescape+0x85>
cmpl   $0x37,-0x1c(%rbp)
jle    11b0 <fescape+0x90>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124d <fescape+0x12d>
mov    -0x1c(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x29(%rbp)
jl     11e6 <fescape+0xc6>
cmpl   $0x37,-0x1c(%rbp)
setle  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11f6 <fescape+0xd6>
jmp    1229 <fescape+0x109>
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
mov    -0x1c(%rbp),%ecx
sub    $0x30,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jg     1224 <fescape+0x104>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124d <fescape+0x12d>
jmp    11c0 <fescape+0xa0>
mov    -0x1c(%rbp),%eax
mov    0x2db5(%rip),%rcx
cmp    (%rcx),%eax
je     1247 <fescape+0x127>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <ungetc@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fescape>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <fgetc@plt>
mov    %eax,%ebx
lea    -0x62(%rbx),%eax
ror    %eax
cmp    $0xa,%eax
jae    1142 <fescape+0x22>
mov    $0x341,%ecx
bt     %eax,%ecx
jb     11a0 <fescape+0x80>
lea    -0x38(%rbx),%eax
cmp    $0xfffffff8,%eax
jb     11ac <fescape+0x8c>
add    $0xffffffd0,%ebx
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cmp    $0x30,%ecx
jne    1189 <fescape+0x69>
mov    %ebx,%ecx
shl    $0x3,%ecx
add    $0xffffffd0,%eax
mov    %eax,%ebx
or     %ecx,%ebx
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cmp    $0x30,%ecx
jne    1189 <fescape+0x69>
shl    $0x3,%ebx
add    $0xffffffd0,%eax
or     %ebx,%eax
mov    %eax,%ebx
jmp    11ac <fescape+0x8c>
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
je     11ac <fescape+0x8c>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <ungetc@plt>
jmp    11ac <fescape+0x8c>
cltq
lea    0xe57(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fescape(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = call i32 @fgetc(i32* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
switch i32 %9, label %14 [
i32 110, label %10
i32 98, label %11
i32 116, label %12
i32 114, label %13
]
10: ; preds = %1
store i32 10, i32* %2
br label %56
11: ; preds = %1
store i32 8, i32* %2
br label %56
12: ; preds = %1
store i32 9, i32* %2
br label %56
13: ; preds = %1
store i32 13, i32* %2
br label %56
14: ; preds = %1
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 48
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 55
br i1 %19, label %20, label %22
20: ; preds = %17, %14
%21 = load i32, i32* %6
store i32 %21, i32* %2
br label %56
22: ; preds = %17
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 48
store i32 %24, i32* %4
store i32 2, i32* %5
br label %25
25: ; preds = %45, %22
%26 = load i32*, i32** %3
%27 = call i32 @fgetc(i32* %26)
store i32 %27, i32* %6
%28 = icmp sge i32 %27, 48
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %6
%31 = icmp sle i32 %30, 55
br label %32
32: ; preds = %29, %25
%33 = phi i1 [ false, %25 ], [ %31, %29 ]
br i1 %33, label %34, label %46
34: ; preds = %32
%35 = load i32, i32* %4
%36 = mul nsw i32 %35, 8
%37 = load i32, i32* %6
%38 = sub nsw i32 %37, 48
%39 = or i32 %36, %38
store i32 %39, i32* %4
%40 = load i32, i32* %5
%41 = add nsw i32 %40, -1
store i32 %41, i32* %5
%42 = icmp sle i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %34
%44 = load i32, i32* %4
store i32 %44, i32* %2
br label %56
45: ; preds = %34
br label %25
46: ; preds = %32
%47 = load i32, i32* %6
%48 = load i32, i32* @EOF
%49 = icmp ne i32 %47, %48
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i32, i32* %6
%52 = load i32*, i32** %3
%53 = call i32 @ungetc(i32 %51, i32* %52)
br label %54
54: ; preds = %50, %46
%55 = load i32, i32* %4
store i32 %55, i32* %2
br label %56
56: ; preds = %54, %43, %20, %13, %12, %11, %10
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
@EOF = global i32 0
@switch.table.fescape = [10 x i32] [i32 8, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 13, i32 9]
define i32 @fescape(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = add i32 %2, -98
%4 = tail call i32 @llvm.fshl.i32(i32 %3, i32 %3, i32 31)
%5 = icmp ult i32 %4, 10
br i1 %5, label %32, label %6
6: ; preds = %32, %1
%7 = add i32 %2, -56
%8 = icmp ult i32 %7, -8
br i1 %8, label %41, label %9
9: ; preds = %6
%10 = add nsw i32 %2, -48
%11 = tail call i32 @fgetc(i32* %0)
%12 = and i32 %11, -8
%13 = icmp eq i32 %12, 48
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = shl nuw nsw i32 %10, 3
%16 = add nsw i32 %11, -48
%17 = or i32 %16, %15
%18 = tail call i32 @fgetc(i32* %0)
%19 = and i32 %18, -8
%20 = icmp eq i32 %19, 48
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = shl nsw i32 %17, 3
%23 = add nsw i32 %18, -48
%24 = or i32 %23, %22
br label %41
25: ; preds = %14, %9
%26 = phi i32 [ %10, %9 ], [ %17, %14 ]
%27 = phi i32 [ %11, %9 ], [ %18, %14 ]
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %41, label %30
30: ; preds = %25
%31 = tail call i32 @ungetc(i32 %27, i32* %0)
br label %41
32: ; preds = %1
%33 = trunc i32 %4 to i16
%34 = lshr i16 833, %33
%35 = and i16 %34, 1
%36 = icmp eq i16 %35, 0
br i1 %36, label %6, label %37
37: ; preds = %32
%38 = sext i32 %4 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* @switch.table.fescape, i64 0, i64 %38
%40 = load i32, i32* %39
br label %41
41: ; preds = %37, %21, %25, %30, %6
%42 = phi i32 [ %2, %6 ], [ %26, %30 ], [ %26, %25 ], [ %24, %21 ], [ %40, %37 ]
ret i32 %42
}