#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 */
int getchar();
int strchar(int delim) {
  int c;
  c = getchar();
  if (delim && c == delim)
    return 0400;
  if (c != '\\')
    return c;
  c = getchar();
  switch (c) {
  case 'b':
    c = '\b';
    break;
  case 'n':
    c = '\n';
    break;
  case 'r':
    c = '\r';
    break;
  case '\\':
    c = '\\';
    break;
  case '0':
    c = 0;
    break;
  }
  return c;
}


x86 assembly (clang, -O0):
<strchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1147 <strchar+0x37>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1147 <strchar+0x37>
movl   $0x100,-0x4(%rbp)
jmp    11fb <strchar+0xeb>
cmpl   $0x5c,-0xc(%rbp)
je     115c <strchar+0x4c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fb <strchar+0xeb>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x30,%eax
je     11ee <strchar+0xde>
jmp    117a <strchar+0x6a>
mov    -0x10(%rbp),%eax
sub    $0x5c,%eax
je     11e2 <strchar+0xd2>
jmp    118b <strchar+0x7b>
mov    -0x10(%rbp),%eax
sub    $0x62,%eax
je     11be <strchar+0xae>
jmp    119c <strchar+0x8c>
mov    -0x10(%rbp),%eax
sub    $0x6e,%eax
je     11ca <strchar+0xba>
jmp    11ad <strchar+0x9d>
mov    -0x10(%rbp),%eax
sub    $0x72,%eax
je     11d6 <strchar+0xc6>
jmp    11f5 <strchar+0xe5>
movl   $0x8,-0xc(%rbp)
jmp    11f5 <strchar+0xe5>
movl   $0xa,-0xc(%rbp)
jmp    11f5 <strchar+0xe5>
movl   $0xd,-0xc(%rbp)
jmp    11f5 <strchar+0xe5>
movl   $0x5c,-0xc(%rbp)
jmp    11f5 <strchar+0xe5>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strchar>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
test   %ebx,%ebx
je     112b <strchar+0x1b>
mov    $0x100,%eax
cmp    %ebx,%ecx
jne    112b <strchar+0x1b>
pop    %rbx
ret
mov    %ecx,%eax
cmp    $0x5c,%ecx
jne    1129 <strchar+0x19>
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x5c(%rax),%ecx
cmp    $0x16,%ecx
ja     1158 <strchar+0x48>
lea    0xeb8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x5c,%eax
pop    %rbx
ret
cmp    $0x30,%eax
jne    1129 <strchar+0x19>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0xa,%eax
pop    %rbx
ret
mov    $0xd,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @strchar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = call i32 (...) @getchar()
store i32 %5, i32* %4
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 256, i32* %2
br label %28
13: ; preds = %8, %1
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 92
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i32, i32* %4
store i32 %17, i32* %2
br label %28
18: ; preds = %13
%19 = call i32 (...) @getchar()
store i32 %19, i32* %4
%20 = load i32, i32* %4
switch i32 %20, label %26 [
i32 98, label %21
i32 110, label %22
i32 114, label %23
i32 92, label %24
i32 48, label %25
]
21: ; preds = %18
store i32 8, i32* %4
br label %26
22: ; preds = %18
store i32 10, i32* %4
br label %26
23: ; preds = %18
store i32 13, i32* %4
br label %26
24: ; preds = %18
store i32 92, i32* %4
br label %26
25: ; preds = %18
store i32 0, i32* %4
br label %26
26: ; preds = %18, %25, %24, %23, %22, %21
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %28
28: ; preds = %26, %16, %12
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @strchar(i32 %0) {
%2 = tail call i32 (...) @getchar()
%3 = icmp ne i32 %0, 0
%4 = icmp eq i32 %2, %0
%5 = and i1 %3, %4
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = icmp eq i32 %2, 92
br i1 %7, label %8, label %15
8: ; preds = %6
%9 = tail call i32 (...) @getchar()
switch i32 %9, label %15 [
i32 98, label %10
i32 110, label %11
i32 114, label %12
i32 92, label %13
i32 48, label %14
]
10: ; preds = %8
br label %15
11: ; preds = %8
br label %15
12: ; preds = %8
br label %15
13: ; preds = %8
br label %15
14: ; preds = %8
br label %15
15: ; preds = %10, %11, %12, %13, %14, %8, %6, %1
%16 = phi i32 [ 256, %1 ], [ %2, %6 ], [ %9, %8 ], [ 0, %14 ], [ 92, %13 ], [ 13, %12 ], [ 10, %11 ], [ 8, %10 ]
ret i32 %16
}