// File: /workspace/github_cpp_makefile_star2_O3/onai[P]npio/npio_test_c.c
// Function: test4
void test4()
{
  int i, err;
  int64_t *data;
  float total;
  FILE *f;
  void *p;
  size_t sz;
  npio_Array array;

  npio_init_array(&array);
  f = fopen("test1.npy", "r");
  if (!f)
  {
    fprintf(stderr, "could not open test1.npy\n");
    exit(1);
  }

  fseek(f, 0, SEEK_END);
  sz = ftell(f);
  fseek(f, 0, SEEK_SET);
  p = malloc(sz);
  if (fread(p, 1, sz, f) != sz)
  {
    perror("fread");
    exit(1);
  }

  err = npio_load_mem(p, sz, &array);
  if (err)
  {
    fprintf(stderr, "npio_load_mem: %s\n", strerror(err));
    exit(1);
  }

  fclose(f);

  data = (int64_t*) array.data;
  total = 0;
  for (i = 0; i < array.size; ++i)
    total += data[i];

  assert(total == 4950);

  npio_free_array(&array);
  free(p);
  printf("test4 passed\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movb $0x1, 0x8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movups %xmm0, 0x20(%rsp)
movups %xmm0, 0x2c(%rsp)
movaps 0x1376(%rip), %xmm1     # 0x3010
movups %xmm1, 0x3c(%rsp)
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movups %xmm0, 0x70(%rsp)
movq %rax, 0x80(%rsp)
leaq 0x1575(%rip), %rdi      # 0x3237
leaq 0x15a8(%rip), %rsi      # 0x3271
callq 0x11a0
testq %rax, %rax
je 0x1ed3
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1150
movq %r14, %rdi
callq 0x1110
movq %rax, %r15
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1150
movq %r15, %rdi
callq 0x1140
movq %rax, %rbx
movl $0x1, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1070
cmpq %r15, %rax
jne 0x1ed8
movl $0x16, %eax
cmpq $0x10, %r15
jb 0x1ee2
movq %rbx, 0x60(%rsp)
movl $0x4d554e93, %ecx       # imm = 0x4D554E93
xorl (%rbx), %ecx
movq %r15, 0x68(%rsp)
movzwl 0x4(%rbx), %edx
xorl $0x5950, %edx           # imm = 0x5950
orl %ecx, %edx
jne 0x1ee2
movzbl 0x6(%rbx), %eax
movb %al, 0x8(%rsp)
movb 0x7(%rbx), %cl
movb %cl, 0x9(%rsp)
cmpl $0x2, %eax
je 0x1d8a
cmpl $0x1, %eax
jne 0x1edd
movsbl 0x8(%rbx), %ecx
movsbl 0x9(%rbx), %eax
shll $0x8, %eax
addl %ecx, %eax
movl $0xa, %esi
jmp 0x1dae
movsbl 0x8(%rbx), %eax
movsbl 0x9(%rbx), %ecx
shll $0x8, %ecx
addl %eax, %ecx
movsbl 0xa(%rbx), %edx
shll $0x10, %edx
movzbl 0xb(%rbx), %eax
shll $0x18, %eax
addl %edx, %eax
addl %ecx, %eax
movl $0xc, %esi
addq %rbx, %r15
movslq %eax, %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
addq %rbx, %rsi
addq %rsi, %rdx
cmpq %r15, %rdx
cmovaeq %r15, %rdx
callq 0x22e9
testl %eax, %eax
jne 0x1ee2
leaq 0x8(%rsp), %rdi
callq 0x1aba
testl %eax, %eax
jne 0x1ee2
movq %r14, %rdi
callq 0x1080
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x1eb4
movq 0x50(%rsp), %r14
xorps %xmm0, %xmm0
xorl %ecx, %ecx
xorps %xmm1, %xmm1
cvtsi2ssq (%r14,%rcx,8), %xmm1
addss %xmm1, %xmm0
incq %rcx
cmpq %rcx, %rax
jne 0x1e09
ucomiss 0x1237(%rip), %xmm0     # 0x305c
jne 0x1eb4
jp 0x1eb4
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1e40
callq 0x1030
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1e4f
callq 0x1030
movq 0x60(%rsp), %r15
testq %r15, %r15
jne 0x1e61
movq %r14, %rdi
callq 0x1030
cmpl $0x0, 0x80(%rsp)
je 0x1e78
movq 0x68(%rsp), %rsi
movq %r15, %rdi
callq 0x1170
movl 0x58(%rsp), %edi
testl %edi, %edi
js 0x1e85
callq 0x10e0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1e94
callq 0x1030
movq %rbx, %rdi
callq 0x1030
leaq 0x1416(%rip), %rdi      # 0x32b9
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x1060
leaq 0x1288(%rip), %rdi      # 0x3143
leaq 0x1266(%rip), %rsi      # 0x3128
leaq 0x135d(%rip), %rcx      # 0x3226
movl $0xaa, %edx
callq 0x10d0
callq 0x1301
callq 0x12c0
movl $0x5f, %eax
movl %eax, %edi
callq 0x12d5