#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 /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
char string_to_char(char *s) {
  unsigned int c;
  if (s[0] == '\\') {
    switch (s[1]) {
    case 'n':
      return '\n';
    case 'f':
      return '\f';
    case 'r':
      return '\r';
    case 't':
      return '\t';
    case 'v':
      return '\v';
    case 'x':
      sscanf(s + 2, "%x", &c);
      return (char)c;
    default:
      return s[1];
    }
  } else {
    return s[0];
  }
}


x86 assembly (clang, -O0):
<string_to_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11b9 <string_to_char+0xa9>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
add    $0xffffff9a,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x12,%eax
ja     11aa <string_to_char+0x9a>
mov    -0x20(%rbp),%rax
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0xa,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
movb   $0xc,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
movb   $0xd,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
movb   $0x9,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
movb   $0xb,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    0xeb6(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x14(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x1(%rbp)
jmp    11c2 <string_to_char+0xb2>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_to_char>:
push   %rax
mov    (%rdi),%al
cmp    $0x5c,%al
jne    113d <string_to_char+0x2d>
movsbl 0x1(%rdi),%ecx
lea    -0x66(%rcx),%edx
ror    %edx
cmp    $0x9,%edx
ja     113b <string_to_char+0x2b>
mov    $0xa,%al
lea    0xed2(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0xc,%al
pop    %rcx
ret
mov    %ecx,%eax
pop    %rcx
ret
mov    $0xd,%al
pop    %rcx
ret
mov    $0x9,%al
pop    %rcx
ret
mov    $0xb,%al
pop    %rcx
ret
add    $0x2,%rdi
lea    0xed2(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%x\00"
define signext i8 @string_to_char(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 92
br i1 %9, label %10, label %30
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %26 [
i32 110, label %15
i32 102, label %16
i32 114, label %17
i32 116, label %18
i32 118, label %19
i32 120, label %20
]
15: ; preds = %10
store i8 10, i8* %2
br label %34
16: ; preds = %10
store i8 12, i8* %2
br label %34
17: ; preds = %10
store i8 13, i8* %2
br label %34
18: ; preds = %10
store i8 9, i8* %2
br label %34
19: ; preds = %10
store i8 11, i8* %2
br label %34
20: ; preds = %10
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 2
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = trunc i32 %24 to i8
store i8 %25, i8* %2
br label %34
26: ; preds = %10
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
store i8 %29, i8* %2
br label %34
30: ; preds = %1
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
store i8 %33, i8* %2
br label %34
34: ; preds = %30, %26, %20, %19, %18, %17, %16, %15
%35 = load i8, i8* %2
ret i8 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
define signext i8 @string_to_char(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 92
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = add nsw i32 %9, -102
%11 = tail call i32 @llvm.fshl.i32(i32 %10, i32 %10, i32 31)
switch i32 %11, label %21 [
i32 4, label %22
i32 0, label %12
i32 6, label %13
i32 7, label %14
i32 8, label %15
i32 9, label %16
]
12: ; preds = %6
br label %22
13: ; preds = %6
br label %22
14: ; preds = %6
br label %22
15: ; preds = %6
br label %22
16: ; preds = %6
%17 = getelementptr inbounds i8, i8* %0, i64 2
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
%20 = trunc i32 %19 to i8
br label %22
21: ; preds = %6
br label %22
22: ; preds = %1, %6, %21, %16, %15, %14, %13, %12
%23 = phi i8 [ %8, %21 ], [ %20, %16 ], [ 11, %15 ], [ 9, %14 ], [ 13, %13 ], [ 12, %12 ], [ 10, %6 ], [ %4, %1 ]
ret i8 %23
}