#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 mult();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int soma();
int main() {
  int op = 0, result;
  do {
    printf("Informe a operacao desejada soma(1) ou produto (2):");
    scanf("%d", &op);
    if (op == 1)
      result = soma();
    else if (op == 2)
      result = mult();
    if (op != 0)
      printf("O resultado foi: %d", result);
  } while (op != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    118d <main+0x4d>
mov    $0x0,%al
call   1040 <soma@plt>
mov    %eax,-0xc(%rbp)
jmp    11a6 <main+0x66>
cmpl   $0x2,-0x8(%rbp)
jne    11a1 <main+0x61>
mov    $0x0,%al
call   1050 <mult@plt>
mov    %eax,-0xc(%rbp)
jmp    11a6 <main+0x66>
cmpl   $0x0,-0x8(%rbp)
je     11c1 <main+0x81>
mov    -0xc(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c6 <main+0x86>
cmpl   $0x0,-0x8(%rbp)
jne    1156 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea5(%rip),%r14
lea    0xee3(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xec6(%rip),%r12
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     11a0 <main+0x60>
cmp    $0x1,%eax
jne    11ad <main+0x6d>
xor    %eax,%eax
call   1040 <soma@plt>
jmp    11a7 <main+0x67>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <mult@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11c4 <main+0x84>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Informe a operacao desejada soma(1) ou produto (2):\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"O resultado foi: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %24, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 (...) @soma()
store i32 %10, i32* %3
br label %17
11: ; preds = %4
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (...) @mult()
store i32 %15, i32* %3
br label %16
16: ; preds = %14, %11
br label %17
17: ; preds = %16, %9
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %4, label %27
27: ; preds = %24
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [52 x i8] c"Informe a operacao desejada soma(1) ou produto (2):\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"O resultado foi: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %19, %0
%4 = phi i32 [ undef, %0 ], [ %17, %19 ]
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
switch i32 %7, label %15 [
i32 1, label %8
i32 2, label %10
]
8: ; preds = %3
%9 = call i32 (...) @soma()
br label %12
10: ; preds = %3
%11 = call i32 (...) @mult()
br label %12
12: ; preds = %8, %10
%13 = phi i32 [ %11, %10 ], [ %9, %8 ]
%14 = load i32, i32* %1
br label %15
15: ; preds = %12, %3
%16 = phi i32 [ %14, %12 ], [ %7, %3 ]
%17 = phi i32 [ %13, %12 ], [ %4, %3 ]
%18 = icmp eq i32 %16, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %3
23: ; preds = %15, %19
ret i32 0
}