#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 */
unsigned int XsDutInit(int /*<<< orphan*/, int, unsigned int *, unsigned int *);
int /*<<< orphan*/ XsDutRead(unsigned int, unsigned char **, unsigned int);
int /*<<< orphan*/ XsDutWrite(unsigned int, unsigned char **, unsigned int);
unsigned int XsMemInit(int /*<<< orphan*/, int, unsigned int *, unsigned int *);
int /*<<< orphan*/ XsMemRead(unsigned int, int, unsigned long long *, int);
int /*<<< orphan*/ XsMemWrite(unsigned int, int, unsigned long long *, int);
int /*<<< orphan*/ free(unsigned long long *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  int i;
  unsigned int dut;
  unsigned int inVecWidth;
  unsigned int outVecWidth;
  unsigned char outputs[5];
  unsigned char inputs[4];
  unsigned int ram;
  unsigned int addrWidth;
  unsigned int dataWidth;
  int ramSize;
  printf("====================================================================="
         "===\n");
  printf("Testing HostIoDut...\n");
  dut = XsDutInit(0, 1, &inVecWidth, &outVecWidth);
  printf("Input vector width: %d\nOutput vector width: %d\n\n", inVecWidth,
         outVecWidth);
  for (i = 0; i < 9; i++) {
    XsDutWrite(dut, &inputs, inVecWidth);
    XsDutRead(dut, &outputs, outVecWidth);
    printf("%d %d %d %d %d\n", outputs[4], outputs[3], outputs[2], outputs[1],
           outputs[0]);
  }
  printf("====================================================================="
         "===\n");
  printf("Testing HostIoRam...\n");
  ram = XsMemInit(0, 3, &addrWidth, &dataWidth);
  printf(" Addr Width: %d\n Data Width: %d\n\n", addrWidth, dataWidth);
  ramSize = 1 << addrWidth;
  ramSize /= 2;
  unsigned long long *wData =
      (unsigned long long *)malloc(ramSize * sizeof(unsigned long long));
  unsigned long long *rData =
      (unsigned long long *)malloc(ramSize * sizeof(unsigned long long));
  int num = 2097152;
  int addr = 0;
  unsigned long k;
  for (k = 0; k < num; k++) {
    wData[k] = (unsigned short)k;
  }
  printf("Writing %d elements to SDRAM starting at %d...\n", num, addr);
  XsMemWrite(ram, addr, wData, num);
  printf("Reading %d elements from SDRAM starting at %d...\n", num, addr);
  for (k = 0; k < num; k++) {
    rData[k] = 0;
  }
  XsMemRead(ram, addr, rData, num);
  for (k = 0; k < num; k++) {
    if (rData[k] != wData[k]) {
      printf(" Oops, something went wrong! IN DATA != OUT DATA\n");
      free(rData);
      free(wData);
      return 1;
    }
  }
  sleep(4);
  for (k = 0; k < num; k++) {
    rData[k] = 0;
  }
  printf("Reading %d elements from SDRAM starting at %d...\n", num, addr);
  XsMemRead(ram, 0, rData, num);
  for (k = 0; k < num; k++) {
    if (rData[k] != wData[k]) {
      printf(" Oops, something went wrong! IN DATA != OUT DATA\n");
      free(rData);
      free(wData);
      return 1;
    }
  }
  printf("Done.\n");
  free(rData);
  free(wData);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0x1,%esi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1080 <XsDutInit@plt>
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x9,-0x14(%rbp)
jge    125e <main+0xbe>
mov    -0x18(%rbp),%edi
lea    -0x29(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <XsDutWrite@plt>
mov    -0x18(%rbp),%edi
lea    -0x25(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <XsDutRead@plt>
movzbl -0x21(%rbp),%esi
movzbl -0x22(%rbp),%edx
movzbl -0x23(%rbp),%ecx
movzbl -0x24(%rbp),%r8d
movzbl -0x25(%rbp),%r9d
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1204 <main+0x64>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0x3,%esi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10a0 <XsMemInit@plt>
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x200000,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmp    %rcx,%rax
jae    1333 <main+0x193>
mov    -0x60(%rbp),%rax
movzwl %ax,%eax
mov    %eax,%edx
mov    -0x48(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    12fc <main+0x15c>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%edi
mov    -0x58(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x54(%rbp),%ecx
call   1070 <XsMemWrite@plt>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmp    %rcx,%rax
jae    13a7 <main+0x207>
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1375 <main+0x1d5>
mov    -0x30(%rbp),%edi
mov    -0x58(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    -0x54(%rbp),%ecx
call   10b0 <XsMemRead@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmp    %rcx,%rax
jae    1432 <main+0x292>
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x48(%rbp),%rcx
mov    -0x60(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
je     141c <main+0x27c>
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x39b>
jmp    1421 <main+0x281>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    13c1 <main+0x221>
mov    $0x4,%edi
call   10c0 <sleep@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmp    %rcx,%rax
jae    1476 <main+0x2d6>
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1444 <main+0x2a4>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    -0x54(%rbp),%ecx
xor    %esi,%esi
call   10b0 <XsMemRead@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmp    %rcx,%rax
jae    1514 <main+0x374>
mov    -0x50(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x48(%rbp),%rcx
mov    -0x60(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
je     14fe <main+0x35e>
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x39b>
jmp    1503 <main+0x363>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    14a3 <main+0x303>
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xf65(%rip),%rdi
call   1060 <puts@plt>
lea    0xf44(%rip),%rdi
call   1060 <puts@plt>
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <XsDutInit@plt>
mov    %eax,%ebx
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%edx
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x9,%ebp
lea    0x24(%rsp),%r14
lea    0xf(%rsp),%r15
lea    0xe67(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    0x1c(%rsp),%edx
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <XsDutWrite@plt>
mov    0x18(%rsp),%edx
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <XsDutRead@plt>
movzbl 0x13(%rsp),%esi
movzbl 0x12(%rsp),%edx
movzbl 0x11(%rsp),%ecx
movzbl 0x10(%rsp),%r8d
movzbl 0xf(%rsp),%r9d
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0xffffffff,%ebp
jne    1230 <main+0x70>
lea    0xebd(%rip),%rdi
call   1060 <puts@plt>
lea    0xefa(%rip),%rdi
call   1060 <puts@plt>
lea    0x14(%rsp),%rdx
lea    0x20(%rsp),%rcx
xor    %edi,%edi
mov    $0x3,%esi
call   10c0 <XsMemInit@plt>
mov    %eax,%r15d
mov    0x14(%rsp),%esi
mov    0x20(%rsp),%edx
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x14(%rsp),%cl
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
shl    $0x2,%ebp
and    $0xfffffff8,%ebp
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
movdqa 0xd0f(%rip),%xmm0
mov    $0x6,%eax
movdqa 0xd12(%rip),%xmm1
movdqa 0xd1a(%rip),%xmm2
movdqa 0xd22(%rip),%xmm3
movdqa 0xd2a(%rip),%xmm4
movdqa 0xd32(%rip),%xmm5
xchg   %ax,%ax
movdqa %xmm0,%xmm6
paddq  %xmm1,%xmm6
movdqa %xmm0,%xmm7
pand   %xmm2,%xmm7
pand   %xmm2,%xmm6
movdqu %xmm7,-0x30(%rbx,%rax,8)
movdqu %xmm6,-0x20(%rbx,%rax,8)
movdqa %xmm0,%xmm6
paddq  %xmm3,%xmm6
movdqa %xmm0,%xmm7
paddq  %xmm4,%xmm7
pand   %xmm2,%xmm6
pand   %xmm2,%xmm7
movdqu %xmm6,-0x10(%rbx,%rax,8)
movdqu %xmm7,(%rbx,%rax,8)
paddq  %xmm5,%xmm0
add    $0x8,%rax
cmp    $0x200006,%rax
jne    1320 <main+0x160>
lea    0xd49(%rip),%rdi
mov    $0x200000,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0x200000,%ecx
call   1090 <XsMemWrite@plt>
lea    0xd52(%rip),%rdi
mov    $0x200000,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1000000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    %r15d,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    $0x200000,%ecx
call   10d0 <XsMemRead@plt>
mov    $0x3,%eax
lea    0xdc2(%rip),%r12
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x18(%r14,%rax,8),%rcx
cmp    -0x18(%rbx,%rax,8),%rcx
jne    14d0 <main+0x310>
mov    -0x10(%r14,%rax,8),%rcx
cmp    -0x10(%rbx,%rax,8),%rcx
jne    14d0 <main+0x310>
mov    -0x8(%r14,%rax,8),%rcx
cmp    -0x8(%rbx,%rax,8),%rcx
jne    14d0 <main+0x310>
mov    (%r14,%rax,8),%rcx
cmp    (%rbx,%rax,8),%rcx
jne    14d0 <main+0x310>
add    $0x4,%rax
cmp    $0x200003,%rax
jne    13f0 <main+0x230>
mov    $0x4,%edi
call   10e0 <sleep@plt>
xor    %ebp,%ebp
mov    $0x1000000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xc97(%rip),%rdi
mov    $0x200000,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    $0x200000,%ecx
call   10d0 <XsMemRead@plt>
lea    0xd15(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rbp,8),%rax
cmp    (%rbx,%rbp,8),%rax
jne    14d0 <main+0x310>
mov    0x8(%r14,%rbp,8),%rax
cmp    0x8(%rbx,%rbp,8),%rax
jne    14d0 <main+0x310>
mov    0x10(%r14,%rbp,8),%rax
cmp    0x10(%rbx,%rbp,8),%rax
jne    14d0 <main+0x310>
mov    0x18(%r14,%rbp,8),%rax
cmp    0x18(%rbx,%rbp,8),%rax
jne    14d0 <main+0x310>
add    $0x4,%rbp
cmp    $0x200000,%rbp
jne    1490 <main+0x2d0>
xor    %r13d,%r13d
jmp    14d3 <main+0x313>
mov    %r12,%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [74 x i8] c"========================================================================\0A\00"
@.str.1 = [22 x i8] c"Testing HostIoDut...\0A\00"
@.str.2 = [49 x i8] c"Input vector width: %d\0AOutput vector width: %d\0A\0A\00"
@.str.3 = [16 x i8] c"%d %d %d %d %d\0A\00"
@.str.4 = [22 x i8] c"Testing HostIoRam...\0A\00"
@.str.5 = [34 x i8] c" Addr Width: %d\0A Data Width: %d\0A\0A\00"
@.str.6 = [48 x i8] c"Writing %d elements to SDRAM starting at %d...\0A\00"
@.str.7 = [50 x i8] c"Reading %d elements from SDRAM starting at %d...\0A\00"
@.str.8 = [50 x i8] c" Oops, something went wrong! IN DATA != OUT DATA\0A\00"
@.str.9 = [7 x i8] c"Done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [5 x i8]
%11 = alloca [4 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64*
%17 = alloca i64*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @XsDutInit(i32 0, i32 1, i32* %8, i32* %9)
store i32 %23, i32* %7
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
store i32 0, i32* %6
br label %27
27: ; preds = %55, %2
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 9
br i1 %29, label %30, label %58
30: ; preds = %27
%31 = load i32, i32* %7
%32 = bitcast [4 x i8]* %11 to i8**
%33 = load i32, i32* %8
%34 = call i32 @XsDutWrite(i32 %31, i8** %32, i32 %33)
%35 = load i32, i32* %7
%36 = bitcast [5 x i8]* %10 to i8**
%37 = load i32, i32* %9
%38 = call i32 @XsDutRead(i32 %35, i8** %36, i32 %37)
%39 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 4
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 3
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 2
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 1
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %44, i32 %47, i32 %50, i32 %53)
br label %55
55: ; preds = %30
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %27
58: ; preds = %27
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 @XsMemInit(i32 0, i32 3, i32* %13, i32* %14)
store i32 %61, i32* %12
%62 = load i32, i32* %13
%63 = load i32, i32* %14
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %62, i32 %63)
%65 = load i32, i32* %13
%66 = shl i32 1, %65
store i32 %66, i32* %15
%67 = load i32, i32* %15
%68 = sdiv i32 %67, 2
store i32 %68, i32* %15
%69 = load i32, i32* %15
%70 = sext i32 %69 to i64
%71 = mul i64 %70, 8
%72 = trunc i64 %71 to i32
%73 = call i64 @malloc(i32 %72)
%74 = inttoptr i64 %73 to i64*
store i64* %74, i64** %16
%75 = load i32, i32* %15
%76 = sext i32 %75 to i64
%77 = mul i64 %76, 8
%78 = trunc i64 %77 to i32
%79 = call i64 @malloc(i32 %78)
%80 = inttoptr i64 %79 to i64*
store i64* %80, i64** %17
store i32 2097152, i32* %18
store i32 0, i32* %19
store i64 0, i64* %20
br label %81
81: ; preds = %93, %58
%82 = load i64, i64* %20
%83 = load i32, i32* %18
%84 = sext i32 %83 to i64
%85 = icmp ult i64 %82, %84
br i1 %85, label %86, label %96
86: ; preds = %81
%87 = load i64, i64* %20
%88 = trunc i64 %87 to i16
%89 = zext i16 %88 to i64
%90 = load i64*, i64** %16
%91 = load i64, i64* %20
%92 = getelementptr inbounds i64, i64* %90, i64 %91
store i64 %89, i64* %92
br label %93
93: ; preds = %86
%94 = load i64, i64* %20
%95 = add i64 %94, 1
store i64 %95, i64* %20
br label %81
96: ; preds = %81
%97 = load i32, i32* %18
%98 = load i32, i32* %19
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %97, i32 %98)
%100 = load i32, i32* %12
%101 = load i32, i32* %19
%102 = load i64*, i64** %16
%103 = load i32, i32* %18
%104 = call i32 @XsMemWrite(i32 %100, i32 %101, i64* %102, i32 %103)
%105 = load i32, i32* %18
%106 = load i32, i32* %19
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 %105, i32 %106)
store i64 0, i64* %20
br label %108
108: ; preds = %117, %96
%109 = load i64, i64* %20
%110 = load i32, i32* %18
%111 = sext i32 %110 to i64
%112 = icmp ult i64 %109, %111
br i1 %112, label %113, label %120
113: ; preds = %108
%114 = load i64*, i64** %17
%115 = load i64, i64* %20
%116 = getelementptr inbounds i64, i64* %114, i64 %115
store i64 0, i64* %116
br label %117
117: ; preds = %113
%118 = load i64, i64* %20
%119 = add i64 %118, 1
store i64 %119, i64* %20
br label %108
120: ; preds = %108
%121 = load i32, i32* %12
%122 = load i32, i32* %19
%123 = load i64*, i64** %17
%124 = load i32, i32* %18
%125 = call i32 @XsMemRead(i32 %121, i32 %122, i64* %123, i32 %124)
store i64 0, i64* %20
br label %126
126: ; preds = %148, %120
%127 = load i64, i64* %20
%128 = load i32, i32* %18
%129 = sext i32 %128 to i64
%130 = icmp ult i64 %127, %129
br i1 %130, label %131, label %151
131: ; preds = %126
%132 = load i64*, i64** %17
%133 = load i64, i64* %20
%134 = getelementptr inbounds i64, i64* %132, i64 %133
%135 = load i64, i64* %134
%136 = load i64*, i64** %16
%137 = load i64, i64* %20
%138 = getelementptr inbounds i64, i64* %136, i64 %137
%139 = load i64, i64* %138
%140 = icmp ne i64 %135, %139
br i1 %140, label %141, label %147
141: ; preds = %131
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0))
%143 = load i64*, i64** %17
%144 = call i32 @free(i64* %143)
%145 = load i64*, i64** %16
%146 = call i32 @free(i64* %145)
store i32 1, i32* %3
br label %204
147: ; preds = %131
br label %148
148: ; preds = %147
%149 = load i64, i64* %20
%150 = add i64 %149, 1
store i64 %150, i64* %20
br label %126
151: ; preds = %126
%152 = call i32 @sleep(i32 4)
store i64 0, i64* %20
br label %153
153: ; preds = %162, %151
%154 = load i64, i64* %20
%155 = load i32, i32* %18
%156 = sext i32 %155 to i64
%157 = icmp ult i64 %154, %156
br i1 %157, label %158, label %165
158: ; preds = %153
%159 = load i64*, i64** %17
%160 = load i64, i64* %20
%161 = getelementptr inbounds i64, i64* %159, i64 %160
store i64 0, i64* %161
br label %162
162: ; preds = %158
%163 = load i64, i64* %20
%164 = add i64 %163, 1
store i64 %164, i64* %20
br label %153
165: ; preds = %153
%166 = load i32, i32* %18
%167 = load i32, i32* %19
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 %166, i32 %167)
%169 = load i32, i32* %12
%170 = load i64*, i64** %17
%171 = load i32, i32* %18
%172 = call i32 @XsMemRead(i32 %169, i32 0, i64* %170, i32 %171)
store i64 0, i64* %20
br label %173
173: ; preds = %195, %165
%174 = load i64, i64* %20
%175 = load i32, i32* %18
%176 = sext i32 %175 to i64
%177 = icmp ult i64 %174, %176
br i1 %177, label %178, label %198
178: ; preds = %173
%179 = load i64*, i64** %17
%180 = load i64, i64* %20
%181 = getelementptr inbounds i64, i64* %179, i64 %180
%182 = load i64, i64* %181
%183 = load i64*, i64** %16
%184 = load i64, i64* %20
%185 = getelementptr inbounds i64, i64* %183, i64 %184
%186 = load i64, i64* %185
%187 = icmp ne i64 %182, %186
br i1 %187, label %188, label %194
188: ; preds = %178
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0))
%190 = load i64*, i64** %17
%191 = call i32 @free(i64* %190)
%192 = load i64*, i64** %16
%193 = call i32 @free(i64* %192)
store i32 1, i32* %3
br label %204
194: ; preds = %178
br label %195
195: ; preds = %194
%196 = load i64, i64* %20
%197 = add i64 %196, 1
store i64 %197, i64* %20
br label %173
198: ; preds = %173
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%200 = load i64*, i64** %17
%201 = call i32 @free(i64* %200)
%202 = load i64*, i64** %16
%203 = call i32 @free(i64* %202)
store i32 0, i32* %3
br label %204
204: ; preds = %198, %188, %141
%205 = load i32, i32* %3
ret i32 %205
}

LLVM IR (-O2):
@.str.2 = [49 x i8] c"Input vector width: %d\0AOutput vector width: %d\0A\0A\00"
@.str.3 = [16 x i8] c"%d %d %d %d %d\0A\00"
@.str.5 = [34 x i8] c" Addr Width: %d\0A Data Width: %d\0A\0A\00"
@.str.6 = [48 x i8] c"Writing %d elements to SDRAM starting at %d...\0A\00"
@.str.7 = [50 x i8] c"Reading %d elements from SDRAM starting at %d...\0A\00"
@str.10 = [21 x i8] c"Testing HostIoDut...\00"
@str.11 = [73 x i8] c"========================================================================\00"
@str.12 = [21 x i8] c"Testing HostIoRam...\00"
@str.13 = [6 x i8] c"Done.\00"
@str.15 = [49 x i8] c" Oops, something went wrong! IN DATA != OUT DATA\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x i8]
%6 = alloca [4 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.11, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%17 = call i32 @XsDutInit(i32 0, i32 1, i32* %3, i32* %4)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
%21 = bitcast [4 x i8]* %6 to i8**
%22 = bitcast [5 x i8]* %5 to i8**
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 4
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 3
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 2
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 1
br label %27
27: ; preds = %2, %27
%28 = phi i32 [ 0, %2 ], [ %44, %27 ]
%29 = load i32, i32* %3
%30 = call i32 @XsDutWrite(i32 %17, i8** %21, i32 %29)
%31 = load i32, i32* %4
%32 = call i32 @XsDutRead(i32 %17, i8** %22, i32 %31)
%33 = load i8, i8* %23
%34 = zext i8 %33 to i32
%35 = load i8, i8* %24
%36 = zext i8 %35 to i32
%37 = load i8, i8* %25
%38 = zext i8 %37 to i32
%39 = load i8, i8* %26
%40 = zext i8 %39 to i32
%41 = load i8, i8* %11
%42 = zext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %36, i32 %38, i32 %40, i32 %42)
%44 = add nuw nsw i32 %28, 1
%45 = icmp eq i32 %44, 9
br i1 %45, label %46, label %27
46: ; preds = %27
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.11, i64 0, i64 0))
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
%49 = call i32 @XsMemInit(i32 0, i32 3, i32* %7, i32* %8)
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %50, i32 %51)
%53 = load i32, i32* %7
%54 = shl nuw i32 1, %53
%55 = sdiv i32 %54, 2
%56 = shl i32 %55, 3
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to i64*
%59 = call i64 @malloc(i32 %56)
br label %60
60: ; preds = %60, %46
%61 = phi i64 [ 0, %46 ], [ %79, %60 ]
%62 = phi <2 x i64> [ <i64 0, i64 1>, %46 ], [ %80, %60 ]
%63 = add <2 x i64> %62, <i64 2, i64 2>
%64 = and <2 x i64> %62, <i64 65535, i64 65535>
%65 = and <2 x i64> %63, <i64 65535, i64 65535>
%66 = getelementptr inbounds i64, i64* %58, i64 %61
%67 = bitcast i64* %66 to <2 x i64>*
store <2 x i64> %64, <2 x i64>* %67
%68 = getelementptr inbounds i64, i64* %66, i64 2
%69 = bitcast i64* %68 to <2 x i64>*
store <2 x i64> %65, <2 x i64>* %69
%70 = or i64 %61, 4
%71 = add <2 x i64> %62, <i64 4, i64 4>
%72 = add <2 x i64> %62, <i64 6, i64 6>
%73 = and <2 x i64> %71, <i64 65535, i64 65535>
%74 = and <2 x i64> %72, <i64 65535, i64 65535>
%75 = getelementptr inbounds i64, i64* %58, i64 %70
%76 = bitcast i64* %75 to <2 x i64>*
store <2 x i64> %73, <2 x i64>* %76
%77 = getelementptr inbounds i64, i64* %75, i64 2
%78 = bitcast i64* %77 to <2 x i64>*
store <2 x i64> %74, <2 x i64>* %78
%79 = add nuw nsw i64 %61, 8
%80 = add <2 x i64> %62, <i64 8, i64 8>
%81 = icmp eq i64 %79, 2097152
br i1 %81, label %82, label %60
82: ; preds = %60
%83 = inttoptr i64 %59 to i64*
%84 = inttoptr i64 %59 to i8*
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 2097152, i32 0)
%86 = call i32 @XsMemWrite(i32 %49, i32 0, i64* %58, i32 2097152)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 2097152, i32 0)
%88 = call i32 @XsMemRead(i32 %49, i32 0, i64* %83, i32 2097152)
br label %113
89: ; preds = %113
%90 = or i64 %114, 1
%91 = getelementptr inbounds i64, i64* %83, i64 %90
%92 = load i64, i64* %91
%93 = getelementptr inbounds i64, i64* %58, i64 %90
%94 = load i64, i64* %93
%95 = icmp eq i64 %92, %94
br i1 %95, label %96, label %155
96: ; preds = %89
%97 = or i64 %114, 2
%98 = getelementptr inbounds i64, i64* %83, i64 %97
%99 = load i64, i64* %98
%100 = getelementptr inbounds i64, i64* %58, i64 %97
%101 = load i64, i64* %100
%102 = icmp eq i64 %99, %101
br i1 %102, label %103, label %155
103: ; preds = %96
%104 = or i64 %114, 3
%105 = getelementptr inbounds i64, i64* %83, i64 %104
%106 = load i64, i64* %105
%107 = getelementptr inbounds i64, i64* %58, i64 %104
%108 = load i64, i64* %107
%109 = icmp eq i64 %106, %108
br i1 %109, label %110, label %155
110: ; preds = %103
%111 = add nuw nsw i64 %114, 4
%112 = icmp eq i64 %111, 2097152
br i1 %112, label %120, label %113
113: ; preds = %110, %82
%114 = phi i64 [ 0, %82 ], [ %111, %110 ]
%115 = getelementptr inbounds i64, i64* %83, i64 %114
%116 = load i64, i64* %115
%117 = getelementptr inbounds i64, i64* %58, i64 %114
%118 = load i64, i64* %117
%119 = icmp eq i64 %116, %118
br i1 %119, label %89, label %155
120: ; preds = %110
%121 = call i32 @sleep(i32 4)
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i32 2097152, i32 0)
%123 = call i32 @XsMemRead(i32 %49, i32 0, i64* %83, i32 2097152)
br label %148
124: ; preds = %148
%125 = or i64 %149, 1
%126 = getelementptr inbounds i64, i64* %83, i64 %125
%127 = load i64, i64* %126
%128 = getelementptr inbounds i64, i64* %58, i64 %125
%129 = load i64, i64* %128
%130 = icmp eq i64 %127, %129
br i1 %130, label %131, label %155
131: ; preds = %124
%132 = or i64 %149, 2
%133 = getelementptr inbounds i64, i64* %83, i64 %132
%134 = load i64, i64* %133
%135 = getelementptr inbounds i64, i64* %58, i64 %132
%136 = load i64, i64* %135
%137 = icmp eq i64 %134, %136
br i1 %137, label %138, label %155
138: ; preds = %131
%139 = or i64 %149, 3
%140 = getelementptr inbounds i64, i64* %83, i64 %139
%141 = load i64, i64* %140
%142 = getelementptr inbounds i64, i64* %58, i64 %139
%143 = load i64, i64* %142
%144 = icmp eq i64 %141, %143
br i1 %144, label %145, label %155
145: ; preds = %138
%146 = add nuw nsw i64 %149, 4
%147 = icmp eq i64 %146, 2097152
br i1 %147, label %155, label %148
148: ; preds = %145, %120
%149 = phi i64 [ 0, %120 ], [ %146, %145 ]
%150 = getelementptr inbounds i64, i64* %83, i64 %149
%151 = load i64, i64* %150
%152 = getelementptr inbounds i64, i64* %58, i64 %149
%153 = load i64, i64* %152
%154 = icmp eq i64 %151, %153
br i1 %154, label %124, label %155
155: ; preds = %113, %89, %96, %103, %148, %124, %131, %138, %145
%156 = phi i8* [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %148 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %124 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %131 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %138 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.13, i64 0, i64 0), %145 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %103 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %96 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %89 ], [ getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0), %113 ]
%157 = phi i32 [ 1, %148 ], [ 1, %124 ], [ 1, %131 ], [ 1, %138 ], [ 0, %145 ], [ 1, %103 ], [ 1, %96 ], [ 1, %89 ], [ 1, %113 ]
%158 = call i32 @puts(i8* dereferenceable(1) %156)
%159 = call i32 @free(i64* %83)
%160 = call i32 @free(i64* %58)
ret i32 %157
}