#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 addition(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int sub(int, int);
int main() {
  int x;
  int y;
  int option;
  int total;
  printf("Your options");
  printf("\n* 1 = Addition;");
  printf("\n* 2 = Subtraction;");
  printf("\nPlease, select an option:");
  scanf("%d", &option);
  printf("Please, insert the primary number:");
  scanf("%d", &x);
  printf("\nPlease, insert the secundary number:");
  scanf("%d", &y);
  if (option == 1) {
    total = addition(x, y);
    printf("The addition is: %d\n", total);
  } else if (option == 2) {
    total = sub(x, y);
    printf("The sub is: %d\n", total);
  } else {
    printf("You selected the invalid option!");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x10(%rbp)
jne    1201 <main+0xc1>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <addition@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1242 <main+0x102>
cmpl   $0x2,-0x10(%rbp)
jne    122f <main+0xef>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <sub@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123d <main+0xfd>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1242 <main+0x102>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     11eb <main+0xab>
cmp    $0x1,%eax
jne    120a <main+0xca>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1030 <addition@plt>
lea    0xeb0(%rip),%rdi
jmp    11ff <main+0xbf>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1060 <sub@plt>
lea    0xeaf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1218 <main+0xd8>
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Your options\00"
@.str.1 = [17 x i8] c"\0A* 1 = Addition;\00"
@.str.2 = [20 x i8] c"\0A* 2 = Subtraction;\00"
@.str.3 = [27 x i8] c"\0APlease, select an option:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [35 x i8] c"Please, insert the primary number:\00"
@.str.6 = [38 x i8] c"\0APlease, insert the secundary number:\00"
@.str.7 = [21 x i8] c"The addition is: %d\0A\00"
@.str.8 = [16 x i8] c"The sub is: %d\0A\00"
@.str.9 = [33 x i8] c"You selected the invalid option!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %0
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @addition(i32 %18, i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %21)
br label %35
23: ; preds = %0
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = call i32 @sub(i32 %27, i32 %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %30)
br label %34
32: ; preds = %23
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %34
34: ; preds = %32, %26
br label %35
35: ; preds = %34, %17
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [13 x i8] c"Your options\00"
@.str.1 = [17 x i8] c"\0A* 1 = Addition;\00"
@.str.2 = [20 x i8] c"\0A* 2 = Subtraction;\00"
@.str.3 = [27 x i8] c"\0APlease, select an option:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [35 x i8] c"Please, insert the primary number:\00"
@.str.6 = [38 x i8] c"\0APlease, insert the secundary number:\00"
@.str.7 = [21 x i8] c"The addition is: %d\0A\00"
@.str.8 = [16 x i8] c"The sub is: %d\0A\00"
@.str.9 = [33 x i8] c"You selected the invalid option!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %3
switch i32 %16, label %27 [
i32 1, label %17
i32 2, label %22
]
17: ; preds = %0
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @addition(i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %20)
br label %29
22: ; preds = %0
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @sub(i32 %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %29
29: ; preds = %22, %27, %17
ret i32 0
}