#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 uint32_t;

/* Variables and functions */
void paged_mem_block_header_write(void *ptr_header, uint32_t block_idx,
                                  uint32_t bitmap_idx, uint32_t bit_idx,
                                  uint32_t in_pool) {
  uint32_t *ptr_header_p = ptr_header;
  *ptr_header_p++ = 0xDEADBEEF;
  *ptr_header_p++ = block_idx;
  *ptr_header_p++ = ((bitmap_idx & 0xFFFF) << 16) | (bit_idx & 0xFFFF);
  *ptr_header_p++ = in_pool;
}


x86 assembly (clang, -O0):
<paged_mem_block_header_write>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
movl   $0xdeadbeef,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%ecx
and    $0xffff,%ecx
shl    $0x10,%ecx
mov    -0x14(%rbp),%eax
and    $0xffff,%eax
or     %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<paged_mem_block_header_write>:
movl   $0xdeadbeef,(%rdi)
mov    %esi,0x4(%rdi)
shl    $0x10,%edx
movzwl %cx,%eax
or     %edx,%eax
mov    %eax,0x8(%rdi)
mov    %r8d,0xc(%rdi)
ret

LLVM IR (-O0):
define void @paged_mem_block_header_write(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = bitcast i8* %12 to i32*
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = getelementptr inbounds i32, i32* %14, i32 1
store i32* %15, i32** %11
store i32 -559038737, i32* %14
%16 = load i32, i32* %7
%17 = load i32*, i32** %11
%18 = getelementptr inbounds i32, i32* %17, i32 1
store i32* %18, i32** %11
store i32 %16, i32* %17
%19 = load i32, i32* %8
%20 = and i32 %19, 65535
%21 = shl i32 %20, 16
%22 = load i32, i32* %9
%23 = and i32 %22, 65535
%24 = or i32 %21, %23
%25 = load i32*, i32** %11
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %11
store i32 %24, i32* %25
%27 = load i32, i32* %10
%28 = load i32*, i32** %11
%29 = getelementptr inbounds i32, i32* %28, i32 1
store i32* %29, i32** %11
store i32 %27, i32* %28
ret void
}

LLVM IR (-O2):
define void @paged_mem_block_header_write(i8* nocapture writeonly %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = bitcast i8* %0 to i32*
%7 = getelementptr inbounds i8, i8* %0, i64 4
%8 = bitcast i8* %7 to i32*
store i32 -559038737, i32* %6
%9 = getelementptr inbounds i8, i8* %0, i64 8
%10 = bitcast i8* %9 to i32*
store i32 %1, i32* %8
%11 = shl i32 %2, 16
%12 = and i32 %3, 65535
%13 = or i32 %12, %11
%14 = getelementptr inbounds i8, i8* %0, i64 12
%15 = bitcast i8* %14 to i32*
store i32 %13, i32* %10
store i32 %4, i32* %15
ret void
}