#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 */
char getchar();
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sortuj_spis();
int /*<<< orphan*/ spis_do_pliku();
char tolower(char);
int /*<<< orphan*/ utworz_spis(char *);
int /*<<< orphan*/ znajdz_imie(char *, char *, int *);
int /*<<< orphan*/ znajdz_nazwisko(char *, char *, int *);
main(int argc, char *argv[]) {
  char odpowiedz, im[15 + 1], na[10 + 1];
  int p;
  utworz_spis(argv[1]);
  sortuj_spis();
  spis_do_pliku();
  do {
    printf("\n Znalezc wg imienia (I), nazwiska (N), czy zakonczyc (Q)? ");
    do {
      odpowiedz = getchar();
    } while (isspace(odpowiedz));
    odpowiedz = tolower(odpowiedz);
    switch (odpowiedz) {
    case 'i':
      printf("\n szukane imie: ");
      scanf("%s", im);
      if (znajdz_imie(im, na, &p))
        printf(" IMIE: %s, NAZWISKO: %s, PENSJA: %i\n", im, na, p);
      else
        printf(" nie ma imienia %s\n", im);
      break;
    case 'n':
      printf("\n szukane nazwisko: ");
      scanf("%s", na);
      if (znajdz_nazwisko(na, im, &p))
        printf(" IMIE: %s, NAZWISKO: %s, PENSJA: %i\n", im, na, p);
      else
        printf(" nie ma nazwiska %s\n", im);
      break;
    case 'q':
      break;
    default:
      printf(" Poprawne odpowiedzi: N, I, Q.\n");
    }
  } while (tolower(odpowiedz) != 'q');
  printf("\n DZIEKUJE.\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <utworz_spis@plt>
mov    $0x0,%al
call   1050 <sortuj_spis@plt>
mov    $0x0,%al
call   10a0 <spis_do_pliku@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1080 <isspace@plt>
cmp    $0x0,%rax
jne    11df <main+0x3f>
movsbl -0x11(%rbp),%edi
call   10b0 <tolower@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x69,%eax
je     123f <main+0x9f>
jmp    121d <main+0x7d>
mov    -0x44(%rbp),%eax
sub    $0x6e,%eax
je     12ac <main+0x10c>
jmp    122e <main+0x8e>
mov    -0x44(%rbp),%eax
sub    $0x71,%eax
je     1319 <main+0x179>
jmp    131e <main+0x17e>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xdf5(%rip),%rdi
call   10c0 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x3b(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <znajdz_imie@plt>
cmp    $0x0,%eax
je     1295 <main+0xf5>
lea    -0x30(%rbp),%rsi
lea    -0x3b(%rbp),%rdx
mov    -0x40(%rbp),%ecx
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12a7 <main+0x107>
lea    -0x30(%rbp),%rsi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    132c <main+0x18c>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x3b(%rbp),%rsi
lea    0xd88(%rip),%rdi
call   10c0 <scanf@plt>
lea    -0x3b(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <znajdz_nazwisko@plt>
cmp    $0x0,%eax
je     1302 <main+0x162>
lea    -0x30(%rbp),%rsi
lea    -0x3b(%rbp),%rdx
mov    -0x40(%rbp),%ecx
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1314 <main+0x174>
lea    -0x30(%rbp),%rsi
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    132c <main+0x18c>
jmp    132c <main+0x18c>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1331 <main+0x191>
movsbl -0x11(%rbp),%edi
call   10b0 <tolower@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    11d1 <main+0x31>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x8(%rsi),%rdi
call   1030 <utworz_spis@plt>
xor    %eax,%eax
call   1060 <sortuj_spis@plt>
xor    %eax,%eax
call   10b0 <spis_do_pliku@plt>
lea    0xe24(%rip),%r12
lea    0x5(%rsp),%r13
lea    0x10(%rsp),%rbx
mov    %rsp,%r15
jmp    124a <main+0x9a>
nopl   0x0(%rax,%rax,1)
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe48(%rip),%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <znajdz_imie@plt>
test   %eax,%eax
je     12ec <main+0x13c>
mov    (%rsp),%ecx
lea    0xe23(%rip),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14d,%edi
call   10c0 <tolower@plt>
cmp    $0x71,%al
je     1302 <main+0x152>
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   10a0 <getchar@plt>
movsbl %al,%ebp
mov    %ebp,%edi
call   1090 <isspace@plt>
test   %rax,%rax
jne    1260 <main+0xb0>
mov    %ebp,%edi
call   10c0 <tolower@plt>
movsbl %al,%r14d
cmp    $0x71,%r14d
je     123a <main+0x8a>
cmp    $0x6e,%r14d
je     12b0 <main+0x100>
cmp    $0x69,%r14d
je     11f0 <main+0x40>
lea    0xe22(%rip),%rdi
call   1050 <puts@plt>
jmp    123a <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd88(%rip),%rdi
mov    %r13,%rsi
call   10d0 <scanf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <znajdz_nazwisko@plt>
test   %eax,%eax
jne    1223 <main+0x73>
lea    0xdb4(%rip),%rdi
jmp    12f3 <main+0x143>
lea    0xd82(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    123a <main+0x8a>
lea    0xdaa(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"\0A Znalezc wg imienia (I), nazwiska (N), czy zakonczyc (Q)? \00"
@.str.1 = [17 x i8] c"\0A szukane imie: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [37 x i8] c" IMIE: %s, NAZWISKO: %s, PENSJA: %i\0A\00"
@.str.4 = [20 x i8] c" nie ma imienia %s\0A\00"
@.str.5 = [21 x i8] c"\0A szukane nazwisko: \00"
@.str.6 = [21 x i8] c" nie ma nazwiska %s\0A\00"
@.str.7 = [32 x i8] c" Poprawne odpowiedzi: N, I, Q.\0A\00"
@.str.8 = [14 x i8] c"\0A DZIEKUJE.\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca [16 x i8]
%8 = alloca [11 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @utworz_spis(i8* %12)
%14 = call i32 (...) @sortuj_spis()
%15 = call i32 (...) @spis_do_pliku()
br label %16
16: ; preds = %67, %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %20, %16
%19 = call signext i8 (...) @getchar()
store i8 %19, i8* %6
br label %20
20: ; preds = %18
%21 = load i8, i8* %6
%22 = call i64 @isspace(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %18, label %24
24: ; preds = %20
%25 = load i8, i8* %6
%26 = call signext i8 @tolower(i8 signext %25)
store i8 %26, i8* %6
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
switch i32 %28, label %64 [
i32 105, label %29
i32 110, label %46
i32 113, label %63
]
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%35 = call i32 @znajdz_imie(i8* %33, i8* %34, i32* %9)
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %29
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%39 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%40 = load i32, i32* %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %39, i32 %40)
br label %45
42: ; preds = %29
%43 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %37
br label %66
46: ; preds = %24
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%48 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%52 = call i32 @znajdz_nazwisko(i8* %50, i8* %51, i32* %9)
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %46
%55 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%56 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%57 = load i32, i32* %9
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %55, i8* %56, i32 %57)
br label %62
59: ; preds = %46
%60 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %54
br label %66
63: ; preds = %24
br label %66
64: ; preds = %24
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %64, %63, %62, %45
br label %67
67: ; preds = %66
%68 = load i8, i8* %6
%69 = call signext i8 @tolower(i8 signext %68)
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 113
br i1 %71, label %16, label %72
72: ; preds = %67
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [60 x i8] c"\0A Znalezc wg imienia (I), nazwiska (N), czy zakonczyc (Q)? \00"
@.str.1 = [17 x i8] c"\0A szukane imie: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [37 x i8] c" IMIE: %s, NAZWISKO: %s, PENSJA: %i\0A\00"
@.str.4 = [20 x i8] c" nie ma imienia %s\0A\00"
@.str.5 = [21 x i8] c"\0A szukane nazwisko: \00"
@.str.6 = [21 x i8] c" nie ma nazwiska %s\0A\00"
@str = [13 x i8] c"\0A DZIEKUJE.\0A\00"
@str.9 = [31 x i8] c" Poprawne odpowiedzi: N, I, Q.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = alloca [11 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @utworz_spis(i8* %10)
%12 = tail call i32 (...) @sortuj_spis()
%13 = tail call i32 (...) @spis_do_pliku()
br label %14
14: ; preds = %45, %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %16, %14
%17 = call signext i8 (...) @getchar()
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %16
%21 = call signext i8 @tolower(i8 signext %17)
%22 = sext i8 %21 to i32
switch i32 %22, label %43 [
i32 105, label %23
i32 110, label %33
i32 113, label %45
]
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%26 = call i32 @znajdz_imie(i8* %6, i8* %7, i32* %5)
%27 = icmp eq i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %7, i32 %29)
br label %45
31: ; preds = %23
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %6)
br label %45
33: ; preds = %20
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%36 = call i32 @znajdz_nazwisko(i8* %7, i8* %6, i32* %5)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %33
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %7, i32 %39)
br label %45
41: ; preds = %33
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %6)
br label %45
43: ; preds = %20
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
br label %45
45: ; preds = %20, %43, %31, %28, %41, %38
%46 = call signext i8 @tolower(i8 signext %21)
%47 = icmp eq i8 %46, 113
br i1 %47, label %48, label %14
48: ; preds = %45
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
ret i32 0
}