// File: /workspace/github_cpp_makefile_star2_O1/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
movw $0x1, 0x8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movups %xmm0, 0x20(%rsp)
movups %xmm0, 0x2c(%rsp)
movaps 0x12c4(%rip), %xmm1     # 0x3010
movups %xmm1, 0x3c(%rsp)
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movups %xmm0, 0x60(%rsp)
movups %xmm0, 0x70(%rsp)
movq %rax, 0x80(%rsp)
leaq 0x149e(%rip), %rdi      # 0x3217
leaq 0x14d1(%rip), %rsi      # 0x3251
callq 0x11a0
testq %rax, %rax
je 0x1fed
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 0x1ff2
movl $0x16, %eax
cmpq $0x10, %r15
jb 0x1ea7
cmpl $0x0, 0x80(%rsp)
jne 0x1e01
movq %rbx, 0x60(%rsp)
movq %r15, 0x68(%rsp)
movl $0x4d554e93, %eax       # imm = 0x4D554E93
xorl (%rbx), %eax
movzwl 0x4(%rbx), %ecx
xorl $0x5950, %ecx           # imm = 0x5950
orl %eax, %ecx
je 0x1e22
xorl %ecx, %ecx
movl $0x16, %eax
movq %rbx, %rsi
jmp 0x1e85
movzbl 0x6(%rbx), %eax
movb %al, 0x8(%rsp)
movb 0x7(%rbx), %cl
movb %cl, 0x9(%rsp)
cmpl $0x2, %eax
je 0x1e53
cmpl $0x1, %eax
jne 0x1fc2
movsbl 0x8(%rbx), %ecx
movsbl 0x9(%rbx), %eax
shll $0x8, %eax
addl %ecx, %eax
movl $0xa, %esi
jmp 0x1e77
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
cltq
movq %rax, 0x10(%rsp)
addq %rbx, %rsi
xorl %eax, %eax
movb $0x1, %cl
testb %cl, %cl
je 0x1ea7
movq %rbx, %rax
addq %r15, %rax
leaq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rdx
addq %rsi, %rdx
cmpq %rax, %rdx
cmovaeq %rax, %rdx
callq 0x2472
testl %eax, %eax
jne 0x1eb5
leaq 0x8(%rsp), %rdi
callq 0x1b5e
testl %eax, %eax
jne 0x1ff7
movq %r14, %rdi
callq 0x1080
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x1fce
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 0x1edd
ucomiss 0x1143(%rip), %xmm0     # 0x303c
jne 0x1fce
jp 0x1fce
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1f1d
callq 0x1030
movq $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1f35
callq 0x1030
movq $0x0, 0x28(%rsp)
testq %r14, %r14
je 0x1f53
cmpq $0x0, 0x60(%rsp)
jne 0x1f53
movq %r14, %rdi
callq 0x1030
movq $0x0, 0x50(%rsp)
cmpl $0x0, 0x80(%rsp)
je 0x1f75
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x1170
movq $0x0, 0x60(%rsp)
movl 0x58(%rsp), %edi
testl %edi, %edi
js 0x1f8a
callq 0x10e0
movl $0xffffffff, 0x58(%rsp) # imm = 0xFFFFFFFF
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1fa2
callq 0x1030
movq $0x0, 0x70(%rsp)
movq %rbx, %rdi
callq 0x1030
leaq 0x12e8(%rip), %rdi      # 0x3299
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x1060
xorl %ecx, %ecx
movl $0x5f, %eax
jmp 0x1e1d
leaq 0x114e(%rip), %rdi      # 0x3123
leaq 0x112c(%rip), %rsi      # 0x3108
leaq 0x1223(%rip), %rcx      # 0x3206
movl $0xaa, %edx
callq 0x10d0
callq 0x1301
callq 0x12c0
movl %eax, %edi
callq 0x12d5