// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xb8, %rsp
movl $0x0, 0xb4(%rsp)
movl %edi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq $0x0, 0x98(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x1ee7(%rip), %rsi      # 0x31b0
movl $0x24, %edx
callq 0x1040
movq 0x1f06(%rip), %rax      # 0x31e0
movq %rax, 0x60(%rsp)
movq 0x1f02(%rip), %rax      # 0x31e8
movq %rax, 0x68(%rsp)
movq 0x1eee(%rip), %rax      # 0x31e0
movq %rax, 0x50(%rsp)
movq 0x1eea(%rip), %rax      # 0x31e8
movq %rax, 0x58(%rsp)
movq 0x1ed6(%rip), %rax      # 0x31e0
movq %rax, 0x40(%rsp)
movq 0x1ed2(%rip), %rax      # 0x31e8
movq %rax, 0x48(%rsp)
movq $0x0, 0x30(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x1cf5(%rip), %rdi      # 0x302a
movb $0x0, %al
callq 0x1030
movq $0x0, 0xa0(%rsp)
cmpq $0x9, 0xa0(%rsp)
jae 0x13a3
movq 0xa0(%rsp), %rsi
movq 0xa0(%rsp), %rax
movss 0x70(%rsp,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1cc4(%rip), %rdi      # 0x3038
movb $0x1, %al
callq 0x1030
leaq 0x70(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x17f0
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x1348
leaq 0x1c99(%rip), %rdi      # 0x3043
movb $0x0, %al
callq 0x1030
movq $0x0, 0xa0(%rsp)
cmpq $0x9, 0xa0(%rsp)
jae 0x141a
movq 0xa0(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1830
movq 0x28(%rsp), %rsi
movss 0x70(%rsp,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1c54(%rip), %rdi      # 0x3051
movb $0x1, %al
callq 0x1030
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x13bd
leaq 0x1c3a(%rip), %rdi      # 0x305b
movb $0x0, %al
callq 0x1030
movq $0x0, 0xa0(%rsp)
cmpq $0x9, 0xa0(%rsp)
jae 0x1467
leaq 0x70(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x17f0
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x1434
movss 0x7c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1c1a(%rip), %rdi      # 0x3092
movsd 0x1b88(%rip), %xmm1     # 0x3008
movb $0x2, %al
callq 0x1030
movss 0x1b75(%rip), %xmm0     # 0x3004
movss %xmm0, 0x7c(%rsp)
leaq 0x70(%rsp), %rdi
movq 0x98(%rsp), %rsi
movl $0x3, %edx
callq 0x18a0
movq $0x0, 0xa0(%rsp)
cmpq $0x9, 0xa0(%rsp)
jae 0x1515
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1830
movq 0x20(%rsp), %rsi
movss 0x70(%rsp,%rax,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1ba4(%rip), %rdi      # 0x309c
movb $0x1, %al
callq 0x1030
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x14b8
leaq 0x1b8b(%rip), %rdi      # 0x30a7
movb $0x0, %al
callq 0x1030
movq $0x0, 0x98(%rsp)
movq $0x0, 0xa0(%rsp)
cmpq $0x4, 0xa0(%rsp)
jae 0x1590
movq 0xa0(%rsp), %rsi
movq 0xa0(%rsp), %rax
movl 0x60(%rsp,%rax,4), %edx
leaq 0x1b62(%rip), %rdi      # 0x30c3
movb $0x0, %al
callq 0x1030
leaq 0x60(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x18e0
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x153b
leaq 0x1b3c(%rip), %rdi      # 0x30d3
movb $0x0, %al
callq 0x1030
movq $0x0, 0xa0(%rsp)
cmpq $0x4, 0xa0(%rsp)
jae 0x1601
movq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1920
movq 0x18(%rsp), %rsi
movl 0x60(%rsp,%rax,4), %edx
leaq 0x1adf(%rip), %rdi      # 0x30c3
movb $0x0, %al
callq 0x1030
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x15aa
leaq 0x1ae7(%rip), %rdi      # 0x30ef
movb $0x0, %al
callq 0x1030
movq $0x0, 0x98(%rsp)
movq $0x0, 0xa0(%rsp)
cmpq $0x4, 0xa0(%rsp)
jae 0x167c
movq 0xa0(%rsp), %rsi
movq 0xa0(%rsp), %rax
movl 0x50(%rsp,%rax,4), %edx
leaq 0x1a76(%rip), %rdi      # 0x30c3
movb $0x0, %al
callq 0x1030
leaq 0x50(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1990
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x1627
leaq 0x1a99(%rip), %rdi      # 0x311c
movb $0x0, %al
callq 0x1030
movq $0x0, 0xa0(%rsp)
cmpq $0x4, 0xa0(%rsp)
jae 0x16ed
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x19d0
movq 0x10(%rsp), %rsi
movl 0x50(%rsp,%rax,4), %edx
leaq 0x19f3(%rip), %rdi      # 0x30c3
movb $0x0, %al
callq 0x1030
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x1696
leaq 0x1a55(%rip), %rdi      # 0x3149
movb $0x0, %al
callq 0x1030
movq $0x0, 0x98(%rsp)
movq $0x0, 0xa0(%rsp)
cmpq $0x4, 0xa0(%rsp)
jae 0x1769
movq 0xa0(%rsp), %rsi
movq 0x38(%rsp), %rax
movq 0xa0(%rsp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x1986(%rip), %rdi      # 0x30c3
movb $0x0, %al
callq 0x1030
leaq 0x30(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x1a40
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x1713
leaq 0x1a0b(%rip), %rdi      # 0x317b
movb $0x0, %al
callq 0x1030
movq $0x0, 0xa0(%rsp)
cmpq $0x4, 0xa0(%rsp)
jae 0x17e6
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x30(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x1a80
movq (%rsp), %rsi
movq %rax, %rcx
movq 0x8(%rsp), %rax
movl (%rax,%rcx,4), %edx
leaq 0x18fa(%rip), %rdi      # 0x30c3
movb $0x0, %al
callq 0x1030
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x1783
xorl %eax, %eax
addq $0xb8, %rsp
retq