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

/* Variables and functions */
int /*<<< orphan*/ htole64(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(void *, char *, int);
int block_debug_setup(void *addr, int len, uint64_t off, uint64_t id) {
  off = htole64(off);
  id = htole64(id);
  memcpy(addr, (char *)&off, sizeof(uint64_t));
  memcpy(addr + sizeof(uint64_t), (char *)&id, sizeof(uint64_t));
  addr += len - sizeof(uint64_t) - sizeof(uint64_t);
  memcpy(addr, (char *)&off, sizeof(uint64_t));
  memcpy(addr + sizeof(uint64_t), (char *)&id, sizeof(uint64_t));
  return 0;
}


x86 assembly (clang, -O0):
<block_debug_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <htole64@plt>
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <htole64@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
movslq -0xc(%rbp),%rax
sub    $0x4,%rax
sub    $0x4,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block_debug_setup>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %edx,%edi
call   1040 <htole64@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
call   1040 <htole64@plt>
mov    %eax,0x8(%rsp)
lea    0xc(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
lea    0x4(%rbx),%rdi
lea    0x8(%rsp),%r12
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
movslq %r14d,%rbp
lea    (%rbx,%rbp,1),%rdi
add    $0xfffffffffffffff8,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0xfffffffffffffffc,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @block_debug_setup(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %7
%10 = call i32 @htole64(i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %8
%12 = call i32 @htole64(i32 %11)
store i32 %12, i32* %8
%13 = load i8*, i8** %5
%14 = bitcast i32* %7 to i8*
%15 = call i32 @memcpy(i8* %13, i8* %14, i32 4)
%16 = load i8*, i8** %5
%17 = getelementptr i8, i8* %16, i64 4
%18 = bitcast i32* %8 to i8*
%19 = call i32 @memcpy(i8* %17, i8* %18, i32 4)
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = sub i64 %21, 4
%23 = sub i64 %22, 4
%24 = load i8*, i8** %5
%25 = getelementptr i8, i8* %24, i64 %23
store i8* %25, i8** %5
%26 = load i8*, i8** %5
%27 = bitcast i32* %7 to i8*
%28 = call i32 @memcpy(i8* %26, i8* %27, i32 4)
%29 = load i8*, i8** %5
%30 = getelementptr i8, i8* %29, i64 4
%31 = bitcast i32* %8 to i8*
%32 = call i32 @memcpy(i8* %30, i8* %31, i32 4)
ret i32 0
}

LLVM IR (-O2):
define i32 @block_debug_setup(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = tail call i32 @htole64(i32 %2)
store i32 %7, i32* %5
%8 = tail call i32 @htole64(i32 %3)
store i32 %8, i32* %6
%9 = bitcast i32* %5 to i8*
%10 = call i32 @memcpy(i8* %0, i8* %9, i32 4)
%11 = getelementptr i8, i8* %0, i64 4
%12 = bitcast i32* %6 to i8*
%13 = call i32 @memcpy(i8* %11, i8* %12, i32 4)
%14 = sext i32 %1 to i64
%15 = add nsw i64 %14, -8
%16 = getelementptr i8, i8* %0, i64 %15
%17 = call i32 @memcpy(i8* %16, i8* %9, i32 4)
%18 = getelementptr i8, i8* %16, i64 4
%19 = call i32 @memcpy(i8* %18, i8* %12, i32 4)
ret i32 0
}