#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 */
struct no {
  int dummy;
};

/* Variables and functions */
struct no *incluir(struct no *, int);
int /*<<< orphan*/ percorrer_nos(struct no *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
struct no *remover(struct no *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int opcao_menu, valor_entrada;
  struct no *raiz;
  raiz = NULL;
  do {
    printf("0- Sair\n");
    printf("1- Incluir\n");
    printf("2- Remover\n");
    printf("-----\n");
    percorrer_nos(raiz, 0);
    printf("\n\n-----\n");
    printf("Opcao: ");
    scanf("%d", &opcao_menu);
    if (opcao_menu == 1) {
      printf("Valor = ");
      scanf("%d", &valor_entrada);
      raiz = incluir(raiz, valor_entrada);
    }
    if (opcao_menu == 2) {
      printf("Valor = ");
      scanf("%d", &valor_entrada);
      raiz = remover(raiz, valor_entrada);
    }
    printf("\n");
  } while (opcao_menu);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe92(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <percorrer_nos@plt>
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
lea    0xe71(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1200 <main+0xb0>
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <incluir@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1236 <main+0xe6>
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
lea    0xe15(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <remover@plt>
mov    %rax,-0x18(%rbp)
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1167 <main+0x17>
mov    $0x1,%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
xor    %r15d,%r15d
lea    0xe7b(%rip),%rbp
lea    0xe7c(%rip),%r14
mov    %rsp,%r12
lea    0xe75(%rip),%r13
lea    0x4(%rsp),%rbx
jmp    11b4 <main+0x44>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%rsp)
je     126a <main+0xfa>
lea    0xe59(%rip),%rdi
call   1050 <puts@plt>
lea    0xe55(%rip),%rdi
call   1050 <puts@plt>
lea    0xe54(%rip),%rdi
call   1050 <puts@plt>
lea    0xe55(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <percorrer_nos@plt>
lea    0xe3d(%rip),%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1090 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x1,%eax
jne    123a <main+0xca>
mov    %r13,%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   1080 <incluir@plt>
mov    %rax,%r15
mov    (%rsp),%eax
cmp    $0x2,%eax
jne    11a0 <main+0x30>
mov    %r13,%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   1060 <remover@plt>
mov    %rax,%r15
jmp    11a0 <main+0x30>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.no = type { i32 }
@.str = [9 x i8] c"0- Sair\0A\00"
@.str.1 = [12 x i8] c"1- Incluir\0A\00"
@.str.2 = [12 x i8] c"2- Remover\0A\00"
@.str.3 = [7 x i8] c"-----\0A\00"
@.str.4 = [9 x i8] c"\0A\0A-----\0A\00"
@.str.5 = [8 x i8] c"Opcao: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [9 x i8] c"Valor = \00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.no*
store i32 0, i32* %1
store %struct.no* null, %struct.no** %4
br label %5
5: ; preds = %34, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = load %struct.no*, %struct.no** %4
%11 = call i32 @percorrer_nos(%struct.no* %10, i32 0)
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %5
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%20 = load %struct.no*, %struct.no** %4
%21 = load i32, i32* %3
%22 = call %struct.no* @incluir(%struct.no* %20, i32 %21)
store %struct.no* %22, %struct.no** %4
br label %23
23: ; preds = %17, %5
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%29 = load %struct.no*, %struct.no** %4
%30 = load i32, i32* %3
%31 = call %struct.no* @remover(%struct.no* %29, i32 %30)
store %struct.no* %31, %struct.no** %4
br label %32
32: ; preds = %26, %23
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 0
br i1 %36, label %5, label %37
37: ; preds = %34
ret i32 1
}

LLVM IR (-O2):
%struct.no = type { i32 }
@.str.5 = [8 x i8] c"Opcao: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [9 x i8] c"Valor = \00"
@str = [8 x i8] c"0- Sair\00"
@str.9 = [11 x i8] c"1- Incluir\00"
@str.10 = [11 x i8] c"2- Remover\00"
@str.11 = [6 x i8] c"-----\00"
@str.12 = [8 x i8] c"\0A\0A-----\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %32, %0
%6 = phi %struct.no* [ null, %0 ], [ %33, %32 ]
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @percorrer_nos(%struct.no* %6, i32 0)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %5
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = call %struct.no* @incluir(%struct.no* %6, i32 %20)
%22 = load i32, i32* %1
br label %23
23: ; preds = %17, %5
%24 = phi i32 [ %22, %17 ], [ %15, %5 ]
%25 = phi %struct.no* [ %21, %17 ], [ %6, %5 ]
%26 = icmp eq i32 %24, 2
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%30 = load i32, i32* %2
%31 = call %struct.no* @remover(%struct.no* %25, i32 %30)
br label %32
32: ; preds = %27, %23
%33 = phi %struct.no* [ %31, %27 ], [ %25, %23 ]
%34 = call i32 @putchar(i32 10)
%35 = load i32, i32* %1
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %5
37: ; preds = %32
ret i32 1
}