#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *,
                           char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, char *, char *);
int /*<<< orphan*/ printf(char *);
int main() {
  char prezime[15], ime[15], reg[10];
  FILE *fUlaz, *fIzlaz;
  if ((fUlaz = fopen("auto.txt", "r")) == NULL) {
    printf("Greska prilikom otvaranja datoteke");
    exit(1);
  }
  if ((fIzlaz = fopen("auto88.txt", "w")) == NULL) {
    fclose(fUlaz);
    printf("Greska prilikom otvaranja datoteke");
    exit(1);
  }
  while (fscanf(fUlaz, "%15s%15s%9s", prezime, ime, reg) == 3) {
    int br8 = 0, i;
    char *preg = reg;
    for (i = 0; i < 9; i++) {
      if (*preg == '8')
        br8++;
      preg++;
    }
    if (br8 == 2)
      fprintf(fIzlaz, "%-15s%-15s%-9s\n", prezime, ime, reg);
  }
  fclose(fUlaz);
  fclose(fIzlaz);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11a6 <main+0x46>
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe81(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    11e6 <main+0x86>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11eb <main+0x8b>
mov    -0x38(%rbp),%rdi
lea    -0x13(%rbp),%rdx
lea    -0x22(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    0xe39(%rip),%rsi
call   1050 <fscanf@plt>
cmp    $0x3,%eax
jne    128e <main+0x12e>
movl   $0x0,-0x44(%rbp)
lea    -0x2c(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x48(%rbp)
cmpl   $0x9,-0x48(%rbp)
jge    1263 <main+0x103>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x38,%eax
jne    1249 <main+0xe9>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1226 <main+0xc6>
cmpl   $0x2,-0x44(%rbp)
jne    1289 <main+0x129>
mov    -0x40(%rbp),%rdi
lea    -0x13(%rbp),%rdx
lea    -0x22(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    0xdc3(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11eb <main+0x8b>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@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
lea    0xe9b(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1291 <main+0x131>
mov    %rax,%rbx
lea    0xeaa(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1289 <main+0x129>
mov    %rax,%r14
lea    0xe98(%rip),%rsi
lea    0x19(%rsp),%rdx
lea    0xa(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
call   1050 <fscanf@plt>
cmp    $0x3,%eax
jne    1268 <main+0x108>
lea    0x19(%rsp),%r12
lea    0xa(%rsp),%r13
mov    %rsp,%rbp
lea    0xe66(%rip),%r15
jmp    1209 <main+0xa9>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1050 <fscanf@plt>
cmp    $0x3,%eax
jne    1268 <main+0x108>
movq   (%rsp),%xmm0
xor    %eax,%eax
cmpb   $0x38,0x8(%rsp)
pcmpeqb 0xde3(%rip),%xmm0
sete   %al
pmovmskb %xmm0,%ecx
mov    %ecx,%edx
shr    %dl
and    $0x55,%dl
sub    %dl,%cl
mov    %ecx,%edx
and    $0x33,%dl
shr    $0x2,%cl
and    $0x33,%cl
add    %dl,%cl
mov    %ecx,%edx
shr    $0x4,%dl
add    %cl,%dl
and    $0xf,%dl
movzbl %dl,%ecx
add    %eax,%ecx
cmp    $0x2,%ecx
jne    11f0 <main+0x90>
mov    %r14,%rdi
lea    0xdff(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1060 <fprintf@plt>
jmp    11f0 <main+0x90>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"auto.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [35 x i8] c"Greska prilikom otvaranja datoteke\00"
@.str.3 = [11 x i8] c"auto88.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [12 x i8] c"%15s%15s%9s\00"
@.str.6 = [16 x i8] c"%-15s%-15s%-9s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca [15 x i8]
%4 = alloca [10 x i8]
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %5
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %16, i32** %6
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32*, i32** %5
%20 = call i32 @fclose(i32* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %15
br label %24
24: ; preds = %59, %23
%25 = load i32*, i32** %5
%26 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%27 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%29 = call i32 @fscanf(i32* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %26, i8* %27, i8* %28)
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %60
31: ; preds = %24
store i32 0, i32* %7
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i8* %32, i8** %9
store i32 0, i32* %8
br label %33
33: ; preds = %47, %31
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 9
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load i8*, i8** %9
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 56
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %44
44: ; preds = %41, %36
%45 = load i8*, i8** %9
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %9
br label %47
47: ; preds = %44
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %33
50: ; preds = %33
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 2
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = load i32*, i32** %6
%55 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%56 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%58 = call i32 @fprintf(i32* %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %55, i8* %56, i8* %57)
br label %59
59: ; preds = %53, %50
br label %24
60: ; preds = %24
%61 = load i32*, i32** %5
%62 = call i32 @fclose(i32* %61)
%63 = load i32*, i32** %6
%64 = call i32 @fclose(i32* %63)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"auto.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [35 x i8] c"Greska prilikom otvaranja datoteke\00"
@.str.3 = [11 x i8] c"auto88.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [12 x i8] c"%15s%15s%9s\00"
@.str.6 = [16 x i8] c"%-15s%-15s%-9s\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca [15 x i8]
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %41
18: ; preds = %15
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
%20 = bitcast [10 x i8]* %3 to <8 x i8>*
br label %25
21: ; preds = %12
%22 = tail call i32 @fclose(i32* %7)
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %18, %38
%26 = load <8 x i8>, <8 x i8>* %20
%27 = icmp eq <8 x i8> %26, <i8 56, i8 56, i8 56, i8 56, i8 56, i8 56, i8 56, i8 56>
%28 = load i8, i8* %19
%29 = icmp eq i8 %28, 56
%30 = zext i1 %29 to i32
%31 = bitcast <8 x i1> %27 to i8
%32 = call i8 @llvm.ctpop.i8(i8 %31)
%33 = zext i8 %32 to i32
%34 = add nuw nsw i32 %33, %30
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
br label %38
38: ; preds = %36, %25
%39 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* %5, i8* %6)
%40 = icmp eq i32 %39, 3
br i1 %40, label %25, label %41
41: ; preds = %38, %15
%42 = call i32 @fclose(i32* %7)
%43 = call i32 @fclose(i32* %13)
ret i32 0
}