#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 */
size_t fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, size_t);
int writeMaxFreqsFile(FILE *file, int *maxFreqs, int size) {
  size_t written;
  written = fwrite(maxFreqs, sizeof(int), size, file);
  if (written != size) {
    printf(
        "Error writing max freqs: tried to write: %d records, but wrote: %zu\n",
        size, written);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<writeMaxFreqsFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
call   1040 <fwrite@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
je     117c <writeMaxFreqsFile+0x5c>
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1183 <writeMaxFreqsFile+0x63>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeMaxFreqsFile>:
push   %rbx
mov    %edx,%ebx
mov    %rdi,%rcx
mov    %rsi,%rdi
mov    $0x4,%esi
call   1040 <fwrite@plt>
movslq %ebx,%rdx
mov    $0x1,%ecx
cmp    %rdx,%rax
je     1153 <writeMaxFreqsFile+0x33>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1030 <printf@plt>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [69 x i8] c"Error writing max freqs: tried to write: %d records, but wrote: %zu\0A\00"
define i32 @writeMaxFreqsFile(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = load i32*, i32** %6
%10 = load i32, i32* %7
%11 = load i32*, i32** %5
%12 = call i64 @fwrite(i32* %9, i32 4, i32 %10, i32* %11)
store i64 %12, i64* %8
%13 = load i64, i64* %8
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = icmp ne i64 %13, %15
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = load i32, i32* %7
%19 = load i64, i64* %8
%20 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %18, i64 %19)
store i32 0, i32* %4
br label %22
21: ; preds = %3
store i32 1, i32* %4
br label %22
22: ; preds = %21, %17
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
@.str = [69 x i8] c"Error writing max freqs: tried to write: %d records, but wrote: %zu\0A\00"
define i32 @writeMaxFreqsFile(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = tail call i64 @fwrite(i32* %1, i32 4, i32 %2, i32* %0)
%5 = sext i32 %2 to i64
%6 = icmp eq i64 %4, %5
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %2, i64 %4)
br label %9
9: ; preds = %3, %7
%10 = phi i32 [ 0, %7 ], [ 1, %3 ]
ret i32 %10
}