#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char op = ' ';
  char letra = ' ';
  do {
    printf("\n0) Sair            \n1) Digite uma letra            \n2) Mostre "
           "a letra            \nOp: ");
    scanf(" %c", &op);
    switch (op) {
    case '0':
      break;
    case '1':
      printf("\nLetra: ");
      scanf(" %c", &letra);
      break;
    case '2':
      printf("\nLetra digitada: %c", letra);
      break;
    default:
      printf("\nOpcao invalida.");
    }
  } while (op != '0');
  printf("fim");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x20,-0x5(%rbp)
movb   $0x20,-0x6(%rbp)
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf25(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x30,%eax
je     118c <main+0x6c>
jmp    116a <main+0x4a>
mov    -0xc(%rbp),%eax
sub    $0x31,%eax
je     1191 <main+0x71>
jmp    117b <main+0x5b>
mov    -0xc(%rbp),%eax
sub    $0x32,%eax
je     11b4 <main+0x94>
jmp    11cb <main+0xab>
jmp    11d9 <main+0xb9>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x6(%rbp),%rsi
call   1040 <scanf@plt>
jmp    11d9 <main+0xb9>
movsbl -0x6(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xb9>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0xbe>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jne    1137 <main+0x17>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x20,0x6(%rsp)
movb   $0x20,0x7(%rsp)
lea    0xec4(%rip),%r14
lea    0xf2e(%rip),%rbx
lea    0x6(%rsp),%r15
lea    0xf12(%rip),%r12
lea    0x7(%rsp),%rbp
lea    0xf1a(%rip),%r13
jmp    1179 <main+0x59>
nopl   (%rax)
movsbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x6(%rsp),%ecx
cmp    $0x30,%cl
je     11cc <main+0xac>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movzbl 0x6(%rsp),%ecx
movsbl %cl,%eax
cmp    $0x30,%eax
je     1174 <main+0x54>
cmp    $0x32,%eax
je     1160 <main+0x40>
cmp    $0x31,%eax
jne    11c0 <main+0xa0>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
jmp    116f <main+0x4f>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    116f <main+0x4f>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [88 x i8] c"\0A0) Sair \0A1) Digite uma letra \0A2) Mostre a letra \0AOp: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [9 x i8] c"\0ALetra: \00"
@.str.3 = [20 x i8] c"\0ALetra digitada: %c\00"
@.str.4 = [17 x i8] c"\0AOpcao invalida.\00"
@.str.5 = [4 x i8] c"fim\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
store i32 0, i32* %1
store i8 32, i8* %2
store i8 32, i8* %3
br label %4
4: ; preds = %20, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
switch i32 %8, label %17 [
i32 48, label %9
i32 49, label %10
i32 50, label %13
]
9: ; preds = %4
br label %19
10: ; preds = %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %19
13: ; preds = %4
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %19
17: ; preds = %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %17, %13, %10, %9
br label %20
20: ; preds = %19
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 48
br i1 %23, label %4, label %24
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [88 x i8] c"\0A0) Sair \0A1) Digite uma letra \0A2) Mostre a letra \0AOp: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [9 x i8] c"\0ALetra: \00"
@.str.3 = [20 x i8] c"\0ALetra digitada: %c\00"
@.str.4 = [17 x i8] c"\0AOpcao invalida.\00"
@.str.5 = [4 x i8] c"fim\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
store i8 32, i8* %1
store i8 32, i8* %2
br label %3
3: ; preds = %19, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = load i8, i8* %1
%7 = sext i8 %6 to i32
switch i32 %7, label %15 [
i32 48, label %19
i32 49, label %8
i32 50, label %11
]
8: ; preds = %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %17
11: ; preds = %3
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %17
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %15, %11, %8
%18 = load i8, i8* %1
br label %19
19: ; preds = %17, %3
%20 = phi i8 [ %18, %17 ], [ %6, %3 ]
%21 = icmp eq i8 %20, 48
br i1 %21, label %22, label %3
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}