#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();
char tolower(char);
int /*<<< orphan*/ utworz_spis(char *);
int /*<<< orphan*/ znajdz_imie(char *, char *, int *);
int /*<<< orphan*/ znajdz_nazwisko(char *, char *, int *);
int main(int argc, char *argv[]) {
  char odpowiedz, im[15 + 1], na[10 + 1];
  int p;
  utworz_spis(argv[1]);
  sortuj_spis();
  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", na);
      break;
    case 'q':
      break;
    default:
      printf(" Poprawne odpowiedzi: N, I, Q.\n");
    }
  } while (tolower(odpowiedz) != 'q');
  printf("\n DZIEKUJE.\n\n");
  return 0;
}


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>
lea    0xe3f(%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    11c8 <main+0x38>
movsbl -0x11(%rbp),%edi
call   10a0 <tolower@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x69,%eax
je     1228 <main+0x98>
jmp    1206 <main+0x76>
mov    -0x44(%rbp),%eax
sub    $0x6e,%eax
je     1295 <main+0x105>
jmp    1217 <main+0x87>
mov    -0x44(%rbp),%eax
sub    $0x71,%eax
je     1302 <main+0x172>
jmp    1307 <main+0x177>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   10b0 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x3b(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <znajdz_imie@plt>
cmp    $0x0,%eax
je     127e <main+0xee>
lea    -0x30(%rbp),%rsi
lea    -0x3b(%rbp),%rdx
mov    -0x40(%rbp),%ecx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1290 <main+0x100>
lea    -0x30(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1315 <main+0x185>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x3b(%rbp),%rsi
lea    0xd9f(%rip),%rdi
call   10b0 <scanf@plt>
lea    -0x3b(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <znajdz_nazwisko@plt>
cmp    $0x0,%eax
je     12eb <main+0x15b>
lea    -0x30(%rbp),%rsi
lea    -0x3b(%rbp),%rdx
mov    -0x40(%rbp),%ecx
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12fd <main+0x16d>
lea    -0x3b(%rbp),%rsi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1315 <main+0x185>
jmp    1315 <main+0x185>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    131a <main+0x18a>
movsbl -0x11(%rbp),%edi
call   10a0 <tolower@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    11ba <main+0x2a>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%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>
lea    0xe3b(%rip),%r12
lea    0x5(%rsp),%rbx
lea    0x10(%rsp),%r13
mov    %rsp,%r15
jmp    123a <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe58(%rip),%rdi
mov    %r13,%rsi
call   10c0 <scanf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <znajdz_imie@plt>
test   %eax,%eax
je     12df <main+0x13f>
mov    (%rsp),%ecx
lea    0xe33(%rip),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14d,%edi
call   10b0 <tolower@plt>
cmp    $0x71,%al
je     12f5 <main+0x155>
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    1250 <main+0xb0>
mov    %ebp,%edi
call   10b0 <tolower@plt>
movsbl %al,%r14d
cmp    $0x71,%r14d
je     122a <main+0x8a>
cmp    $0x6e,%r14d
je     12a0 <main+0x100>
cmp    $0x69,%r14d
je     11e0 <main+0x40>
lea    0xe32(%rip),%rdi
call   1050 <puts@plt>
jmp    122a <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd98(%rip),%rdi
mov    %rbx,%rsi
call   10c0 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1070 <znajdz_nazwisko@plt>
test   %eax,%eax
jne    1213 <main+0x73>
lea    0xdc4(%rip),%rdi
mov    %rbx,%rsi
jmp    12e9 <main+0x149>
lea    0xd8f(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    122a <main+0x8a>
lea    0xdb7(%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()
br label %15
15: ; preds = %66, %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %19, %15
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %6
br label %19
19: ; preds = %17
%20 = load i8, i8* %6
%21 = call i64 @isspace(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %17, label %23
23: ; preds = %19
%24 = load i8, i8* %6
%25 = call signext i8 @tolower(i8 signext %24)
store i8 %25, i8* %6
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
switch i32 %27, label %63 [
i32 105, label %28
i32 110, label %45
i32 113, label %62
]
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%33 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%34 = call i32 @znajdz_imie(i8* %32, i8* %33, i32* %9)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %28
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%39 = load i32, i32* %9
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %37, i8* %38, i32 %39)
br label %44
41: ; preds = %28
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %36
br label %65
45: ; preds = %23
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%47 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%48 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%51 = call i32 @znajdz_nazwisko(i8* %49, i8* %50, i32* %9)
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %45
%54 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%55 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%56 = load i32, i32* %9
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %54, i8* %55, i32 %56)
br label %61
58: ; preds = %45
%59 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %58, %53
br label %65
62: ; preds = %23
br label %65
63: ; preds = %23
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
br label %65
65: ; preds = %63, %62, %61, %44
br label %66
66: ; preds = %65
%67 = load i8, i8* %6
%68 = call signext i8 @tolower(i8 signext %67)
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 113
br i1 %70, label %15, label %71
71: ; preds = %66
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

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()
br label %13
13: ; preds = %44, %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %15, %13
%16 = call signext i8 (...) @getchar()
%17 = call i64 @isspace(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %15
19: ; preds = %15
%20 = call signext i8 @tolower(i8 signext %16)
%21 = sext i8 %20 to i32
switch i32 %21, label %42 [
i32 105, label %22
i32 110, label %32
i32 113, label %44
]
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%25 = call i32 @znajdz_imie(i8* %6, i8* %7, i32* %5)
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = load i32, i32* %5
%29 = 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 %28)
br label %44
30: ; preds = %22
%31 = 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 %44
32: ; preds = %19
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%35 = call i32 @znajdz_nazwisko(i8* %7, i8* %6, i32* %5)
%36 = icmp eq i32 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = load i32, i32* %5
%39 = 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 %38)
br label %44
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %7)
br label %44
42: ; preds = %19
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
br label %44
44: ; preds = %19, %42, %30, %27, %40, %37
%45 = call signext i8 @tolower(i8 signext %20)
%46 = icmp eq i8 %45, 113
br i1 %46, label %47, label %13
47: ; preds = %44
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
ret i32 0
}