#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fwrite(void *, int /*<<< orphan*/, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void write_item(FILE *pk, void *item, uint32_t size, size_t cant) {
  if (fwrite(item, size, cant, pk) == 0) {
    fprintf(stderr, "Error writing the file: %s\n", strerror(errno));
    fclose(pk);
    exit(3);
  }
}


x86 assembly (clang, -O0):
<write_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   1060 <fwrite@plt>
cmp    $0x0,%rax
jne    11c4 <write_item+0x74>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_item>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
test   %rax,%rax
je     1172 <write_item+0x22>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e67(%rip),%rax
mov    (%rax),%ebp
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe70(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Error writing the file: %s\0A\00"
@errno = global i32 0
define void @write_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 @fwrite(i8* %9, i32 %10, i64 %11, i32* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32*, i32** %5
%21 = call i32 @fclose(i32* %20)
%22 = call i32 @exit(i32 3)
unreachable
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Error writing the file: %s\0A\00"
@errno = global i32 0
define void @write_item(i32* nocapture %0, i8* nocapture %1, i32 %2, i64 %3) {
%5 = tail call i64 @fwrite(i8* %1, i32 %2, i64 %3, i32* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @fclose(i32* %0)
%13 = tail call i32 @exit(i32 3)
unreachable
14: ; preds = %4
ret void
}