#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();
int /*<<< orphan*/ znajdz_imie(char *, char *, int *);
int /*<<< orphan*/ znajdz_nazwisko(char *, char *, int *);
int main() {
  char odpowiedz, im[15 + 1], na[15 + 1];
  int p;
  utworz_spis();
  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", 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    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <utworz_spis@plt>
mov    $0x0,%al
call   1050 <sortuj_spis@plt>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1080 <isspace@plt>
cmp    $0x0,%rax
jne    11bb <main+0x2b>
movsbl -0x5(%rbp),%edi
call   10a0 <tolower@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x69,%eax
je     121b <main+0x8b>
jmp    11f9 <main+0x69>
mov    -0x38(%rbp),%eax
sub    $0x6e,%eax
je     1288 <main+0xf8>
jmp    120a <main+0x7a>
mov    -0x38(%rbp),%eax
sub    $0x71,%eax
je     12f5 <main+0x165>
jmp    12fa <main+0x16a>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   10b0 <scanf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1040 <znajdz_imie@plt>
cmp    $0x0,%eax
je     1271 <main+0xe1>
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1283 <main+0xf3>
lea    -0x20(%rbp),%rsi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1308 <main+0x178>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xdac(%rip),%rdi
call   10b0 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1060 <znajdz_nazwisko@plt>
cmp    $0x0,%eax
je     12de <main+0x14e>
lea    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12f0 <main+0x160>
lea    -0x20(%rbp),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1308 <main+0x178>
jmp    1308 <main+0x178>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    130d <main+0x17d>
movsbl -0x5(%rbp),%edi
call   10a0 <tolower@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    11ad <main+0x1d>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1030 <utworz_spis@plt>
xor    %eax,%eax
call   1060 <sortuj_spis@plt>
lea    0xe3d(%rip),%r12
lea    0x10(%rsp),%r13
lea    0x20(%rsp),%rbx
lea    0xc(%rsp),%r15
jmp    123b <main+0x9b>
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    %rbx,%rsi
call   10c0 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <znajdz_imie@plt>
test   %eax,%eax
je     12dc <main+0x13c>
mov    0xc(%rsp),%ecx
lea    0xe32(%rip),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14d,%edi
call   10b0 <tolower@plt>
cmp    $0x71,%al
je     12f2 <main+0x152>
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
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     122b <main+0x8b>
cmp    $0x6e,%r14d
je     12a0 <main+0x100>
cmp    $0x69,%r14d
je     11e0 <main+0x40>
lea    0xe32(%rip),%rdi
call   1050 <puts@plt>
jmp    122b <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd98(%rip),%rdi
mov    %r13,%rsi
call   10c0 <scanf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <znajdz_nazwisko@plt>
test   %eax,%eax
jne    1213 <main+0x73>
lea    0xdc4(%rip),%rdi
jmp    12e3 <main+0x143>
lea    0xd92(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    122b <main+0x8b>
lea    0xdba(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x38,%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() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @utworz_spis()
%7 = call i32 (...) @sortuj_spis()
br label %8
8: ; preds = %59, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %12, %8
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %2
br label %12
12: ; preds = %10
%13 = load i8, i8* %2
%14 = call i64 @isspace(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %12
%17 = load i8, i8* %2
%18 = call signext i8 @tolower(i8 signext %17)
store i8 %18, i8* %2
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
switch i32 %20, label %56 [
i32 105, label %21
i32 110, label %38
i32 113, label %55
]
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%27 = call i32 @znajdz_imie(i8* %25, i8* %26, i32* %5)
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %21
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %31, i32 %32)
br label %37
34: ; preds = %21
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %29
br label %58
38: ; preds = %16
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%43 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%44 = call i32 @znajdz_nazwisko(i8* %42, i8* %43, i32* %5)
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %38
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%48 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%49 = load i32, i32* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %47, i8* %48, i32 %49)
br label %54
51: ; preds = %38
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51, %46
br label %58
55: ; preds = %16
br label %58
56: ; preds = %16
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
br label %58
58: ; preds = %56, %55, %54, %37
br label %59
59: ; preds = %58
%60 = load i8, i8* %2
%61 = call signext i8 @tolower(i8 signext %60)
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 113
br i1 %63, label %8, label %64
64: ; preds = %59
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%66 = load i32, i32* %1
ret i32 %66
}

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