// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/src/test_heap-def.c
// Function: main
int
main (int argc VL_UNUSED, char** argv VL_UNUSED)
{
  vl_uindex i ;
  vl_size numNodes = 0 ;
  float data [] = {1.01, 5.02, 8, 0.1, 100, 3, 9, 4, 1.02} ;
  S data_s [] = {{5}, {7}, {9}, {1}} ;
  S data_s_track [] = {{5}, {7}, {9}, {1}} ;
  int data_h [] = {5, 7, 9, 1} ;
  H h ;
  h.numNodes = 0 ;
  h.array = data_h ;

  printf("Pushing heap\n") ;
  for (i = 0 ; i < sizeof(data) / sizeof(data[0]) ; ++i) {
    printf ("%5" VL_FMT_UINDEX ": %f\n", i, data[i]) ;
    vl_heap_float_push (data, &numNodes) ;
  }

  printf("Popping heap\n") ;
  for (i = 0 ; i < sizeof(data) / sizeof(data[0]) ; ++i) {
    printf ("%" VL_FMT_UINDEX ": %f\n", i, data[vl_heap_float_pop (data, &numNodes)]) ;
  }

  printf("Refilling, updating fourth element, and popping again\n") ;
  for (i = 0 ; i < sizeof(data) / sizeof(data[0]) ; ++i) {
    vl_heap_float_push (data, &numNodes) ;
  }
  printf("%f -> %f\n", data[3], 9.01) ;
  data [3] = 9.01 ;
  vl_heap_float_update (data, numNodes, 3) ;
  for (i = 0 ; i < sizeof(data) / sizeof(data[0]) ; ++i) {
    printf ("%" VL_FMT_UINDEX ":  %f\n", i, data[vl_heap_float_pop (data, &numNodes)]) ;
  }

  printf("Pushing heap of structures\n") ;
  numNodes = 0 ;
  for (i = 0 ; i < sizeof(data_s) / sizeof(data_s[0]) ; ++i) {
    printf ("s[%" VL_FMT_UINDEX "].x = %d\n", i, data_s[i].x) ;
    s_heap_push (data_s, &numNodes) ;
  }

  printf("Popping heap of structures\n") ;
  for (i = 0 ; i < sizeof(data_s) / sizeof(data_s[0]) ; ++i) {
    printf ("s[%" VL_FMT_UINDEX "].x = %d\n", i, data_s[s_heap_pop (data_s, &numNodes)].x) ;
  }

  printf("Pushing heap of structures with custom swap\n") ;
  numNodes = 0 ;
  for (i = 0 ; i < sizeof(data_s) / sizeof(data_s[0]) ; ++i) {
    printf ("s[%" VL_FMT_UINDEX "].x = %d\n", i, data_s_track[i].x) ;
    track_s_heap_push (data_s_track, &numNodes) ;
  }

  printf("Popping heap of structures with custom swap\n") ;
  for (i = 0 ; i < sizeof(data_s) / sizeof(data_s[0]) ; ++i) {
    printf ("s[%" VL_FMT_UINDEX "].x = %d\n", i, data_s_track
               [track_s_heap_pop (data_s_track, &numNodes)].x) ;
  }

  printf("Pushing heap of structures with custom container\n") ;
  numNodes = 0 ;
  for (i = 0 ; i < sizeof(data_h) / sizeof(data_h[0]) ; ++i) {
    printf ("s[%" VL_FMT_UINDEX "].x = %d\n", i, h.array[i]) ;
    h_heap_push (&h, &h.numNodes) ;
  }

  printf("Popping heap of structures with custom container\n") ;
  for (i = 0 ; i < sizeof(data_h) / sizeof(data_h[0]) ; ++i) {
    printf ("s[%" VL_FMT_UINDEX "].x = %d\n", i, h.array
               [h_heap_pop (&h, &h.numNodes)]) ;
  }

  return 0 ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x38(%rsp), %rbx
andq $0x0, (%rbx)
movaps 0x1019(%rip), %xmm0     # 0x21c0
leaq 0x40(%rsp), %r14
movaps %xmm0, 0x10(%r14)
movaps 0xff8(%rip), %xmm0      # 0x21b0
movaps %xmm0, (%r14)
movl $0x3f828f5c, 0x20(%r14) # imm = 0x3F828F5C
movaps 0x1015(%rip), %xmm0     # 0x21e0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x20(%rsp)
movaps 0x1005(%rip), %xmm0     # 0x21e0
movaps %xmm0, 0x10(%rsp)
leaq 0xe7d(%rip), %rdi       # 0x2064
callq 0x1030
xorl %r15d, %r15d
leaq 0xe34(%rip), %r12       # 0x202a
cmpq $0x9, %r15
je 0x1220
cvtss2sd 0x40(%rsp,%r15,4), %xmm0
movq %r12, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1040
movq %r14, %rdi
movq %rbx, %rsi
callq 0x166d
incq %r15
jmp 0x11f6
leaq 0xe4a(%rip), %rdi       # 0x2071
callq 0x1030
xorl %ebx, %ebx
leaq 0x40(%rsp), %r14
leaq 0x38(%rsp), %r15
leaq 0xdf6(%rip), %r12       # 0x2035
cmpq $0x9, %rbx
je 0x1268
movq %r14, %rdi
movq %r15, %rsi
callq 0x167e
cvtss2sd 0x40(%rsp,%rax,4), %xmm0
movq %r12, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x1040
incq %rbx
jmp 0x123f
leaq 0xe0f(%rip), %rdi       # 0x207e
callq 0x1030
pushq $0x9
popq %r15
leaq 0x40(%rsp), %rbx
leaq 0x38(%rsp), %r14
subq $0x1, %r15
jb 0x1295
movq %rbx, %rdi
movq %r14, %rsi
callq 0x166d
jmp 0x1282
leaq 0x40(%rsp), %rbx
cvtss2sd 0xc(%rbx), %xmm0
leaq 0xd99(%rip), %rdi       # 0x203f
movsd 0xd5a(%rip), %xmm1      # 0x2008
movb $0x2, %al
callq 0x1040
movl $0x411028f6, 0xc(%rbx)  # imm = 0x411028F6
leaq 0x38(%rsp), %r14
movq (%r14), %rsi
pushq $0x3
popq %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x16e0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x16b5
xorl %r15d, %r15d
leaq 0xd61(%rip), %r12       # 0x2049
cmpq $0x9, %r15
je 0x1311
movq %rbx, %rdi
movq %r14, %rsi
callq 0x167e
cvtss2sd 0x40(%rsp,%rax,4), %xmm0
movq %r12, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1040
incq %r15
jmp 0x12e8
leaq 0xd9c(%rip), %rdi       # 0x20b4
callq 0x1030
leaq 0xd30(%rip), %rbx       # 0x2054
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x1367
movl (%rsp,%r14,4), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
movq %r14, %rax
testq %rax, %rax
je 0x1362
leaq -0x1(%rax), %rcx
shrq %rcx
movl (%rsp,%rax,4), %edx
movl (%rsp,%rcx,4), %esi
cmpl %esi, %edx
jge 0x1362
movl %esi, (%rsp,%rax,4)
movl %edx, (%rsp,%rcx,4)
movq %rcx, %rax
jmp 0x1341
incq %r14
jmp 0x1327
leaq 0xd61(%rip), %rdi       # 0x20cf
callq 0x1030
pushq $0x4
popq %r15
leaq 0xcd6(%rip), %rbx       # 0x2054
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x141d
movq %r15, %rax
decq %r15
movl (%rsp), %ecx
movl -0x4(%rsp,%rax,4), %edx
movl %edx, (%rsp)
movl %ecx, -0x4(%rsp,%rax,4)
cmpq $0x2, %r15
jb 0x1404
xorl %eax, %eax
leaq 0x1(,%rax,2), %rcx
cmpq %r15, %rcx
jae 0x1404
leaq 0x2(,%rax,2), %rdi
cmpq %r15, %rdi
jae 0x13f4
movl (%rsp,%rcx,4), %esi
movl (%rsp,%rdi,4), %r9d
movl (%rsp,%rax,4), %edx
cmpl %r9d, %esi
jge 0x13da
cmpl %esi, %edx
jle 0x1404
leaq (%rsp,%rcx,4), %r8
jmp 0x13e9
cmpl %r9d, %edx
jle 0x1404
leaq (%rsp,%rdi,4), %r8
movl %r9d, %esi
movq %rdi, %rcx
movl %esi, (%rsp,%rax,4)
movl %edx, (%r8)
movq %rcx, %rax
jmp 0x13a7
movl (%rsp,%rax,4), %edx
movl (%rsp,%rcx,4), %esi
cmpl %esi, %edx
jle 0x1404
movl %esi, (%rsp,%rax,4)
movl %edx, (%rsp,%rcx,4)
movl (%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
incq %r14
jmp 0x1381
leaq 0xcc6(%rip), %rdi       # 0x20ea
callq 0x1030
leaq 0xc24(%rip), %rbx       # 0x2054
leaq 0x20(%rsp), %r14
xorl %r15d, %r15d
cmpq $0x4, %r15
je 0x147f
movl 0x20(%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movq %r15, %rsi
testq %rsi, %rsi
je 0x147a
leaq -0x1(%rsi), %r12
shrq %r12
movl 0x20(%rsp,%rsi,4), %eax
cmpl 0x20(%rsp,%r12,4), %eax
jge 0x147a
movq %r14, %rdi
movq %r12, %rdx
callq 0x1153
movq %r12, %rsi
jmp 0x1453
incq %r15
jmp 0x1438
leaq 0xc90(%rip), %rdi       # 0x2116
callq 0x1030
pushq $0x4
popq %rbx
leaq 0x20(%rsp), %r14
leaq 0xbba(%rip), %r15       # 0x2054
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x153a
decq %rbx
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1153
cmpq $0x2, %rbx
jb 0x1521
xorl %esi, %esi
leaq 0x1(,%rsi,2), %r13
cmpq %rbx, %r13
jae 0x1521
leaq 0x2(,%rsi,2), %rax
cmpq %rbx, %rax
jae 0x150b
leaq (%rsi,%rsi), %rcx
movl 0x20(%rsp,%r13,4), %edi
movl 0x28(%rsp,%rcx,4), %ecx
movl 0x20(%rsp,%rsi,4), %edx
cmpl %ecx, %edi
jge 0x14f4
cmpl %edi, %edx
jg 0x14fb
jmp 0x1521
movq %rax, %r13
cmpl %ecx, %edx
jle 0x1521
movq %r14, %rdi
movq %r13, %rdx
callq 0x1153
movq %r13, %rsi
jmp 0x14bf
movl 0x20(%rsp,%rsi,4), %eax
cmpl 0x20(%rsp,%r13,4), %eax
jle 0x1521
movq %r14, %rdi
movq %r13, %rdx
callq 0x1153
movl 0x20(%rsp,%rbx,4), %edx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1040
incq %r12
jmp 0x149d
leaq 0xc01(%rip), %rdi       # 0x2142
callq 0x1030
leaq 0xb07(%rip), %rbx       # 0x2054
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x1593
movl 0x10(%rsp,%r14,4), %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
movq %r14, %rax
testq %rax, %rax
je 0x158e
leaq -0x1(%rax), %rcx
shrq %rcx
movl 0x10(%rsp,%rcx,4), %edx
cmpl %edx, %ebp
jge 0x158e
movl %edx, 0x10(%rsp,%rax,4)
movl %ebp, 0x10(%rsp,%rcx,4)
movq %rcx, %rax
jmp 0x156d
incq %r14
jmp 0x1550
leaq 0xbd9(%rip), %rdi       # 0x2173
callq 0x1030
pushq $0x4
popq %r15
leaq 0xaaa(%rip), %rbx       # 0x2054
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x165c
movq %r15, %rax
decq %r15
movl 0x10(%rsp), %ecx
movl 0xc(%rsp,%rax,4), %edx
movl %edx, 0x10(%rsp)
movl %ecx, 0xc(%rsp,%rax,4)
cmpq $0x2, %r15
jb 0x1642
xorl %eax, %eax
leaq 0x1(,%rax,2), %rcx
cmpq %r15, %rcx
jae 0x1642
leaq 0x2(,%rax,2), %rdi
cmpq %r15, %rdi
jae 0x162e
movl 0x10(%rsp,%rcx,4), %esi
movl 0x10(%rsp,%rdi,4), %r9d
movl 0x10(%rsp,%rax,4), %edx
cmpl %r9d, %esi
jge 0x160f
cmpl %esi, %edx
jle 0x1642
leaq (%rsp,%rcx,4), %r8
addq $0x10, %r8
jmp 0x1622
cmpl %r9d, %edx
jle 0x1642
leaq (%rsp,%rdi,4), %r8
addq $0x10, %r8
movl %r9d, %esi
movq %rdi, %rcx
movl %esi, 0x10(%rsp,%rax,4)
movl %edx, (%r8)
movq %rcx, %rax
jmp 0x15d5
movl 0x10(%rsp,%rax,4), %edx
movl 0x10(%rsp,%rcx,4), %esi
cmpl %esi, %edx
jle 0x1642
movl %esi, 0x10(%rsp,%rax,4)
movl %edx, 0x10(%rsp,%rcx,4)
movl 0x10(%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
incq %r14
jmp 0x15ad
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq