#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 EOF;
int do_get_char();
int /*<<< orphan*/ isxdigit(int);
int strtol(char *, int /*<<< orphan*/, int);
int cgi_get_char(void) {
  int c = do_get_char();
  char bb[4];
  if (c == '&' || c == '=')
    return -c;
  if (c != '%' && c != '+')
    return c;
  if (c == '+')
    return ' ';
  c = do_get_char();
  if (c == EOF)
    return '?';
  if (!isxdigit(c))
    return '?';
  bb[0] = c;
  c = do_get_char();
  if (c == EOF)
    return '?';
  if (!isxdigit(c))
    return '?';
  bb[1] = c;
  bb[2] = 0;
  c = strtol(bb, 0, 16);
  return c;
}


x86 assembly (clang, -O0):
<cgi_get_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <do_get_char@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x26,-0x8(%rbp)
je     1156 <cgi_get_char+0x26>
cmpl   $0x3d,-0x8(%rbp)
jne    1163 <cgi_get_char+0x33>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
cmpl   $0x25,-0x8(%rbp)
je     1182 <cgi_get_char+0x52>
cmpl   $0x2b,-0x8(%rbp)
je     1182 <cgi_get_char+0x52>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
cmpl   $0x2b,-0x8(%rbp)
jne    1198 <cgi_get_char+0x68>
movl   $0x20,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
mov    $0x0,%al
call   1050 <do_get_char@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%eax
jne    11c0 <cgi_get_char+0x90>
movl   $0x3f,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
mov    -0x8(%rbp),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%eax
jne    11dd <cgi_get_char+0xad>
movl   $0x3f,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
mov    -0x8(%rbp),%eax
mov    %al,-0xc(%rbp)
mov    $0x0,%al
call   1050 <do_get_char@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%eax
jne    120b <cgi_get_char+0xdb>
movl   $0x3f,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
mov    -0x8(%rbp),%edi
call   1040 <isxdigit@plt>
cmp    $0x0,%eax
jne    1228 <cgi_get_char+0xf8>
movl   $0x3f,-0x4(%rbp)
jmp    124b <cgi_get_char+0x11b>
mov    -0x8(%rbp),%eax
mov    %al,-0xb(%rbp)
movb   $0x0,-0xa(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_get_char>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <do_get_char@plt>
mov    %eax,%ebx
lea    -0x25(%rbx),%eax
cmp    $0x18,%eax
ja     11c4 <cgi_get_char+0x94>
lea    0xeb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
neg    %ebx
jmp    11c4 <cgi_get_char+0x94>
xor    %eax,%eax
call   1050 <do_get_char@plt>
mov    0x2e7d(%rip),%r14
mov    $0x3f,%ebx
cmp    (%r14),%eax
je     11c4 <cgi_get_char+0x94>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     11c4 <cgi_get_char+0x94>
mov    %bpl,0xc(%rsp)
xor    %eax,%eax
call   1050 <do_get_char@plt>
cmp    (%r14),%eax
je     11c4 <cgi_get_char+0x94>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isxdigit@plt>
test   %eax,%eax
je     11c4 <cgi_get_char+0x94>
mov    %bpl,0xd(%rsp)
movb   $0x0,0xe(%rsp)
lea    0xc(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,%ebx
jmp    11c4 <cgi_get_char+0x94>
mov    $0x20,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @cgi_get_char() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i8]
%4 = call i32 (...) @do_get_char()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 38
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 61
br i1 %9, label %10, label %13
10: ; preds = %7, %0
%11 = load i32, i32* %2
%12 = sub nsw i32 0, %11
store i32 %12, i32* %1
br label %58
13: ; preds = %7
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 37
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 43
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* %2
store i32 %20, i32* %1
br label %58
21: ; preds = %16, %13
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 43
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 32, i32* %1
br label %58
25: ; preds = %21
%26 = call i32 (...) @do_get_char()
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 63, i32* %1
br label %58
31: ; preds = %25
%32 = load i32, i32* %2
%33 = call i32 @isxdigit(i32 %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %31
store i32 63, i32* %1
br label %58
36: ; preds = %31
%37 = load i32, i32* %2
%38 = trunc i32 %37 to i8
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 %38, i8* %39
%40 = call i32 (...) @do_get_char()
store i32 %40, i32* %2
%41 = load i32, i32* %2
%42 = load i32, i32* @EOF
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %45
44: ; preds = %36
store i32 63, i32* %1
br label %58
45: ; preds = %36
%46 = load i32, i32* %2
%47 = call i32 @isxdigit(i32 %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %45
store i32 63, i32* %1
br label %58
50: ; preds = %45
%51 = load i32, i32* %2
%52 = trunc i32 %51 to i8
%53 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %52, i8* %53
%54 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 0, i8* %54
%55 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%56 = call i32 @strtol(i8* %55, i32 0, i32 16)
store i32 %56, i32* %2
%57 = load i32, i32* %2
store i32 %57, i32* %1
br label %58
58: ; preds = %50, %49, %44, %35, %30, %24, %19, %10
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @cgi_get_char() {
%1 = alloca [4 x i8]
%2 = tail call i32 (...) @do_get_char()
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
switch i32 %2, label %27 [
i32 61, label %4
i32 38, label %4
i32 43, label %6
i32 37, label %7
]
4: ; preds = %0, %0
%5 = sub nsw i32 0, %2
br label %27
6: ; preds = %0
br label %27
7: ; preds = %0
%8 = tail call i32 (...) @do_get_char()
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %27, label %11
11: ; preds = %7
%12 = tail call i32 @isxdigit(i32 %8)
%13 = icmp eq i32 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %11
%15 = trunc i32 %8 to i8
store i8 %15, i8* %3
%16 = tail call i32 (...) @do_get_char()
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %27, label %19
19: ; preds = %14
%20 = tail call i32 @isxdigit(i32 %16)
%21 = icmp eq i32 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = trunc i32 %16 to i8
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 1
store i8 %23, i8* %24
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 2
store i8 0, i8* %25
%26 = call i32 @strtol(i8* %3, i32 0, i32 16)
br label %27
27: ; preds = %0, %19, %14, %11, %7, %22, %6, %4
%28 = phi i32 [ %5, %4 ], [ 32, %6 ], [ %26, %22 ], [ 63, %7 ], [ 63, %11 ], [ 63, %14 ], [ 63, %19 ], [ %2, %0 ]
ret i32 %28
}