#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 *);
int main() {
  int a, b, c;
  printf("Podaj a: ");
  scanf("%i", &a);
  printf("Podaj b: ");
  scanf("%i", &b);
  if (a < 1 || b < 1) {
    printf("Error, zle dane !\n");
  } else {
    c = 0;
    while (c < 1 || c > 6) {
      printf("Podaj mi co chcesz zrobic:\n");
      printf("1) Dodać\n");
      printf("2) Odjąć\n");
      printf("3) Pomnożyć\n");
      printf("4) Odjąć\n");
      printf("5) Obliczyć modulo\n");
      printf("6) Zakończyć program\n");
      printf("Twój wybór to: ");
      scanf("%i", &c);
    }
    if (c == 1) {
      printf("Wynik dodawania to: %i\n", a + b);
    } else if (c == 2) {
      printf("Wynik odejmowania to: %i\n", a - b);
    } else if (c == 3) {
      printf("Wynik mnożenia to: %i\n", a * b);
    } else if (c == 4) {
      printf("Wynik dzielenia to: %i\n", a / b);
    } else if (c == 5) {
      printf("Wynik modulo to: %i\n", a % b);
    } else if (c == 6) {
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     117f <main+0x5f>
cmpl   $0x1,-0xc(%rbp)
jge    1192 <main+0x72>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1331 <main+0x211>
movl   $0x0,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jl     11b2 <main+0x92>
cmpl   $0x6,-0x10(%rbp)
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11c2 <main+0xa2>
jmp    1247 <main+0x127>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1199 <main+0x79>
cmpl   $0x1,-0x10(%rbp)
jne    126a <main+0x14a>
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132c <main+0x20c>
cmpl   $0x2,-0x10(%rbp)
jne    128d <main+0x16d>
mov    -0x8(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1327 <main+0x207>
cmpl   $0x3,-0x10(%rbp)
jne    12b1 <main+0x191>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1322 <main+0x202>
cmpl   $0x4,-0x10(%rbp)
jne    12d7 <main+0x1b7>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    131d <main+0x1fd>
cmpl   $0x5,-0x10(%rbp)
jne    12fd <main+0x1dd>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1318 <main+0x1f8>
cmpl   $0x6,-0x10(%rbp)
jne    1313 <main+0x1f3>
movl   $0x0,-0x4(%rbp)
jmp    1338 <main+0x218>
jmp    1318 <main+0x1f8>
jmp    131d <main+0x1fd>
jmp    1322 <main+0x202>
jmp    1327 <main+0x207>
jmp    132c <main+0x20c>
jmp    1331 <main+0x211>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%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    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1262 <main+0x132>
cmpl   $0x0,0xc(%rsp)
jle    1262 <main+0x132>
movl   $0x0,0x14(%rsp)
lea    0xf52(%rip),%rbx
lea    0xf56(%rip),%rbp
lea    0xf63(%rip),%r14
lea    0xe76(%rip),%r15
lea    0xe62(%rip),%r12
lea    0x14(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
lea    -0x7(%rax),%ecx
cmp    $0xfffffffa,%ecx
jb     11d0 <main+0xa0>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     12c0 <main+0x190>
lea    0xdb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0xc(%rsp),%esi
add    0x10(%rsp),%esi
lea    0xddd(%rip),%rdi
jmp    12b9 <main+0x189>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
jmp    12c0 <main+0x190>
mov    0x10(%rsp),%esi
sub    0xc(%rsp),%esi
lea    0xdd6(%rip),%rdi
jmp    12b9 <main+0x189>
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
lea    0xdde(%rip),%rdi
jmp    12b9 <main+0x189>
mov    0x10(%rsp),%eax
cltd
idivl  0xc(%rsp)
lea    0xde4(%rip),%rdi
mov    %eax,%esi
jmp    12b9 <main+0x189>
mov    0x10(%rsp),%eax
cltd
idivl  0xc(%rsp)
lea    0xde8(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Podaj a: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [10 x i8] c"Podaj b: \00"
@.str.3 = [19 x i8] c"Error, zle dane !\0A\00"
@.str.4 = [28 x i8] c"Podaj mi co chcesz zrobic:\0A\00"
@.str.5 = [11 x i8] c"1) Doda\C4\87\0A\00"
@.str.6 = [12 x i8] c"2) Odj\C4\85\C4\87\0A\00"
@.str.7 = [15 x i8] c"3) Pomno\C5\BCy\C4\87\0A\00"
@.str.8 = [12 x i8] c"4) Odj\C4\85\C4\87\0A\00"
@.str.9 = [21 x i8] c"5) Obliczy\C4\87 modulo\0A\00"
@.str.10 = [24 x i8] c"6) Zako\C5\84czy\C4\87 program\0A\00"
@.str.11 = [18 x i8] c"Tw\C3\B3j wyb\C3\B3r to: \00"
@.str.12 = [24 x i8] c"Wynik dodawania to: %i\0A\00"
@.str.13 = [26 x i8] c"Wynik odejmowania to: %i\0A\00"
@.str.14 = [24 x i8] c"Wynik mno\C5\BCenia to: %i\0A\00"
@.str.15 = [24 x i8] c"Wynik dzielenia to: %i\0A\00"
@.str.16 = [21 x i8] c"Wynik modulo to: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11, %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %85
16: ; preds = %11
store i32 0, i32* %4
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 6
br label %23
23: ; preds = %20, %17
%24 = phi i1 [ true, %17 ], [ %22, %20 ]
br i1 %24, label %25, label %35
25: ; preds = %23
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %17
35: ; preds = %23
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = add nsw i32 %39, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i32 %41)
br label %84
43: ; preds = %35
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* %2
%48 = load i32, i32* %3
%49 = sub nsw i32 %47, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %49)
br label %83
51: ; preds = %43
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 3
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = mul nsw i32 %55, %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i32 %57)
br label %82
59: ; preds = %51
%60 = load i32, i32* %4
%61 = icmp eq i32 %60, 4
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load i32, i32* %2
%64 = load i32, i32* %3
%65 = sdiv i32 %63, %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %65)
br label %81
67: ; preds = %59
%68 = load i32, i32* %4
%69 = icmp eq i32 %68, 5
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = load i32, i32* %2
%72 = load i32, i32* %3
%73 = srem i32 %71, %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), i32 %73)
br label %80
75: ; preds = %67
%76 = load i32, i32* %4
%77 = icmp eq i32 %76, 6
br i1 %77, label %78, label %79
78: ; preds = %75
store i32 0, i32* %1
br label %86
79: ; preds = %75
br label %80
80: ; preds = %79, %70
br label %81
81: ; preds = %80, %62
br label %82
82: ; preds = %81, %54
br label %83
83: ; preds = %82, %46
br label %84
84: ; preds = %83, %38
br label %85
85: ; preds = %84, %14
store i32 0, i32* %1
br label %86
86: ; preds = %85, %78
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
@.str = [10 x i8] c"Podaj a: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [10 x i8] c"Podaj b: \00"
@.str.11 = [18 x i8] c"Tw\C3\B3j wyb\C3\B3r to: \00"
@.str.12 = [24 x i8] c"Wynik dodawania to: %i\0A\00"
@.str.13 = [26 x i8] c"Wynik odejmowania to: %i\0A\00"
@.str.14 = [24 x i8] c"Wynik mno\C5\BCenia to: %i\0A\00"
@.str.15 = [24 x i8] c"Wynik dzielenia to: %i\0A\00"
@.str.16 = [21 x i8] c"Wynik modulo to: %i\0A\00"
@str = [27 x i8] c"Podaj mi co chcesz zrobic:\00"
@str.17 = [10 x i8] c"1) Doda\C4\87\00"
@str.18 = [11 x i8] c"2) Odj\C4\85\C4\87\00"
@str.19 = [14 x i8] c"3) Pomno\C5\BCy\C4\87\00"
@str.20 = [11 x i8] c"4) Odj\C4\85\C4\87\00"
@str.21 = [20 x i8] c"5) Obliczy\C4\87 modulo\00"
@str.22 = [23 x i8] c"6) Zako\C5\84czy\C4\87 program\00"
@str.23 = [18 x i8] c"Error, zle dane !\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 ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 1
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 1
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.23, i64 0, i64 0))
br label %58
18: ; preds = %0
store i32 0, i32* %3
br label %19
19: ; preds = %18, %19
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.17, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.20, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.21, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.22, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = add i32 %29, -7
%31 = icmp ult i32 %30, -6
br i1 %31, label %19, label %32
32: ; preds = %19
switch i32 %29, label %58 [
i32 1, label %33
i32 2, label %38
i32 3, label %43
i32 4, label %48
i32 5, label %53
]
33: ; preds = %32
%34 = load i32, i32* %1
%35 = load i32, i32* %2
%36 = add nsw i32 %35, %34
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i32 %36)
br label %58
38: ; preds = %32
%39 = load i32, i32* %1
%40 = load i32, i32* %2
%41 = sub nsw i32 %39, %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %41)
br label %58
43: ; preds = %32
%44 = load i32, i32* %1
%45 = load i32, i32* %2
%46 = mul nsw i32 %45, %44
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i32 %46)
br label %58
48: ; preds = %32
%49 = load i32, i32* %1
%50 = load i32, i32* %2
%51 = sdiv i32 %49, %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %51)
br label %58
53: ; preds = %32
%54 = load i32, i32* %1
%55 = load i32, i32* %2
%56 = srem i32 %54, %55
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %16, %38, %48, %53, %43, %33, %32
ret i32 0
}