#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int czytaj(int /*<<< orphan*/ *, int **, int *, int *, int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ filtr(int **, int, int);
int /*<<< orphan*/ filtr2(int **, int, int, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ konturowanie(int **, int, int, int);
int /*<<< orphan*/ negatyw(int **, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ progowanie(int **, int, int, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ wyswietl(char *);
int zapisz(int /*<<< orphan*/ *, int **, int, int, int);
int main() {
  int wymx, wymy, szarosci, prog;
  int obraz_pgm[512][512];
  int operacja = 0;
  FILE *plik;
  char nazwa[100], nazwa2[100], wybor = 'a';
  while (wybor != '0') {
    printf("----------MENU----------\n");
    printf("1 - wczytanie obrazu z pliku\n");
    printf("2 - zapisanie obrazu do pliku\n");
    printf("3 - wyswietlanie obrazu\n");
    printf("4 - negatyw\n");
    printf("5 - progowanie\n");
    printf("6 - konturowanie\n");
    printf("7 - filtr usredniajacy ze wzmocnieniem\n");
    printf("8 - filtrowanie przy uzyciu gradientu Robertsa\n");
    printf("0 - zakonczenie dzialania programu\n");
    scanf("%c", &wybor);
    switch (wybor) {
    case '1':
      printf("Podaj nazwe pliku:\n");
      scanf("%s", nazwa);
      plik = fopen(nazwa, "r");
      if (plik != NULL)
        operacja = czytaj(plik, obraz_pgm, &wymx, &wymy, &szarosci);
      if (operacja != 0)
        printf("Wczytywanie obrazu powiodlo sie.\n");
      fclose(plik);
      break;
    case '2':
      printf("Podaj nazwe pliku do zapisu:\n");
      scanf("%s", nazwa2);
      plik = fopen(nazwa2, "w");
      if (plik != NULL)
        operacja = zapisz(plik, obraz_pgm, wymx, wymy, szarosci);
      if (operacja != 0)
        printf("Zapis obrazu do pliku powiodl sie.\n");
      fclose(plik);
      break;
    case '3':
      wyswietl(nazwa);
      break;
    case '4':
      negatyw(obraz_pgm, wymx, wymy, szarosci);
      printf("Utworzono negatyw obrazu.\n");
      break;
    case '5':
      printf("Podaj prog:\n");
      scanf("%i", &prog);
      progowanie(obraz_pgm, wymx, wymy, szarosci, prog);
      printf("Progowanie obrazu przy progu %i zakonczone.\n", prog);
      break;
    case '6':
      konturowanie(obraz_pgm, wymx, wymy, szarosci);
      printf("Konturowanie obrazu zakonczone.\n");
      break;
    case '7':
      filtr(obraz_pgm, wymx, wymy);
      printf("Obraz zostal przefiltrowany przy uzyciu filtra usredniajacego ze "
             "wzmocnieniem.\n");
      break;
    case '8':
      filtr2(obraz_pgm, wymx, wymy, szarosci);
      printf("Obraz zostal przefiltrowany przy pomocy gradientu Robertsa.\n");
      break;
    case '0':
      printf("Milego dnia!\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100130,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x100024(%rbp)
movb   $0x61,-0x100111(%rbp)
movsbl -0x100111(%rbp),%eax
cmp    $0x30,%eax
je     153b <main+0x37b>
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x100121(%rbp)
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe2a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe36(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe43(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe4a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe45(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe43(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe43(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe59(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe77(%rip),%rdi
call   1070 <printf@plt>
mov    -0x100121(%rbp),%al
lea    0xe89(%rip),%rdi
lea    -0x100111(%rbp),%rsi
call   10d0 <scanf@plt>
movsbl -0x100111(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x100120(%rbp)
sub    $0x8,%eax
ja     1536 <main+0x376>
mov    -0x100120(%rbp),%rax
lea    0xd14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1000a0(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   10d0 <scanf@plt>
lea    -0x1000a0(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x100030(%rbp)
cmpq   $0x0,-0x100030(%rbp)
je     1365 <main+0x1a5>
mov    -0x100030(%rbp),%rdi
lea    -0x100020(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1090 <czytaj@plt>
mov    %eax,-0x100024(%rbp)
cmpl   $0x0,-0x100024(%rbp)
je     1380 <main+0x1c0>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x100030(%rbp),%rdi
call   1060 <fclose@plt>
jmp    1536 <main+0x376>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x100110(%rbp),%rsi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   10d0 <scanf@plt>
lea    -0x100110(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x100030(%rbp)
cmpq   $0x0,-0x100030(%rbp)
je     13ff <main+0x23f>
mov    -0x100030(%rbp),%rdi
lea    -0x100020(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
call   1030 <zapisz@plt>
mov    %eax,-0x100024(%rbp)
cmpl   $0x0,-0x100024(%rbp)
je     141a <main+0x25a>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x100030(%rbp),%rdi
call   1060 <fclose@plt>
jmp    1536 <main+0x376>
lea    -0x1000a0(%rbp),%rdi
call   10b0 <wyswietl@plt>
jmp    1536 <main+0x376>
lea    -0x100020(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   10a0 <negatyw@plt>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1536 <main+0x376>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd70(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   10d0 <scanf@plt>
lea    -0x100020(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   10c0 <progowanie@plt>
mov    -0x14(%rbp),%esi
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1536 <main+0x376>
lea    -0x100020(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <konturowanie@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1536 <main+0x376>
lea    -0x100020(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1080 <filtr@plt>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1536 <main+0x376>
lea    -0x100020(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <filtr2@plt>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1536 <main+0x376>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    11e3 <main+0x23>
xor    %eax,%eax
add    $0x100130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100108,%rsp
movb   $0x61,0xb(%rsp)
lea    0xe6f(%rip),%r15
lea    0xe81(%rip),%r13
lea    0xe97(%rip),%r14
lea    0xeae(%rip),%rbp
lea    0xebf(%rip),%rbx
lea    0xdf0(%rip),%r12
movl   $0x0,0x18(%rsp)
jmp    1242 <main+0x72>
lea    0xf4c(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1050 <puts@plt>
movzbl 0xb(%rsp),%eax
cmp    $0x30,%al
je     14cc <main+0x2fc>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xe63(%rip),%rdi
call   1050 <puts@plt>
lea    0xe66(%rip),%rdi
call   1050 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe86(%rip),%rdi
call   1050 <puts@plt>
lea    0xea9(%rip),%rdi
call   1050 <puts@plt>
lea    0xd77(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   10e0 <scanf@plt>
movsbl 0xb(%rsp),%eax
lea    -0x30(%rax),%ecx
cmp    $0x8,%ecx
ja     123a <main+0x6a>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xfb1(%rip),%rdi
call   1050 <puts@plt>
lea    0xd41(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10e0 <scanf@plt>
mov    %rbx,%rdi
lea    0xd2b(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     132f <main+0x15f>
mov    %rbx,%rdi
lea    0x100(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x14(%rsp),%r8
call   10a0 <czytaj@plt>
mov    %eax,0x18(%rsp)
cmpl   $0x0,0x18(%rsp)
je     1342 <main+0x172>
lea    0xf61(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
jmp    13ba <main+0x1ea>
lea    0xefd(%rip),%rdi
call   1050 <puts@plt>
lea    0xccd(%rip),%rdi
lea    0x90(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10e0 <scanf@plt>
mov    %rbx,%rdi
lea    0xd5c(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     13a4 <main+0x1d4>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    %r14,%rdi
lea    0x100(%rsp),%rsi
call   1030 <zapisz@plt>
mov    %eax,0x18(%rsp)
cmpl   $0x0,0x18(%rsp)
je     13b7 <main+0x1e7>
lea    0xeb6(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1070 <fclose@plt>
lea    0xccc(%rip),%r14
lea    0xce3(%rip),%rbp
lea    0xcf4(%rip),%rbx
jmp    1235 <main+0x65>
lea    0x20(%rsp),%rdi
call   10c0 <wyswietl@plt>
jmp    1235 <main+0x65>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0x100(%rsp),%rdi
call   10b0 <negatyw@plt>
lea    0xe29(%rip),%rdi
jmp    1230 <main+0x60>
lea    0xe11(%rip),%rdi
call   1050 <puts@plt>
lea    0xc0c(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   10e0 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x1c(%rsp),%r8d
lea    0x100(%rsp),%rdi
call   10d0 <progowanie@plt>
mov    0x1c(%rsp),%esi
lea    0xbda(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1235 <main+0x65>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0x100(%rsp),%rdi
call   1060 <konturowanie@plt>
lea    0xd84(%rip),%rdi
jmp    1230 <main+0x60>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0x100(%rsp),%rdi
call   1090 <filtr@plt>
lea    0xd14(%rip),%rdi
jmp    1230 <main+0x60>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0x100(%rsp),%rdi
call   1040 <filtr2@plt>
lea    0xcb3(%rip),%rdi
jmp    1230 <main+0x60>
xor    %eax,%eax
add    $0x100108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"----------MENU----------\0A\00"
@.str.1 = [30 x i8] c"1 - wczytanie obrazu z pliku\0A\00"
@.str.2 = [31 x i8] c"2 - zapisanie obrazu do pliku\0A\00"
@.str.3 = [25 x i8] c"3 - wyswietlanie obrazu\0A\00"
@.str.4 = [13 x i8] c"4 - negatyw\0A\00"
@.str.5 = [16 x i8] c"5 - progowanie\0A\00"
@.str.6 = [18 x i8] c"6 - konturowanie\0A\00"
@.str.7 = [40 x i8] c"7 - filtr usredniajacy ze wzmocnieniem\0A\00"
@.str.8 = [48 x i8] c"8 - filtrowanie przy uzyciu gradientu Robertsa\0A\00"
@.str.9 = [36 x i8] c"0 - zakonczenie dzialania programu\0A\00"
@.str.10 = [3 x i8] c"%c\00"
@.str.11 = [20 x i8] c"Podaj nazwe pliku:\0A\00"
@.str.12 = [3 x i8] c"%s\00"
@.str.13 = [2 x i8] c"r\00"
@.str.14 = [34 x i8] c"Wczytywanie obrazu powiodlo sie.\0A\00"
@.str.15 = [30 x i8] c"Podaj nazwe pliku do zapisu:\0A\00"
@.str.16 = [2 x i8] c"w\00"
@.str.17 = [36 x i8] c"Zapis obrazu do pliku powiodl sie.\0A\00"
@.str.18 = [27 x i8] c"Utworzono negatyw obrazu.\0A\00"
@.str.19 = [13 x i8] c"Podaj prog:\0A\00"
@.str.20 = [3 x i8] c"%i\00"
@.str.21 = [45 x i8] c"Progowanie obrazu przy progu %i zakonczone.\0A\00"
@.str.22 = [33 x i8] c"Konturowanie obrazu zakonczone.\0A\00"
@.str.23 = [80 x i8] c"Obraz zostal przefiltrowany przy uzyciu filtra usredniajacego ze wzmocnieniem.\0A\00"
@.str.24 = [61 x i8] c"Obraz zostal przefiltrowany przy pomocy gradientu Robertsa.\0A\00"
@.str.25 = [14 x i8] c"Milego dnia!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [512 x [512 x i32]]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [100 x i8]
%10 = alloca [100 x i8]
%11 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %7
store i8 97, i8* %11
br label %12
12: ; preds = %123, %0
%13 = load i8, i8* %11
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 48
br i1 %15, label %16, label %124
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %11)
%28 = load i8, i8* %11
%29 = sext i8 %28 to i32
switch i32 %29, label %123 [
i32 49, label %30
i32 50, label %51
i32 51, label %75
i32 52, label %78
i32 53, label %86
i32 54, label %98
i32 55, label %106
i32 56, label %113
i32 48, label %121
]
30: ; preds = %16
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32* %35, i32** %8
%36 = load i32*, i32** %8
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %43
38: ; preds = %30
%39 = load i32*, i32** %8
%40 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%41 = bitcast [512 x i32]* %40 to i32**
%42 = call i32 @czytaj(i32* %39, i32** %41, i32* %2, i32* %3, i32* %4)
store i32 %42, i32* %7
br label %43
43: ; preds = %38, %30
%44 = load i32, i32* %7
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0))
br label %48
48: ; preds = %46, %43
%49 = load i32*, i32** %8
%50 = call i32 @fclose(i32* %49)
br label %123
51: ; preds = %16
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.15, i64 0, i64 0))
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%56 = call i32* @fopen(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %56, i32** %8
%57 = load i32*, i32** %8
%58 = icmp ne i32* %57, null
br i1 %58, label %59, label %67
59: ; preds = %51
%60 = load i32*, i32** %8
%61 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%62 = bitcast [512 x i32]* %61 to i32**
%63 = load i32, i32* %2
%64 = load i32, i32* %3
%65 = load i32, i32* %4
%66 = call i32 @zapisz(i32* %60, i32** %62, i32 %63, i32 %64, i32 %65)
store i32 %66, i32* %7
br label %67
67: ; preds = %59, %51
%68 = load i32, i32* %7
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0))
br label %72
72: ; preds = %70, %67
%73 = load i32*, i32** %8
%74 = call i32 @fclose(i32* %73)
br label %123
75: ; preds = %16
%76 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%77 = call i32 @wyswietl(i8* %76)
br label %123
78: ; preds = %16
%79 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%80 = bitcast [512 x i32]* %79 to i32**
%81 = load i32, i32* %2
%82 = load i32, i32* %3
%83 = load i32, i32* %4
%84 = call i32 @negatyw(i32** %80, i32 %81, i32 %82, i32 %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.18, i64 0, i64 0))
br label %123
86: ; preds = %16
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i64 0, i64 0))
%88 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i32* %5)
%89 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%90 = bitcast [512 x i32]* %89 to i32**
%91 = load i32, i32* %2
%92 = load i32, i32* %3
%93 = load i32, i32* %4
%94 = load i32, i32* %5
%95 = call i32 @progowanie(i32** %90, i32 %91, i32 %92, i32 %93, i32 %94)
%96 = load i32, i32* %5
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.21, i64 0, i64 0), i32 %96)
br label %123
98: ; preds = %16
%99 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%100 = bitcast [512 x i32]* %99 to i32**
%101 = load i32, i32* %2
%102 = load i32, i32* %3
%103 = load i32, i32* %4
%104 = call i32 @konturowanie(i32** %100, i32 %101, i32 %102, i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0))
br label %123
106: ; preds = %16
%107 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%108 = bitcast [512 x i32]* %107 to i32**
%109 = load i32, i32* %2
%110 = load i32, i32* %3
%111 = call i32 @filtr(i32** %108, i32 %109, i32 %110)
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.23, i64 0, i64 0))
br label %123
113: ; preds = %16
%114 = getelementptr inbounds [512 x [512 x i32]], [512 x [512 x i32]]* %6, i64 0, i64 0
%115 = bitcast [512 x i32]* %114 to i32**
%116 = load i32, i32* %2
%117 = load i32, i32* %3
%118 = load i32, i32* %4
%119 = call i32 @filtr2(i32** %115, i32 %116, i32 %117, i32 %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.24, i64 0, i64 0))
br label %123
121: ; preds = %16
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.25, i64 0, i64 0))
br label %123
123: ; preds = %121, %16, %113, %106, %98, %86, %78, %75, %72, %48
br label %12
124: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str.10 = [3 x i8] c"%c\00"
@.str.12 = [3 x i8] c"%s\00"
@.str.13 = [2 x i8] c"r\00"
@.str.16 = [2 x i8] c"w\00"
@.str.20 = [3 x i8] c"%i\00"
@.str.21 = [45 x i8] c"Progowanie obrazu przy progu %i zakonczone.\0A\00"
@str = [25 x i8] c"----------MENU----------\00"
@str.26 = [29 x i8] c"1 - wczytanie obrazu z pliku\00"
@str.27 = [30 x i8] c"2 - zapisanie obrazu do pliku\00"
@str.28 = [24 x i8] c"3 - wyswietlanie obrazu\00"
@str.29 = [12 x i8] c"4 - negatyw\00"
@str.30 = [15 x i8] c"5 - progowanie\00"
@str.31 = [17 x i8] c"6 - konturowanie\00"
@str.32 = [39 x i8] c"7 - filtr usredniajacy ze wzmocnieniem\00"
@str.33 = [47 x i8] c"8 - filtrowanie przy uzyciu gradientu Robertsa\00"
@str.34 = [35 x i8] c"0 - zakonczenie dzialania programu\00"
@str.35 = [13 x i8] c"Milego dnia!\00"
@str.36 = [60 x i8] c"Obraz zostal przefiltrowany przy pomocy gradientu Robertsa.\00"
@str.37 = [79 x i8] c"Obraz zostal przefiltrowany przy uzyciu filtra usredniajacego ze wzmocnieniem.\00"
@str.38 = [32 x i8] c"Konturowanie obrazu zakonczone.\00"
@str.39 = [12 x i8] c"Podaj prog:\00"
@str.40 = [26 x i8] c"Utworzono negatyw obrazu.\00"
@str.41 = [29 x i8] c"Podaj nazwe pliku do zapisu:\00"
@str.42 = [35 x i8] c"Zapis obrazu do pliku powiodl sie.\00"
@str.43 = [19 x i8] c"Podaj nazwe pliku:\00"
@str.44 = [33 x i8] c"Wczytywanie obrazu powiodlo sie.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [512 x [512 x i32]]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca i8
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast [512 x [512 x i32]]* %5 to i8*
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
store i8 97, i8* %8
%16 = bitcast [512 x [512 x i32]]* %5 to i32**
br label %17
17: ; preds = %0, %103
%18 = phi i32 [ 0, %0 ], [ %105, %103 ]
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.26, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.27, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.28, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.29, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.30, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.31, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.32, i64 0, i64 0))
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.33, i64 0, i64 0))
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.34, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %8)
%30 = load i8, i8* %8
%31 = sext i8 %30 to i32
switch i32 %31, label %103 [
i32 49, label %32
i32 50, label %46
i32 51, label %63
i32 52, label %65
i32 53, label %71
i32 54, label %81
i32 55, label %87
i32 56, label %92
i32 48, label %98
]
32: ; preds = %17
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.43, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %14)
%35 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %39, label %37
37: ; preds = %32
%38 = call i32 @czytaj(i32* %35, i32** %16, i32* %1, i32* %2, i32* %3)
br label %39
39: ; preds = %37, %32
%40 = phi i32 [ %38, %37 ], [ %18, %32 ]
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.44, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
%45 = call i32 @fclose(i32* %35)
br label %100
46: ; preds = %17
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.41, i64 0, i64 0))
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %15)
%49 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%50 = icmp eq i32* %49, null
br i1 %50, label %56, label %51
51: ; preds = %46
%52 = load i32, i32* %1
%53 = load i32, i32* %2
%54 = load i32, i32* %3
%55 = call i32 @zapisz(i32* %49, i32** %16, i32 %52, i32 %53, i32 %54)
br label %56
56: ; preds = %51, %46
%57 = phi i32 [ %55, %51 ], [ %18, %46 ]
%58 = icmp eq i32 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.42, i64 0, i64 0))
br label %61
61: ; preds = %59, %56
%62 = call i32 @fclose(i32* %49)
br label %100
63: ; preds = %17
%64 = call i32 @wyswietl(i8* %14)
br label %100
65: ; preds = %17
%66 = load i32, i32* %1
%67 = load i32, i32* %2
%68 = load i32, i32* %3
%69 = call i32 @negatyw(i32** %16, i32 %66, i32 %67, i32 %68)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.40, i64 0, i64 0))
br label %100
71: ; preds = %17
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.39, i64 0, i64 0))
%73 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0), i32* %4)
%74 = load i32, i32* %1
%75 = load i32, i32* %2
%76 = load i32, i32* %3
%77 = load i32, i32* %4
%78 = call i32 @progowanie(i32** %16, i32 %74, i32 %75, i32 %76, i32 %77)
%79 = load i32, i32* %4
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.21, i64 0, i64 0), i32 %79)
br label %100
81: ; preds = %17
%82 = load i32, i32* %1
%83 = load i32, i32* %2
%84 = load i32, i32* %3
%85 = call i32 @konturowanie(i32** %16, i32 %82, i32 %83, i32 %84)
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.38, i64 0, i64 0))
br label %100
87: ; preds = %17
%88 = load i32, i32* %1
%89 = load i32, i32* %2
%90 = call i32 @filtr(i32** %16, i32 %88, i32 %89)
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str.37, i64 0, i64 0))
br label %100
92: ; preds = %17
%93 = load i32, i32* %1
%94 = load i32, i32* %2
%95 = load i32, i32* %3
%96 = call i32 @filtr2(i32** %16, i32 %93, i32 %94, i32 %95)
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.36, i64 0, i64 0))
br label %100
98: ; preds = %17
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.35, i64 0, i64 0))
br label %100
100: ; preds = %44, %61, %63, %65, %71, %81, %87, %92, %98
%101 = phi i32 [ %40, %44 ], [ %57, %61 ], [ %18, %63 ], [ %18, %65 ], [ %18, %71 ], [ %18, %81 ], [ %18, %87 ], [ %18, %92 ], [ %18, %98 ]
%102 = load i8, i8* %8
br label %103
103: ; preds = %100, %17
%104 = phi i8 [ %102, %100 ], [ %30, %17 ]
%105 = phi i32 [ %101, %100 ], [ %18, %17 ]
%106 = icmp eq i8 %104, 48
br i1 %106, label %107, label %17
107: ; preds = %103
ret i32 0
}