#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 writeMetadataFile(FILE *file, int docs, int terms) {
  size_t written;
  written = fwrite(&docs, sizeof(int), 1, file);
  if (written != 1) {
    printf("Error writing metadata: number of docs could not be written\n");
    return 0;
  }
  written = fwrite(&terms, sizeof(int), 1, file);
  if (written != 1) {
    printf("Error writing metadata: number of terms could not be written\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<writeMetadataFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
je     1170 <writeMetadataFile+0x50>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <writeMetadataFile+0x95>
mov    -0x10(%rbp),%rcx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fwrite@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
je     11ae <writeMetadataFile+0x8e>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <writeMetadataFile+0x95>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeMetadataFile>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %esi,0x4(%rsp)
mov    %edx,(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x1,%ebx
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
cmp    $0x1,%rax
jne    1174 <writeMetadataFile+0x54>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
cmp    $0x1,%rax
je     1182 <writeMetadataFile+0x62>
lea    0xe8e(%rip),%rdi
jmp    117b <writeMetadataFile+0x5b>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [61 x i8] c"Error writing metadata: number of docs could not be written\0A\00"
@.str.1 = [62 x i8] c"Error writing metadata: number of terms could not be written\0A\00"
define i32 @writeMetadataFile(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** %5
%10 = call i64 @fwrite(i32* %6, i32 4, i32 1, i32* %9)
store i64 %10, i64* %8
%11 = load i64, i64* %8
%12 = icmp ne i64 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %23
15: ; preds = %3
%16 = load i32*, i32** %5
%17 = call i64 @fwrite(i32* %7, i32 4, i32 1, i32* %16)
store i64 %17, i64* %8
%18 = load i64, i64* %8
%19 = icmp ne i64 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %23
22: ; preds = %15
store i32 1, i32* %4
br label %23
23: ; preds = %22, %20, %13
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@str = [61 x i8] c"Error writing metadata: number of terms could not be written\00"
@str.2 = [60 x i8] c"Error writing metadata: number of docs could not be written\00"
define i32 @writeMetadataFile(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
store i32 %1, i32* %4
store i32 %2, i32* %5
%6 = call i64 @fwrite(i32* %4, i32 4, i32 1, i32* %0)
%7 = icmp eq i64 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = call i64 @fwrite(i32* %5, i32 4, i32 1, i32* %0)
%10 = icmp eq i64 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %8, %3
%12 = phi i8* [ getelementptr inbounds ([60 x i8], [60 x i8]* @str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0), %8 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %8
%15 = phi i32 [ 1, %8 ], [ 0, %11 ]
ret i32 %15
}