#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  printf("This program needs 2 initial digit(s) to perform 4 initial math "
         "actions on them\n\n");
  char z;
  int i, j, x;
  printf("Enter 1st Number:");
  scanf("%d", &i);
  printf("Enter 2nd Number:");
  scanf("%d", &j);
  printf("Enter action:");
  scanf(" %c", &z);
  switch (z) {
  case '+':
    printf("This is the Resualt: %d\n", i + j);
    break;
  case '-':
    printf("This is the Resualt: %d\n", i - j);
    break;
  case '*':
    printf("This is the Resualt: %d\n", i * j);
    break;
  case '/':
    printf("This is the Resualt: %d\n", i / j);
    break;
  default:
    printf("The operator is not valid\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf20(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf23(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xf0f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf01(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1239 <main+0x119>
mov    -0x20(%rbp),%rax
lea    0xe38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x127>
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x127>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x127>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x127>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11d5 <main+0xa5>
lea    0xe49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
jmp    11eb <main+0xbb>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
jmp    11eb <main+0xbb>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
jmp    120d <main+0xdd>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
lea    0xe5f(%rip),%rdi
jmp    1206 <main+0xd6>
mov    0xc(%rsp),%eax
cltd
idivl  0x8(%rsp)
lea    0xe4d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [82 x i8] c"This program needs 2 initial digit(s) to perform 4 initial math actions on them\0A\0A\00"
@.str.1 = [18 x i8] c"Enter 1st Number:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [18 x i8] c"Enter 2nd Number:\00"
@.str.4 = [14 x i8] c"Enter action:\00"
@.str.5 = [4 x i8] c" %c\00"
@.str.6 = [25 x i8] c"This is the Resualt: %d\0A\00"
@.str.7 = [27 x i8] c"The operator is not valid\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
switch i32 %14, label %35 [
i32 43, label %15
i32 45, label %20
i32 42, label %25
i32 47, label %30
]
15: ; preds = %0
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = add nsw i32 %16, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %18)
br label %37
20: ; preds = %0
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %37
25: ; preds = %0
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = mul nsw i32 %26, %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %28)
br label %37
30: ; preds = %0
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = sdiv i32 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %33)
br label %37
35: ; preds = %0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %37
37: ; preds = %35, %30, %25, %20, %15
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"Enter 1st Number:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [18 x i8] c"Enter 2nd Number:\00"
@.str.4 = [14 x i8] c"Enter action:\00"
@.str.5 = [4 x i8] c" %c\00"
@.str.6 = [25 x i8] c"This is the Resualt: %d\0A\00"
@str = [81 x i8] c"This program needs 2 initial digit(s) to perform 4 initial math actions on them\0A\00"
@str.8 = [26 x i8] c"The operator is not valid\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str, i64 0, i64 0))
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
switch i32 %14, label %35 [
i32 43, label %15
i32 45, label %20
i32 42, label %25
i32 47, label %30
]
15: ; preds = %0
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %18)
br label %37
20: ; preds = %0
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = sub nsw i32 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %37
25: ; preds = %0
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = mul nsw i32 %27, %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %28)
br label %37
30: ; preds = %0
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = sdiv i32 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %33)
br label %37
35: ; preds = %0
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.8, i64 0, i64 0))
br label %37
37: ; preds = %35, %30, %25, %20, %15
ret i32 0
}