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

/* Variables and functions */
void nios_pkt_8x8_pack(uint8_t *buf, uint8_t target, bool write, uint8_t addr,
                       uint8_t data) {
  buf[0] = ((uint8_t)'A');
  buf[1] = target;
  if (write) {
    buf[2] = (1 << 0);
  } else {
    buf[2] = 0x00;
  }
  buf[3] = 0x00;
  buf[4] = addr;
  buf[5] = data;
  buf[6 + 0] = 0x00;
  buf[6 + 1] = 0x00;
  buf[6 + 2] = 0x00;
  buf[6 + 3] = 0x00;
  buf[6 + 4] = 0x00;
  buf[6 + 5] = 0x00;
  buf[6 + 6] = 0x00;
  buf[6 + 7] = 0x00;
  buf[6 + 8] = 0x00;
  buf[6 + 9] = 0x00;
}


x86 assembly (clang, -O0):
<nios_pkt_8x8_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   $0x41,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x0,-0x10(%rbp)
je     1143 <nios_pkt_8x8_pack+0x43>
mov    -0x8(%rbp),%rax
movl   $0x1,0x8(%rax)
jmp    114e <nios_pkt_8x8_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
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x18(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x1c(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x20(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x24(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x28(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x2c(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,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_8x8_pack>:
movl   $0x41,(%rdi)
mov    %esi,0x4(%rdi)
xor    %eax,%eax
test   %edx,%edx
setne  %al
mov    %eax,0x8(%rdi)
movl   $0x0,0xc(%rdi)
mov    %ecx,0x10(%rdi)
mov    %r8d,0x14(%rdi)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rdi)
movups %xmm0,0x28(%rdi)
movq   $0x0,0x38(%rdi)
ret

LLVM IR (-O0):
define void @nios_pkt_8x8_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 65, 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 = load i32*, i32** %6
%32 = getelementptr inbounds i32, i32* %31, i64 5
store i32 %30, i32* %32
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 6
store i32 0, i32* %34
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 7
store i32 0, i32* %36
%37 = load i32*, i32** %6
%38 = getelementptr inbounds i32, i32* %37, i64 8
store i32 0, i32* %38
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i64 9
store i32 0, i32* %40
%41 = load i32*, i32** %6
%42 = getelementptr inbounds i32, i32* %41, i64 10
store i32 0, i32* %42
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 11
store i32 0, i32* %44
%45 = load i32*, i32** %6
%46 = getelementptr inbounds i32, i32* %45, i64 12
store i32 0, i32* %46
%47 = load i32*, i32** %6
%48 = getelementptr inbounds i32, i32* %47, i64 13
store i32 0, i32* %48
%49 = load i32*, i32** %6
%50 = getelementptr inbounds i32, i32* %49, i64 14
store i32 0, i32* %50
%51 = load i32*, i32** %6
%52 = getelementptr inbounds i32, i32* %51, i64 15
store i32 0, i32* %52
ret void
}

LLVM IR (-O2):
define void @nios_pkt_8x8_pack(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3, i32 %4) {
store i32 65, 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 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %4, i32* %12
%13 = getelementptr inbounds i32, i32* %0, i64 6
%14 = bitcast i32* %13 to i8*
ret void
}