#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 */
int /*<<< orphan*/ EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int InitialiseHeader(FILE *ofptr, int filecount) {
  int i, j;
  fseek(ofptr, 0, SEEK_SET);
  for (i = 0; i < sizeof(int); i++)
    fputc(*(((char *)(&filecount)) + i), ofptr);
  for (i = 0; i < filecount; i++)
    for (j = 0; j < sizeof(unsigned long) * 3; j++)
      if (fputc(0, ofptr) == EOF)
        return 1;
  return 0;
}


x86 assembly (clang, -O0):
<InitialiseHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x4,%rax
jae    117a <InitialiseHeader+0x5a>
movslq -0x18(%rbp),%rax
mov    -0x14(%rbp,%rax,1),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <InitialiseHeader+0x2a>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ee <InitialiseHeader+0xce>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x18,%rax
jae    11db <InitialiseHeader+0xbb>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1030 <fputc@plt>
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%eax
jne    11c8 <InitialiseHeader+0xa8>
movl   $0x1,-0x4(%rbp)
jmp    11f5 <InitialiseHeader+0xd5>
jmp    11cd <InitialiseHeader+0xad>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <InitialiseHeader+0x74>
jmp    11e0 <InitialiseHeader+0xc0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <InitialiseHeader+0x61>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InitialiseHeader>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %esi,%ebp
shr    $0x8,%ebp
mov    %esi,%r12d
shr    $0x10,%r12d
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
xor    %esi,%esi
call   1040 <fseek@plt>
movsbl %r15b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movsbl %bpl,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
movsbl %r12b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %r15d,%edi
sar    $0x18,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   %r15d,%r15d
jle    11c9 <InitialiseHeader+0xa9>
xor    %r14d,%r14d
mov    0x2e5a(%rip),%r12
mov    $0x18,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    (%r12),%eax
je     11c3 <InitialiseHeader+0xa3>
add    $0xffffffff,%ebp
jne    11a0 <InitialiseHeader+0x80>
add    $0x1,%r14d
cmp    %r15d,%r14d
jne    118e <InitialiseHeader+0x6e>
xor    %r14d,%r14d
jmp    11c9 <InitialiseHeader+0xa9>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@EOF = global i32 0
define i32 @InitialiseHeader(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%8 = load i32*, i32** %4
%9 = load i32, i32* @SEEK_SET
%10 = call i32 @fseek(i32* %8, i32 0, i32 %9)
store i32 0, i32* %6
br label %11
11: ; preds = %23, %2
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %13, 4
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = bitcast i32* %5 to i8*
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = load i32*, i32** %4
%22 = call i32 @fputc(i8 signext %20, i32* %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %11
26: ; preds = %11
store i32 0, i32* %6
br label %27
27: ; preds = %47, %26
%28 = load i32, i32* %6
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %50
31: ; preds = %27
store i32 0, i32* %7
br label %32
32: ; preds = %43, %31
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = icmp ult i64 %34, 24
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32*, i32** %4
%38 = call i32 @fputc(i8 signext 0, i32* %37)
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 1, i32* %3
br label %51
42: ; preds = %36
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %32
46: ; preds = %32
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %27
50: ; preds = %27
store i32 0, i32* %3
br label %51
51: ; preds = %50, %41
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@EOF = global i32 0
define i32 @InitialiseHeader(i32* nocapture %0, i32 %1) {
%3 = trunc i32 %1 to i8
%4 = lshr i32 %1, 8
%5 = trunc i32 %4 to i8
%6 = lshr i32 %1, 16
%7 = trunc i32 %6 to i8
%8 = lshr i32 %1, 24
%9 = trunc i32 %8 to i8
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @fseek(i32* %0, i32 0, i32 %10)
%12 = tail call i32 @fputc(i8 signext %3, i32* %0)
%13 = tail call i32 @fputc(i8 signext %5, i32* %0)
%14 = tail call i32 @fputc(i8 signext %7, i32* %0)
%15 = tail call i32 @fputc(i8 signext %9, i32* %0)
%16 = icmp sgt i32 %1, 0
br i1 %16, label %17, label %30
17: ; preds = %2, %27
%18 = phi i32 [ %28, %27 ], [ 0, %2 ]
br label %22
19: ; preds = %22
%20 = add nuw nsw i32 %23, 1
%21 = icmp eq i32 %20, 24
br i1 %21, label %27, label %22
22: ; preds = %17, %19
%23 = phi i32 [ 0, %17 ], [ %20, %19 ]
%24 = tail call i32 @fputc(i8 signext 0, i32* %0)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %30, label %19
27: ; preds = %19
%28 = add nuw nsw i32 %18, 1
%29 = icmp eq i32 %28, %1
br i1 %29, label %30, label %17
30: ; preds = %27, %22, %2
%31 = phi i32 [ 0, %2 ], [ 1, %22 ], [ 0, %27 ]
ret i32 %31
}