#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*/ uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ECANCELED;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ errors_1p(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                             int, int /*<<< orphan*/, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
size_t fread(void *, int /*<<< orphan*/, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void read_item(FILE *pk, void *item, uint32_t size, size_t cant) {
  if (fread(item, size, cant, pk) < cant) {
    if (feof(pk)) {
      errno = ECANCELED;
      fprintf(stderr,
              "ERROR Incorrect format of the file of input: The file needs "
              "more than the header\n%s\n",
              strerror(errno));
      fclose(pk);
      exit(14);
    } else
      errors_1p(pk, NULL, "Error reading the file", 2, 0, 1);
  }
}


x86 assembly (clang, -O0):
<read_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rcx
call   1040 <fread@plt>
cmp    -0x20(%rbp),%rax
jae    1230 <read_item+0xc0>
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     1209 <read_item+0x99>
mov    0x2e29(%rip),%rax
mov    (%rax),%ecx
mov    0x2e08(%rip),%rax
mov    %ecx,(%rax)
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe0f(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0xe,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    0xe3d(%rip),%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1030 <errors_1p@plt>
jmp    1230 <read_item+0xc0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_item>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    %rbx,%rax
jae    11c2 <read_item+0x52>
mov    %r14,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    11ca <read_item+0x5a>
lea    0xeb2(%rip),%rdx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <errors_1p@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
mov    0x2df6(%rip),%rax
mov    %edi,(%rax)
mov    0x2df5(%rip),%rax
mov    (%rax),%ebx
call   1090 <strerror@plt>
lea    0xe0f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    $0xe,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@ECANCELED = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [85 x i8] c"ERROR Incorrect format of the file of input: The file needs more than the header\0A%s\0A\00"
@.str.1 = [23 x i8] c"Error reading the file\00"
define void @read_item(i32* %0, i8* %1, i32 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i64 %3, i64* %8
%9 = load i8*, i8** %6
%10 = load i32, i32* %7
%11 = load i64, i64* %8
%12 = load i32*, i32** %5
%13 = call i64 @fread(i8* %9, i32 %10, i64 %11, i32* %12)
%14 = load i64, i64* %8
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %4
%17 = load i32*, i32** %5
%18 = call i64 @feof(i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i32, i32* @ECANCELED
store i32 %21, i32* @errno
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32*, i32** %5
%27 = call i32 @fclose(i32* %26)
%28 = call i32 @exit(i32 14)
unreachable
29: ; preds = %16
%30 = load i32*, i32** %5
%31 = call i32 @errors_1p(i32* %30, i32* null, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i32 1)
br label %32
32: ; preds = %29
br label %33
33: ; preds = %32, %4
ret void
}

LLVM IR (-O2):
@ECANCELED = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str = [85 x i8] c"ERROR Incorrect format of the file of input: The file needs more than the header\0A%s\0A\00"
@.str.1 = [23 x i8] c"Error reading the file\00"
define void @read_item(i32* %0, i8* nocapture %1, i32 %2, i64 %3) {
%5 = tail call i64 @fread(i8* %1, i32 %2, i64 %3, i32* %0)
%6 = icmp ult i64 %5, %3
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = tail call i64 @feof(i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = load i32, i32* @ECANCELED
store i32 %11, i32* @errno
%12 = load i32, i32* @stderr
%13 = tail call i8* @strerror(i32 %11)
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @fclose(i32* %0)
%16 = tail call i32 @exit(i32 14)
unreachable
17: ; preds = %7
%18 = tail call i32 @errors_1p(i32* %0, i32* null, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i32 1)
br label %19
19: ; preds = %17, %4
ret void
}