#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*/ scanf(char *, char *);
int le_caracter(void) {
  char prim, seg, ter;
  scanf("%c", &prim);
  if (prim != 27)
    return prim;
  scanf("%c", &seg);
  if (seg == 27) {
    return 27;
  }
  if (seg != '[')
    return 261;
  scanf("%c", &ter);
  switch (ter) {
  case 'A':
    return 256;
  case 'B':
    return 257;
  case 'C':
    return 259;
  case 'D':
    return 258;
  case '3':
    return 260;
  default:
    return 261;
  }
}


x86 assembly (clang, -O0):
<le_caracter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf29(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1030 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x1b,%eax
je     1141 <le_caracter+0x31>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
lea    0xf00(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1030 <scanf@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x1b,%eax
jne    116a <le_caracter+0x5a>
movl   $0x1b,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
movsbl -0x6(%rbp),%eax
cmp    $0x5b,%eax
je     1183 <le_caracter+0x73>
movl   $0x105,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
lea    0xebe(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1030 <scanf@plt>
movsbl -0x7(%rbp),%eax
add    $0xffffffcd,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x11,%eax
ja     11f9 <le_caracter+0xe9>
mov    -0x10(%rbp),%rax
lea    0xe4c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x100,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
movl   $0x101,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
movl   $0x103,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
movl   $0x102,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
movl   $0x104,-0x4(%rbp)
jmp    1200 <le_caracter+0xf0>
movl   $0x105,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<le_caracter>:
push   %rax
lea    0xf30(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1030 <scanf@plt>
movsbl 0x7(%rsp),%eax
cmp    $0x1b,%eax
jne    1188 <le_caracter+0x78>
lea    0xf15(%rip),%rdi
lea    0x6(%rsp),%rsi
call   1030 <scanf@plt>
mov    0x6(%rsp),%al
cmp    $0x1b,%al
je     118a <le_caracter+0x7a>
cmp    $0x5b,%al
jne    1183 <le_caracter+0x73>
lea    0xef8(%rip),%rdi
lea    0x5(%rsp),%rsi
call   1030 <scanf@plt>
movsbl 0x5(%rsp),%ecx
add    $0xffffffcd,%ecx
cmp    $0x11,%ecx
ja     1183 <le_caracter+0x73>
mov    $0x100,%eax
lea    0xe8d(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x104,%eax
pop    %rcx
ret
mov    $0x105,%eax
pop    %rcx
ret
mov    $0x1b,%eax
pop    %rcx
ret
mov    $0x101,%eax
pop    %rcx
ret
mov    $0x103,%eax
pop    %rcx
ret
mov    $0x102,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define i32 @le_caracter() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 27
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
store i32 %11, i32* %1
br label %33
12: ; preds = %0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 27
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 27, i32* %1
br label %33
18: ; preds = %12
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 91
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 261, i32* %1
br label %33
23: ; preds = %18
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
switch i32 %26, label %32 [
i32 65, label %27
i32 66, label %28
i32 67, label %29
i32 68, label %30
i32 51, label %31
]
27: ; preds = %23
store i32 256, i32* %1
br label %33
28: ; preds = %23
store i32 257, i32* %1
br label %33
29: ; preds = %23
store i32 259, i32* %1
br label %33
30: ; preds = %23
store i32 258, i32* %1
br label %33
31: ; preds = %23
store i32 260, i32* %1
br label %33
32: ; preds = %23
store i32 261, i32* %1
br label %33
33: ; preds = %32, %31, %30, %29, %28, %27, %22, %17, %9
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @le_caracter() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 27
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = sext i8 %5 to i32
br label %22
9: ; preds = %0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = load i8, i8* %2
switch i8 %11, label %12 [
i8 27, label %22
i8 91, label %13
]
12: ; preds = %9
br label %22
13: ; preds = %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
switch i32 %16, label %21 [
i32 65, label %22
i32 66, label %17
i32 67, label %18
i32 68, label %19
i32 51, label %20
]
17: ; preds = %13
br label %22
18: ; preds = %13
br label %22
19: ; preds = %13
br label %22
20: ; preds = %13
br label %22
21: ; preds = %13
br label %22
22: ; preds = %13, %9, %21, %20, %19, %18, %17, %12, %7
%23 = phi i32 [ %8, %7 ], [ 261, %12 ], [ 261, %21 ], [ 260, %20 ], [ 258, %19 ], [ 259, %18 ], [ 257, %17 ], [ 27, %9 ], [ 256, %13 ]
ret i32 %23
}