#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, char *, int *);
int ile_linii(char *plik) {
  int licznik = 0;
  char imiepom[11];
  char nazwiskopom[17];
  int pensjapom = 0;
  FILE *fp = fopen(plik, "r");
  if (fp == NULL) {
    fclose(fp);
    return 0;
  } else {
    while ((fscanf(fp, "%s %s %d", imiepom, nazwiskopom, &pensjapom)) != EOF)
      licznik++;
  }
  fclose(fp);
  return licznik;
}


x86 assembly (clang, -O0):
<ile_linii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    117e <ile_linii+0x4e>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <ile_linii+0xa1>
jmp    1183 <ile_linii+0x53>
mov    -0x40(%rbp),%rdi
lea    -0x1f(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    0xe6c(%rip),%rsi
lea    -0x34(%rbp),%r8
call   1040 <fscanf@plt>
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%rax
je     11bd <ile_linii+0x8d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <ile_linii+0x53>
jmp    11c2 <ile_linii+0x92>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ile_linii>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,(%rsp)
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a5 <ile_linii+0x75>
mov    %rax,%r14
mov    $0xffffffff,%ebx
lea    0x5(%rsp),%r12
lea    0x10(%rsp),%r13
mov    %rsp,%rbp
mov    0x2e76(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
lea    0xe78(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1040 <fscanf@plt>
add    $0x1,%ebx
cmp    (%r15),%rax
jne    1180 <ile_linii+0x50>
mov    %r14,%rdi
jmp    11a9 <ile_linii+0x79>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <fclose@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%s %s %d\00"
@EOF = global i64 0
define i32 @ile_linii(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [11 x i8]
%6 = alloca [17 x i8]
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %7
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %8
%11 = load i32*, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32*, i32** %8
%15 = call i32 @fclose(i32* %14)
store i32 0, i32* %2
br label %32
16: ; preds = %1
br label %17
17: ; preds = %24, %16
%18 = load i32*, i32** %8
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%21 = call i64 @fscanf(i32* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20, i32* %7)
%22 = load i64, i64* @EOF
%23 = icmp ne i64 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %17
27: ; preds = %17
br label %28
28: ; preds = %27
%29 = load i32*, i32** %8
%30 = call i32 @fclose(i32* %29)
%31 = load i32, i32* %4
store i32 %31, i32* %2
br label %32
32: ; preds = %28, %13
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%s %s %d\00"
@EOF = global i64 0
define i32 @ile_linii(i8* nocapture %0) {
%2 = alloca [11 x i8]
%3 = alloca [17 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 @fclose(i32* null)
br label %20
12: ; preds = %1, %12
%13 = phi i32 [ %17, %12 ], [ 0, %1 ]
%14 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %6, i32* %4)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
%17 = add nuw nsw i32 %13, 1
br i1 %16, label %18, label %12
18: ; preds = %12
%19 = call i32 @fclose(i32* %8)
br label %20
20: ; preds = %18, %10
%21 = phi i32 [ 0, %10 ], [ %13, %18 ]
ret i32 %21
}