#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*/ familia();
int /*<<< orphan*/ oi();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sair();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ tudo_bem();
int main(void) {
  int continuar = 1;
  int cont = 0;
  do {
    printf("\e[H\e[2J");
    printf("\n\tChat Forever Alone");
    if (cont == 0)
      printf(" (Estilo Victor)");
    printf("\n\n");
    printf("1. Oi\n");
    printf("2. Tudo bem?\n");
    printf("3. Como vai a familia?\n");
    printf("0. Sair\n");
    scanf("%d", &continuar);
    printf("\e[H\e[2J");
    switch (continuar) {
    case 1:
      oi();
      break;
    case 2:
      tudo_bem();
      break;
    case 3:
      familia();
      break;
    case 0:
      sair();
      break;
    default:
      printf("Digite uma opcao valida\n");
    }
    sleep(2);
    cont++;
  } while (continuar);
  printf("\e[H\e[2J");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11bb <main+0x4b>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     1268 <main+0xf8>
mov    -0x18(%rbp),%rax
lea    0xdd1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <oi@plt>
jmp    1274 <main+0x104>
mov    $0x0,%al
call   1050 <tudo_bem@plt>
jmp    1274 <main+0x104>
mov    $0x0,%al
call   1080 <familia@plt>
jmp    1274 <main+0x104>
mov    $0x0,%al
call   1060 <sair@plt>
jmp    1274 <main+0x104>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    118d <main+0x1d>
lea    0xd78(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xe86(%rip),%rbx
mov    %rbx,%rdi
call   1050 <printf@plt>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe51(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     1232 <main+0xb2>
lea    0xde0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <sair@plt>
jmp    1259 <main+0xd9>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
jmp    1259 <main+0xd9>
xor    %eax,%eax
call   1040 <oi@plt>
jmp    1259 <main+0xd9>
xor    %eax,%eax
call   1060 <tudo_bem@plt>
jmp    1259 <main+0xd9>
xor    %eax,%eax
call   1090 <familia@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
cmpl   $0x0,0x4(%rsp)
je     136d <main+0x1ed>
lea    0xdab(%rip),%rbx
lea    0xdea(%rip),%rbp
lea    0xdfa(%rip),%r14
lea    0xdc4(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xd7a(%rip),%r13
jmp    12c5 <main+0x145>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <sair@plt>
nopw   0x0(%rax,%rax,1)
mov    $0x2,%edi
call   10a0 <sleep@plt>
cmpl   $0x0,0x4(%rsp)
je     136d <main+0x1ed>
mov    %rbx,%rdi
call   1050 <printf@plt>
lea    0xd54(%rip),%rdi
call   1050 <printf@plt>
lea    0xd71(%rip),%rdi
call   1030 <puts@plt>
lea    0xd67(%rip),%rdi
call   1030 <puts@plt>
lea    0xd61(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     135c <main+0x1dc>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <oi@plt>
jmp    12b0 <main+0x130>
xor    %eax,%eax
call   1060 <tudo_bem@plt>
jmp    12b0 <main+0x130>
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <familia@plt>
jmp    12b0 <main+0x130>
lea    0xd22(%rip),%rdi
call   1030 <puts@plt>
jmp    12b0 <main+0x130>
lea    0xcac(%rip),%rdi
call   1050 <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 = [8 x i8] c"\1B[H\1B[2J\00"
@.str.1 = [21 x i8] c"\0A\09Chat Forever Alone\00"
@.str.2 = [17 x i8] c" (Estilo Victor)\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [7 x i8] c"1. Oi\0A\00"
@.str.5 = [14 x i8] c"2. Tudo bem?\0A\00"
@.str.6 = [24 x i8] c"3. Como vai a familia?\0A\00"
@.str.7 = [9 x i8] c"0. Sair\0A\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [25 x i8] c"Digite uma opcao valida\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %34, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %2
switch i32 %19, label %28 [
i32 1, label %20
i32 2, label %22
i32 3, label %24
i32 0, label %26
]
20: ; preds = %11
%21 = call i32 (...) @oi()
br label %30
22: ; preds = %11
%23 = call i32 (...) @tudo_bem()
br label %30
24: ; preds = %11
%25 = call i32 (...) @familia()
br label %30
26: ; preds = %11
%27 = call i32 (...) @sair()
br label %30
28: ; preds = %11
%29 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
br label %30
30: ; preds = %28, %26, %24, %22, %20
%31 = call i32 @sleep(i32 2)
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %34
34: ; preds = %30
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 0
br i1 %36, label %4, label %37
37: ; preds = %34
%38 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[H\1B[2J\00"
@.str.1 = [21 x i8] c"\0A\09Chat Forever Alone\00"
@.str.2 = [17 x i8] c" (Estilo Victor)\00"
@.str.8 = [3 x i8] c"%d\00"
@str = [2 x i8] c"\0A\00"
@str.10 = [6 x i8] c"1. Oi\00"
@str.11 = [13 x i8] c"2. Tudo bem?\00"
@str.12 = [23 x i8] c"3. Como vai a familia?\00"
@str.13 = [8 x i8] c"0. Sair\00"
@str.14 = [24 x i8] c"Digite uma opcao valida\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %1
switch i32 %13, label %22 [
i32 1, label %20
i32 2, label %18
i32 3, label %16
i32 0, label %14
]
14: ; preds = %0
%15 = call i32 (...) @sair()
br label %24
16: ; preds = %0
%17 = call i32 (...) @familia()
br label %24
18: ; preds = %0
%19 = call i32 (...) @tudo_bem()
br label %24
20: ; preds = %0
%21 = call i32 (...) @oi()
br label %24
22: ; preds = %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16, %14
%25 = call i32 @sleep(i32 2)
%26 = load i32, i32* %1
%27 = icmp eq i32 %26, 0
br i1 %27, label %53, label %28
28: ; preds = %24, %49
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0))
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0))
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* %1
switch i32 %38, label %47 [
i32 1, label %39
i32 2, label %41
i32 3, label %43
i32 0, label %45
]
39: ; preds = %28
%40 = call i32 (...) @oi()
br label %49
41: ; preds = %28
%42 = call i32 (...) @tudo_bem()
br label %49
43: ; preds = %28
%44 = call i32 (...) @familia()
br label %49
45: ; preds = %28
%46 = call i32 (...) @sair()
br label %49
47: ; preds = %28
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
br label %49
49: ; preds = %47, %45, %43, %41, %39
%50 = call i32 @sleep(i32 2)
%51 = load i32, i32* %1
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %28
53: ; preds = %49, %24
%54 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i32 0
}