// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movaps 0x1023(%rip), %xmm0     # 0x21c0
leaq 0x30(%rsp), %rbx
movaps %xmm0, 0x10(%rbx)
movaps 0x1003(%rip), %xmm0     # 0x21b0
movaps %xmm0, (%rbx)
movl $0x3f828f5c, 0x20(%rbx) # imm = 0x3F828F5C
movaps 0x1022(%rip), %xmm0     # 0x21e0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps 0x1011(%rip), %xmm0     # 0x21e0
leaq 0x60(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, (%rsp)
movq %rax, 0x8(%rsp)
leaq 0xe79(%rip), %rdi       # 0x2064
callq 0x1030
xorl %r14d, %r14d
leaq 0xe30(%rip), %r15       # 0x202a
xorps %xmm0, %xmm0
cvtss2sd 0x30(%rsp,%r14,4), %xmm0
movq %r15, %rdi
movq %r14, %rsi
movb $0x1, %al
callq 0x1040
movq %rbx, %rdi
movq %r14, %rsi
callq 0x157c
incq %r14
cmpq $0x9, %r14
jne 0x11fa
leaq 0xe45(%rip), %rdi       # 0x2071
callq 0x1030
movl $0x8, %ebx
xorl %r14d, %r14d
leaq 0x30(%rsp), %r15
leaq 0xdf0(%rip), %r12       # 0x2035
movss 0x30(%rsp), %xmm0
movss 0x30(%rsp,%rbx,4), %xmm1
movss %xmm1, 0x30(%rsp)
movss %xmm0, 0x30(%rsp,%rbx,4)
cmpq $0x2, %rbx
jb 0x1270
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x15a7
xorps %xmm0, %xmm0
cvtss2sd 0x30(%rsp,%rbx,4), %xmm0
movq %r12, %rdi
movq %r14, %rsi
movb $0x1, %al
callq 0x1040
incq %r14
decq %rbx
cmpq $0x9, %r14
jne 0x1245
leaq 0xde5(%rip), %rdi       # 0x207e
callq 0x1030
xorl %ebx, %ebx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x157c
incq %rbx
cmpq $0x9, %rbx
jne 0x12a5
leaq 0x30(%rsp), %rbx
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rbx), %xmm0
leaq 0xd72(%rip), %rdi       # 0x203f
movsd 0xd33(%rip), %xmm1      # 0x2008
movb $0x2, %al
callq 0x1040
movl $0x411028f6, 0xc(%rbx)  # imm = 0x411028F6
movl $0x9, %esi
movl $0x3, %edx
movq %rbx, %rdi
callq 0x15a7
movl $0x3, %esi
movq %rbx, %rdi
callq 0x157c
movl $0x8, %r14d
xorl %r15d, %r15d
leaq 0xd37(%rip), %r12       # 0x2049
movss 0x30(%rsp), %xmm0
movss 0x30(%rsp,%r14,4), %xmm1
movss %xmm1, 0x30(%rsp)
movss %xmm0, 0x30(%rsp,%r14,4)
cmpq $0x2, %r14
jb 0x133f
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x15a7
xorps %xmm0, %xmm0
cvtss2sd 0x30(%rsp,%r14,4), %xmm0
movq %r12, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1040
incq %r15
decq %r14
cmpq $0x9, %r15
jne 0x1312
leaq 0xd4b(%rip), %rdi       # 0x20b4
callq 0x1030
leaq 0xcdf(%rip), %rbx       # 0x2054
leaq 0x20(%rsp), %r14
xorl %r15d, %r15d
movl 0x20(%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movq %r14, %rdi
movq %r15, %rsi
callq 0x161f
incq %r15
cmpq $0x4, %r15
jne 0x137d
leaq 0xd25(%rip), %rdi       # 0x20cf
callq 0x1030
movl $0x3, %ebx
leaq 0x20(%rsp), %r14
leaq 0xc94(%rip), %r15       # 0x2054
xorl %r12d, %r12d
movl 0x20(%rsp), %eax
movl 0x20(%rsp,%rbx,4), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, 0x20(%rsp,%rbx,4)
cmpq $0x2, %rbx
jb 0x13e6
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x1641
movl 0x20(%rsp,%rbx,4), %edx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1040
incq %r12
decq %rbx
cmpq $0x4, %r12
jne 0x13c3
leaq 0xce0(%rip), %rdi       # 0x20ea
callq 0x1030
leaq 0xc3e(%rip), %rbx       # 0x2054
leaq 0x10(%rsp), %r14
xorl %r15d, %r15d
movl 0x10(%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movq %r14, %rdi
movq %r15, %rsi
callq 0x16a7
incq %r15
cmpq $0x4, %r15
jne 0x141e
leaq 0xccb(%rip), %rdi       # 0x2116
callq 0x1030
movl $0x3, %ebx
leaq 0xbb4(%rip), %r14       # 0x2010
leaq 0x10(%rsp), %r15
leaq 0xbec(%rip), %r12       # 0x2054
xorl %r13d, %r13d
movl 0x10(%rsp), %eax
movl 0x10(%rsp,%rbx,4), %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0x10(%rsp,%rbx,4)
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1040
cmpq $0x2, %rbx
jb 0x149d
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x16ec
movl 0x10(%rsp,%rbx,4), %edx
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x1040
incq %r13
decq %rbx
cmpq $0x4, %r13
jne 0x146b
leaq 0xc81(%rip), %rdi       # 0x2142
callq 0x1030
leaq 0xb87(%rip), %rbx       # 0x2054
movq %rsp, %r14
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movl (%rax,%r15,4), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movq (%rsp), %rsi
movq %r14, %rdi
callq 0x17ac
incq (%rsp)
incq %r15
cmpq $0x4, %r15
jne 0x14d3
leaq 0xc6a(%rip), %rdi       # 0x2173
callq 0x1030
movq %rsp, %rbx
leaq 0xb3c(%rip), %r14       # 0x2054
xorl %r15d, %r15d
movq (%rsp), %rax
movq 0x8(%rsp), %r12
leaq -0x1(%rax), %rsi
movq %rsi, (%rsp)
movl (%r12), %ecx
movl -0x4(%r12,%rax,4), %edx
movl %edx, (%r12)
movl %ecx, -0x4(%r12,%rax,4)
cmpq $0x2, %rsi
jb 0x154e
movq %rbx, %rdi
xorl %edx, %edx
callq 0x17d5
movq (%rsp), %rax
movl (%r12,%rax,4), %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
incq %r15
cmpq $0x4, %r15
jne 0x151b
xorl %eax, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq