#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 uint8_t;
typedef int uint64_t;

/* Variables and functions */
void nios_pkt_8x64_pack(uint8_t *buf, uint8_t target, bool write, uint8_t addr,
                        uint64_t data) {
  buf[0] = ((uint8_t)'D');
  buf[1] = target;
  if (write) {
    buf[2] = (1 << 0);
  } else {
    buf[2] = 0x00;
  }
  buf[3] = 0x00;
  buf[4] = addr;
  buf[5 + 0] = (data >> 0) & 0xff;
  buf[5 + 1] = (data >> 8) & 0xff;
  buf[5 + 2] = (data >> 16) & 0xff;
  buf[5 + 3] = (data >> 24) & 0xff;
  buf[5 + 4] = (data >> 32) & 0xff;
  buf[5 + 5] = (data >> 40) & 0xff;
  buf[5 + 6] = (data >> 48) & 0xff;
  buf[5 + 7] = (data >> 56) & 0xff;
  buf[13 + 0] = 0x00;
  buf[13 + 1] = 0x00;
  buf[13 + 2] = 0x00;
}


x86 assembly (clang, -O0):
<nios_pkt_8x64_pack>:
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
movl   $0x44,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x0,-0x10(%rbp)
je     1143 <nios_pkt_8x64_pack+0x43>
mov    -0x8(%rbp),%rax
movl   $0x1,0x8(%rax)
jmp    114e <nios_pkt_8x64_pack+0x4e>
mov    -0x8(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0xc(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x18(%rbp),%ecx
sar    $0x0,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x18(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x18(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0x18(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x18(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x18(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x18(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x18(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x34(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x38(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x3c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<nios_pkt_8x64_pack>:
mov    %r8d,%eax
movl   $0x44,(%rdi)
mov    %esi,0x4(%rdi)
xor    %esi,%esi
test   %edx,%edx
setne  %sil
mov    %esi,0x8(%rdi)
movl   $0x0,0xc(%rdi)
mov    %ecx,0x10(%rdi)
movzbl %al,%ecx
mov    %ecx,0x14(%rdi)
movzbl %ah,%ecx
mov    %ecx,0x18(%rdi)
mov    %r8d,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %ecx,0x1c(%rdi)
shr    $0x18,%eax
mov    %eax,0x20(%rdi)
movq   $0x0,0x34(%rdi)
movl   $0x0,0x3c(%rdi)
ret

LLVM IR (-O0):
define void @nios_pkt_8x64_pack(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32*, i32** %6
%12 = getelementptr inbounds i32, i32* %11, i64 0
store i32 68, i32* %12
%13 = load i32, i32* %7
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32 %13, i32* %15
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %5
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 2
store i32 1, i32* %20
br label %24
21: ; preds = %5
%22 = load i32*, i32** %6
%23 = getelementptr inbounds i32, i32* %22, i64 2
store i32 0, i32* %23
br label %24
24: ; preds = %21, %18
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 3
store i32 0, i32* %26
%27 = load i32, i32* %9
%28 = load i32*, i32** %6
%29 = getelementptr inbounds i32, i32* %28, i64 4
store i32 %27, i32* %29
%30 = load i32, i32* %10
%31 = ashr i32 %30, 0
%32 = and i32 %31, 255
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 5
store i32 %32, i32* %34
%35 = load i32, i32* %10
%36 = ashr i32 %35, 8
%37 = and i32 %36, 255
%38 = load i32*, i32** %6
%39 = getelementptr inbounds i32, i32* %38, i64 6
store i32 %37, i32* %39
%40 = load i32, i32* %10
%41 = ashr i32 %40, 16
%42 = and i32 %41, 255
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 7
store i32 %42, i32* %44
%45 = load i32, i32* %10
%46 = ashr i32 %45, 24
%47 = and i32 %46, 255
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i64 8
store i32 %47, i32* %49
%50 = load i32, i32* %10
%51 = ashr i32 %50, 32
%52 = and i32 %51, 255
%53 = load i32*, i32** %6
%54 = getelementptr inbounds i32, i32* %53, i64 9
store i32 %52, i32* %54
%55 = load i32, i32* %10
%56 = ashr i32 %55, 40
%57 = and i32 %56, 255
%58 = load i32*, i32** %6
%59 = getelementptr inbounds i32, i32* %58, i64 10
store i32 %57, i32* %59
%60 = load i32, i32* %10
%61 = ashr i32 %60, 48
%62 = and i32 %61, 255
%63 = load i32*, i32** %6
%64 = getelementptr inbounds i32, i32* %63, i64 11
store i32 %62, i32* %64
%65 = load i32, i32* %10
%66 = ashr i32 %65, 56
%67 = and i32 %66, 255
%68 = load i32*, i32** %6
%69 = getelementptr inbounds i32, i32* %68, i64 12
store i32 %67, i32* %69
%70 = load i32*, i32** %6
%71 = getelementptr inbounds i32, i32* %70, i64 13
store i32 0, i32* %71
%72 = load i32*, i32** %6
%73 = getelementptr inbounds i32, i32* %72, i64 14
store i32 0, i32* %73
%74 = load i32*, i32** %6
%75 = getelementptr inbounds i32, i32* %74, i64 15
store i32 0, i32* %75
ret void
}

LLVM IR (-O2):
define void @nios_pkt_8x64_pack(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3, i32 %4) {
store i32 68, i32* %0
%6 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %1, i32* %6
%7 = icmp ne i32 %2, 0
%8 = zext i1 %7 to i32
%9 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %8, i32* %9
%10 = getelementptr inbounds i32, i32* %0, i64 3
store i32 0, i32* %10
%11 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %3, i32* %11
%12 = and i32 %4, 255
%13 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %12, i32* %13
%14 = lshr i32 %4, 8
%15 = and i32 %14, 255
%16 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %15, i32* %16
%17 = lshr i32 %4, 16
%18 = and i32 %17, 255
%19 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %18, i32* %19
%20 = lshr i32 %4, 24
%21 = getelementptr inbounds i32, i32* %0, i64 8
store i32 %20, i32* %21
%22 = getelementptr inbounds i32, i32* %0, i64 13
store i32 0, i32* %22
%23 = getelementptr inbounds i32, i32* %0, i64 14
store i32 0, i32* %23
%24 = getelementptr inbounds i32, i32* %0, i64 15
store i32 0, i32* %24
ret void
}