#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 scalar_t__ uint32_t;
typedef int /*<<< orphan*/ u;
struct index_node {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(scalar_t__ *, int, int, int /*<<< orphan*/ *);
scalar_t__ htonl(int);
int index_write__node(struct index_node const *, int /*<<< orphan*/ *);
void index_write(const struct index_node *node, FILE *out) {
  long initial_offset, final_offset;
  uint32_t u;
  u = htonl(0xB007F457);
  fwrite(&u, sizeof(u), 1, out);
  u = htonl(((0x0002 << 16) | 0x0001));
  fwrite(&u, sizeof(u), 1, out);
  initial_offset = ftell(out);
  u = 0;
  fwrite(&u, sizeof(uint32_t), 1, out);
  u = htonl(index_write__node(node, out));
  final_offset = ftell(out);
  fseek(out, initial_offset, SEEK_SET);
  fwrite(&u, sizeof(uint32_t), 1, out);
  fseek(out, final_offset, SEEK_SET);
}


x86 assembly (clang, -O0):
<index_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xb007f457,%edi
call   1040 <htonl@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    $0x20001,%edi
call   1040 <htonl@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <index_write__node@plt>
mov    %eax,%edi
call   1040 <htonl@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2dd6(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_write>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    $0xb007f457,%edi
call   1040 <htonl@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    $0x20001,%edi
call   1040 <htonl@plt>
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %rax,%r12
movq   $0x0,0x8(%rsp)
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <index_write__node@plt>
mov    %eax,%edi
call   1040 <htonl@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %rax,%r15
mov    0x2dde(%rip),%r13
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <fseek@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <fseek@plt>

LLVM IR (-O0):
%struct.index_node = type { i32 }
@SEEK_SET = global i32 0
define void @index_write(%struct.index_node* %0, i32* %1) {
%3 = alloca %struct.index_node*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store %struct.index_node* %0, %struct.index_node** %3
store i32* %1, i32** %4
%8 = call i64 @htonl(i32 -1341655977)
store i64 %8, i64* %7
%9 = load i32*, i32** %4
%10 = call i32 @fwrite(i64* %7, i32 8, i32 1, i32* %9)
%11 = call i64 @htonl(i32 131073)
store i64 %11, i64* %7
%12 = load i32*, i32** %4
%13 = call i32 @fwrite(i64* %7, i32 8, i32 1, i32* %12)
%14 = load i32*, i32** %4
%15 = call i64 @ftell(i32* %14)
store i64 %15, i64* %5
store i64 0, i64* %7
%16 = load i32*, i32** %4
%17 = call i32 @fwrite(i64* %7, i32 8, i32 1, i32* %16)
%18 = load %struct.index_node*, %struct.index_node** %3
%19 = load i32*, i32** %4
%20 = call i32 @index_write__node(%struct.index_node* %18, i32* %19)
%21 = call i64 @htonl(i32 %20)
store i64 %21, i64* %7
%22 = load i32*, i32** %4
%23 = call i64 @ftell(i32* %22)
store i64 %23, i64* %6
%24 = load i32*, i32** %4
%25 = load i64, i64* %5
%26 = load i32, i32* @SEEK_SET
%27 = call i32 @fseek(i32* %24, i64 %25, i32 %26)
%28 = load i32*, i32** %4
%29 = call i32 @fwrite(i64* %7, i32 8, i32 1, i32* %28)
%30 = load i32*, i32** %4
%31 = load i64, i64* %6
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @fseek(i32* %30, i64 %31, i32 %32)
ret void
}

LLVM IR (-O2):
%struct.index_node = type { i32 }
@SEEK_SET = global i32 0
define void @index_write(%struct.index_node* %0, i32* %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i64 @htonl(i32 -1341655977)
store i64 %5, i64* %3
%6 = call i32 @fwrite(i64* %3, i32 8, i32 1, i32* %1)
%7 = tail call i64 @htonl(i32 131073)
store i64 %7, i64* %3
%8 = call i32 @fwrite(i64* %3, i32 8, i32 1, i32* %1)
%9 = tail call i64 @ftell(i32* %1)
store i64 0, i64* %3
%10 = call i32 @fwrite(i64* %3, i32 8, i32 1, i32* %1)
%11 = tail call i32 @index_write__node(%struct.index_node* %0, i32* %1)
%12 = tail call i64 @htonl(i32 %11)
store i64 %12, i64* %3
%13 = tail call i64 @ftell(i32* %1)
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %1, i64 %9, i32 %14)
%16 = call i32 @fwrite(i64* %3, i32 8, i32 1, i32* %1)
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %1, i64 %13, i32 %17)
ret void
}