#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 */

/* Variables and functions */
int /*<<< orphan*/ node_from_4byte(int, int *, int *, int *, int *);
int /*<<< orphan*/ write_bits(int, int, char *, int *, int *);
void write_node(int node, char *arr, int *pos, int *bitpos,
                int bits_for_index) {
  int letter;
  int index;
  int word_flag;
  int end_flag;
  node_from_4byte(node, &letter, &index, &word_flag, &end_flag);
  write_bits(word_flag, (0x00000001), arr, pos, bitpos);
  write_bits(end_flag, (0x00000001), arr, pos, bitpos);
  write_bits(letter, (0x00000008), arr, pos, bitpos);
  write_bits(index, bits_for_index, arr, pos, bitpos);
}


x86 assembly (clang, -O0):
<write_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1040 <node_from_4byte@plt>
mov    -0x30(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x1,%esi
call   1030 <write_bits@plt>
mov    -0x34(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x1,%esi
call   1030 <write_bits@plt>
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x8,%esi
call   1030 <write_bits@plt>
mov    -0x2c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1030 <write_bits@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_node>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%rbp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <node_from_4byte@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1030 <write_bits@plt>
mov    0x8(%rsp),%edi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1030 <write_bits@plt>
mov    0x14(%rsp),%edi
mov    $0x8,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1030 <write_bits@plt>
mov    0x10(%rsp),%edi
mov    %r15d,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
call   1030 <write_bits@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @write_node(i32 %0, i8* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%15 = load i32, i32* %6
%16 = call i32 @node_from_4byte(i32 %15, i32* %11, i32* %12, i32* %13, i32* %14)
%17 = load i32, i32* %13
%18 = load i8*, i8** %7
%19 = load i32*, i32** %8
%20 = load i32*, i32** %9
%21 = call i32 @write_bits(i32 %17, i32 1, i8* %18, i32* %19, i32* %20)
%22 = load i32, i32* %14
%23 = load i8*, i8** %7
%24 = load i32*, i32** %8
%25 = load i32*, i32** %9
%26 = call i32 @write_bits(i32 %22, i32 1, i8* %23, i32* %24, i32* %25)
%27 = load i32, i32* %11
%28 = load i8*, i8** %7
%29 = load i32*, i32** %8
%30 = load i32*, i32** %9
%31 = call i32 @write_bits(i32 %27, i32 8, i8* %28, i32* %29, i32* %30)
%32 = load i32, i32* %12
%33 = load i32, i32* %10
%34 = load i8*, i8** %7
%35 = load i32*, i32** %8
%36 = load i32*, i32** %9
%37 = call i32 @write_bits(i32 %32, i32 %33, i8* %34, i32* %35, i32* %36)
ret void
}

LLVM IR (-O2):
define void @write_node(i32 %0, i8* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = call i32 @node_from_4byte(i32 %0, i32* %6, i32* %7, i32* %8, i32* %9)
%15 = load i32, i32* %8
%16 = call i32 @write_bits(i32 %15, i32 1, i8* %1, i32* %2, i32* %3)
%17 = load i32, i32* %9
%18 = call i32 @write_bits(i32 %17, i32 1, i8* %1, i32* %2, i32* %3)
%19 = load i32, i32* %6
%20 = call i32 @write_bits(i32 %19, i32 8, i8* %1, i32* %2, i32* %3)
%21 = load i32, i32* %7
%22 = call i32 @write_bits(i32 %21, i32 %4, i8* %1, i32* %2, i32* %3)
ret void
}