#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*/ exit(int /*<<< orphan*/);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int a, b, sum, sq_sum, cu_sum, product, choice;
  printf("Enter two numbers: \n");
  scanf("%d %d", &a, &b);
  printf("\n---------------- MENU -------------- ");
  printf("\n\t 1. Summation \n\t 2. Sum of squares \n\t 3. Sum of cubes \n\t "
         "4. Product \n\t 5. Exit \n Your choice: ");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    sum = a + b;
    printf("\nThe sum is %d", sum);
    break;
  case 2:
    sq_sum = pow(a, 2) + pow(b, 2);
    printf("\nThe sum of squares is %d", sq_sum);
    break;
  case 3:
    cu_sum = pow(a, 3) + pow(b, 3);
    printf("\nThe sum of cubes is %d", cu_sum);
    break;
  case 4:
    product = a * b;
    printf("\nThe product is %d", product);
  case 5:
    exit(0);
  default:
    printf("\nWrong choice");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe8d(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     128c <main+0x14c>
mov    -0x28(%rbp),%rax
lea    0xe38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129a <main+0x15a>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129a <main+0x15a>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1050 <pow@plt>
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x3,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129a <main+0x15a>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xfa8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11d5 <main+0x85>
lea    0xe45(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x4(%rsp),%esi
add    0x8(%rsp),%esi
lea    0xecf(%rip),%rdi
jmp    1237 <main+0xe7>
lea    0xf1a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    123e <main+0xee>
mov    0x8(%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1060 <pow@plt>
add    %eax,%ebx
lea    0xea5(%rip),%rdi
jmp    1235 <main+0xe5>
mov    0x8(%rsp),%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    $0x3,%esi
call   1060 <pow@plt>
add    %eax,%ebx
lea    0xe96(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x4(%rsp),%esi
imul   0x8(%rsp),%esi
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Enter two numbers: \0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [39 x i8] c"\0A---------------- MENU -------------- \00"
@.str.3 = [97 x i8] c"\0A\09 1. Summation \0A\09 2. Sum of squares \0A\09 3. Sum of cubes \0A\09 4. Product \0A\09 5. Exit \0A Your choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [15 x i8] c"\0AThe sum is %d\00"
@.str.6 = [26 x i8] c"\0AThe sum of squares is %d\00"
@.str.7 = [24 x i8] c"\0AThe sum of cubes is %d\00"
@.str.8 = [19 x i8] c"\0AThe product is %d\00"
@.str.9 = [14 x i8] c"\0AWrong choice\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%14 = load i32, i32* %8
switch i32 %14, label %45 [
i32 1, label %15
i32 2, label %21
i32 3, label %29
i32 4, label %37
i32 5, label %43
]
15: ; preds = %0
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = add nsw i32 %16, %17
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %19)
br label %47
21: ; preds = %0
%22 = load i32, i32* %2
%23 = call i32 @pow(i32 %22, i32 2)
%24 = load i32, i32* %3
%25 = call i32 @pow(i32 %24, i32 2)
%26 = add nsw i32 %23, %25
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %27)
br label %47
29: ; preds = %0
%30 = load i32, i32* %2
%31 = call i32 @pow(i32 %30, i32 3)
%32 = load i32, i32* %3
%33 = call i32 @pow(i32 %32, i32 3)
%34 = add nsw i32 %31, %33
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %35)
br label %47
37: ; preds = %0
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = mul nsw i32 %38, %39
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %0, %37
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %47
47: ; preds = %45, %29, %21, %15
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [39 x i8] c"\0A---------------- MENU -------------- \00"
@.str.3 = [97 x i8] c"\0A\09 1. Summation \0A\09 2. Sum of squares \0A\09 3. Sum of cubes \0A\09 4. Product \0A\09 5. Exit \0A Your choice: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [15 x i8] c"\0AThe sum is %d\00"
@.str.6 = [26 x i8] c"\0AThe sum of squares is %d\00"
@.str.7 = [24 x i8] c"\0AThe sum of cubes is %d\00"
@.str.8 = [19 x i8] c"\0AThe product is %d\00"
@.str.9 = [14 x i8] c"\0AWrong choice\00"
@str = [20 x i8] c"Enter two numbers: \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 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
switch i32 %12, label %39 [
i32 1, label %13
i32 2, label %18
i32 3, label %25
i32 4, label %32
i32 5, label %37
]
13: ; preds = %0
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = add nsw i32 %15, %14
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %16)
br label %41
18: ; preds = %0
%19 = load i32, i32* %1
%20 = call i32 @pow(i32 %19, i32 2)
%21 = load i32, i32* %2
%22 = call i32 @pow(i32 %21, i32 2)
%23 = add nsw i32 %22, %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %41
25: ; preds = %0
%26 = load i32, i32* %1
%27 = call i32 @pow(i32 %26, i32 3)
%28 = load i32, i32* %2
%29 = call i32 @pow(i32 %28, i32 3)
%30 = add nsw i32 %29, %27
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %30)
br label %41
32: ; preds = %0
%33 = load i32, i32* %1
%34 = load i32, i32* %2
%35 = mul nsw i32 %34, %33
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %0, %32
%38 = call i32 @exit(i32 0)
unreachable
39: ; preds = %0
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %41
41: ; preds = %39, %25, %18, %13
ret i32 0
}