#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 /*<<< orphan*/ utworz(int, int);
int /*<<< orphan*/ wyswietl(int, int);
int /*<<< orphan*/ zmianaznaku(int, int);
int main() {
  char wybor = '0';
  int w = 0, k = 0;
  while (wybor != '4') {
    printf("----------PROSTE MENU----------\n");
    printf("1 - utworz tablice\n");
    printf("2 - wyswietl tablice\n");
    printf("3 - zmien znaki w tablicy\n");
    printf("4 - zakoncz dzialanie programu\n");
    scanf("%c", &wybor);
    switch (wybor) {
    case '1':
      printf("wybrano wariant pierwszy\n");
      printf("podaj wymiar tablicy:\n");
      scanf("%i", &w);
      scanf("%i", &k);
      utworz(w, k);
      break;
    case '2':
      printf("wybrano wariant drugi\n");
      wyswietl(w, k);
      break;
    case '3':
      printf("wybrano wariant trzeci\n");
      zmianaznaku(w, k);
      break;
    case '4':
      printf("PAPA ! \n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x30,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x34,%eax
je     128b <main+0x13b>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1286 <main+0x136>
mov    -0x18(%rbp),%rax
lea    0xe13(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xea3(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <utworz@plt>
jmp    1286 <main+0x136>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <wyswietl@plt>
jmp    1286 <main+0x136>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <zmianaznaku@plt>
jmp    1286 <main+0x136>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
jmp    1171 <main+0x21>
xor    %eax,%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
movb   $0x30,0xf(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xecf(%rip),%rbx
lea    0xedd(%rip),%rbp
lea    0xef0(%rip),%r12
lea    0xe81(%rip),%r13
lea    0xf(%rsp),%r14
lea    0xe65(%rip),%r15
jmp    11b9 <main+0x69>
nopl   (%rax)
lea    0xef0(%rip),%rdi
call   1040 <puts@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x34,%al
je     12be <main+0x16e>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movsbl 0xf(%rsp),%eax
lea    -0x31(%rax),%ecx
cmp    $0x3,%ecx
ja     11b1 <main+0x61>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%r15
mov    %r13,%r14
mov    %r12,%r13
lea    0xddf(%rip),%r12
mov    %r12,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r12,%rdi
mov    %r13,%r12
mov    %r14,%r13
mov    %r15,%r14
lea    0xdaa(%rip),%r15
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1050 <utworz@plt>
jmp    11ac <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe2f(%rip),%rdi
call   1040 <puts@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1060 <wyswietl@plt>
jmp    11ac <main+0x5c>
xchg   %ax,%ax
lea    0xdf8(%rip),%rdi
call   1040 <puts@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1030 <zmianaznaku@plt>
jmp    11ac <main+0x5c>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"----------PROSTE MENU----------\0A\00"
@.str.1 = [20 x i8] c"1 - utworz tablice\0A\00"
@.str.2 = [22 x i8] c"2 - wyswietl tablice\0A\00"
@.str.3 = [27 x i8] c"3 - zmien znaki w tablicy\0A\00"
@.str.4 = [32 x i8] c"4 - zakoncz dzialanie programu\0A\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [26 x i8] c"wybrano wariant pierwszy\0A\00"
@.str.7 = [23 x i8] c"podaj wymiar tablicy:\0A\00"
@.str.8 = [3 x i8] c"%i\00"
@.str.9 = [23 x i8] c"wybrano wariant drugi\0A\00"
@.str.10 = [24 x i8] c"wybrano wariant trzeci\0A\00"
@.str.11 = [9 x i8] c"PAPA ! \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i8 48, i8* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %38, %0
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 52
br i1 %8, label %9, label %39
9: ; preds = %5
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
switch i32 %17, label %38 [
i32 49, label %18
i32 50, label %26
i32 51, label %31
i32 52, label %36
]
18: ; preds = %9
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @utworz(i32 %23, i32 %24)
br label %38
26: ; preds = %9
%27 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @wyswietl(i32 %28, i32 %29)
br label %38
31: ; preds = %9
%32 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 @zmianaznaku(i32 %33, i32 %34)
br label %38
36: ; preds = %9
%37 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %38
38: ; preds = %36, %9, %31, %26, %18
br label %5
39: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [3 x i8] c"%c\00"
@.str.8 = [3 x i8] c"%i\00"
@str = [32 x i8] c"----------PROSTE MENU----------\00"
@str.12 = [19 x i8] c"1 - utworz tablice\00"
@str.13 = [21 x i8] c"2 - wyswietl tablice\00"
@str.14 = [26 x i8] c"3 - zmien znaki w tablicy\00"
@str.15 = [31 x i8] c"4 - zakoncz dzialanie programu\00"
@str.16 = [8 x i8] c"PAPA ! \00"
@str.17 = [23 x i8] c"wybrano wariant trzeci\00"
@str.18 = [22 x i8] c"wybrano wariant drugi\00"
@str.19 = [25 x i8] c"wybrano wariant pierwszy\00"
@str.20 = [22 x i8] c"podaj wymiar tablicy:\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
store i8 48, i8* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %0, %37
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.14, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.15, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 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 %37 [
i32 49, label %15
i32 50, label %23
i32 51, label %28
i32 52, label %33
]
15: ; preds = %6
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.19, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.20, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @utworz(i32 %20, i32 %21)
br label %35
23: ; preds = %6
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.18, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @wyswietl(i32 %25, i32 %26)
br label %35
28: ; preds = %6
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0))
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @zmianaznaku(i32 %30, i32 %31)
br label %35
33: ; preds = %6
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.16, i64 0, i64 0))
br label %35
35: ; preds = %15, %23, %28, %33
%36 = load i8, i8* %1
br label %37
37: ; preds = %35, %6
%38 = phi i8 [ %36, %35 ], [ %13, %6 ]
%39 = icmp eq i8 %38, 52
br i1 %39, label %40, label %6
40: ; preds = %37
ret i32 0
}