#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 EXIT_SUCCESS;
int gfadd(int, int);
int gfmul(int, int);
int gfsub(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int a, b;
  int option;
start:
  printf("\n\n");
  printf("\t*************************************************\n");
  printf("\t**** Welcome to Galois Field 2^8 Calculator ****\n");
  printf("\t*************************************************\n");
  printf("1. Addition\n2. Subtract\n3. Multiplication\n0. Exit\n");
  printf("Enter your Selection : ");
  scanf("%d", &option);
  while (option != 0) {
    if (option > 3) {
      printf("================================================================="
             "=\n");
      printf("Wrong option .. please try again\n");
      printf("================================================================="
             "=\n");
      goto start;
    }
    printf("Enter The First Number\n");
    scanf("%d", &a);
    printf("Enter The Second Number\n");
    scanf("%d", &b);
    if (option == 1)
      printf("The addition result = %d\n", gfadd(a, b));
    if (option == 2)
      printf("The subtraction result = %d\n", gfsub(a, b));
    if (option == 3)
      printf("The multiplication result = %d\n", gfmul(a, b));
    goto start;
  }
  if (option == 0)
    return EXIT_SUCCESS;
  return (-1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
je     12b6 <main+0x166>
cmpl   $0x3,-0x10(%rbp)
jle    1206 <main+0xb6>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115f <main+0xf>
lea    0xf11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x10(%rbp)
jne    1267 <main+0x117>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <gfadd@plt>
mov    %eax,%esi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x10(%rbp)
jne    128c <main+0x13c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <gfsub@plt>
mov    %eax,%esi
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x10(%rbp)
jne    12b1 <main+0x161>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <gfmul@plt>
mov    %eax,%esi
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115f <main+0xf>
cmpl   $0x0,-0x10(%rbp)
jne    12d1 <main+0x181>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d8 <main+0x188>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf2f(%rip),%r12
lea    0xef6(%rip),%rbx
lea    0xf54(%rip),%rbp
lea    0xe76(%rip),%r15
lea    0xe87(%rip),%r13
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1302 <main+0x1a2>
cmp    $0x4,%eax
jl     1240 <main+0xe0>
mov    %r12,%r13
mov    %r14,%r12
mov    %r15,%r14
lea    0xf57(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%r15
mov    %r12,%r14
mov    %r13,%r12
lea    0xdef(%rip),%r13
call   1030 <puts@plt>
jmp    11a0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     1290 <main+0x130>
cmp    $0x2,%eax
je     12b6 <main+0x156>
cmp    $0x3,%eax
jne    11a0 <main+0x40>
jmp    12e0 <main+0x180>
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1070 <gfadd@plt>
lea    0xd77(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
jne    1280 <main+0x120>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1050 <gfsub@plt>
lea    0xd6b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jne    11a0 <main+0x40>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1080 <gfmul@plt>
lea    0xd5e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x40>
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [52 x i8] c"\09*************************************************\0A\00"
@.str.2 = [51 x i8] c"\09**** Welcome to Galois Field 2^8 Calculator ****\0A\00"
@.str.3 = [51 x i8] c"1. Addition\0A2. Subtract\0A3. Multiplication\0A0. Exit\0A\00"
@.str.4 = [24 x i8] c"Enter your Selection : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [68 x i8] c"==================================================================\0A\00"
@.str.7 = [34 x i8] c"Wrong option .. please try again\0A\00"
@.str.8 = [24 x i8] c"Enter The First Number\0A\00"
@.str.9 = [25 x i8] c"Enter The Second Number\0A\00"
@.str.10 = [26 x i8] c"The addition result = %d\0A\00"
@.str.11 = [29 x i8] c"The subtraction result = %d\0A\00"
@.str.12 = [32 x i8] c"The multiplication result = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %51, %19, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
br label %13
13: ; preds = %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %52
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 3
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0))
br label %5
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @gfadd(i32 %31, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %30, %23
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = call i32 @gfsub(i32 %39, i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %38, %35
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, 3
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* %2
%48 = load i32, i32* %3
%49 = call i32 @gfmul(i32 %47, i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %46, %43
br label %5
52: ; preds = %13
%53 = load i32, i32* %4
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = load i32, i32* @EXIT_SUCCESS
store i32 %56, i32* %1
br label %58
57: ; preds = %52
store i32 -1, i32* %1
br label %58
58: ; preds = %57, %55
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str.4 = [24 x i8] c"Enter your Selection : \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.10 = [26 x i8] c"The addition result = %d\0A\00"
@.str.11 = [29 x i8] c"The subtraction result = %d\0A\00"
@.str.12 = [32 x i8] c"The multiplication result = %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [2 x i8] c"\0A\00"
@str.14 = [50 x i8] c"\09**** Welcome to Galois Field 2^8 Calculator ****\00"
@str.15 = [51 x i8] c"\09*************************************************\00"
@str.16 = [50 x i8] c"1. Addition\0A2. Subtract\0A3. Multiplication\0A0. Exit\00"
@str.17 = [23 x i8] c"Enter The First Number\00"
@str.18 = [24 x i8] c"Enter The Second Number\00"
@str.20 = [33 x i8] c"Wrong option .. please try again\00"
@str.21 = [67 x i8] c"==================================================================\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*
br label %7
7: ; preds = %48, %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.14, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.16, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %54, label %17
17: ; preds = %7
%18 = icmp sgt i32 %15, 3
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.21, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.20, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.21, i64 0, i64 0))
br label %48
23: ; preds = %17
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.18, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %36
30: ; preds = %23
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = call i32 @gfadd(i32 %31, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %3
br label %36
36: ; preds = %30, %23
%37 = phi i32 [ %35, %30 ], [ %28, %23 ]
%38 = icmp eq i32 %37, 2
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = load i32, i32* %1
%41 = load i32, i32* %2
%42 = call i32 @gfsub(i32 %40, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %3
br label %45
45: ; preds = %39, %36
%46 = phi i32 [ %44, %39 ], [ %37, %36 ]
%47 = icmp eq i32 %46, 3
br i1 %47, label %49, label %48
48: ; preds = %45, %49, %19
br label %7
49: ; preds = %45
%50 = load i32, i32* %1
%51 = load i32, i32* %2
%52 = call i32 @gfmul(i32 %50, i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0), i32 %52)
br label %48
54: ; preds = %7
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}