// File: /workspace/github_c_makefile_star2_O3/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
movaps 0x1022(%rip), %xmm0     # 0x21c0
movaps %xmm0, 0x10(%rsp)
movaps 0x1006(%rip), %xmm0     # 0x21b0
movaps %xmm0, (%rsp)
movl $0x3f828f5c, 0x20(%rsp) # imm = 0x3F828F5C
movaps 0x1023(%rip), %xmm0     # 0x21e0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps 0x1012(%rip), %xmm0     # 0x21e0
movaps %xmm0, 0x30(%rsp)
leaq 0xe8e(%rip), %rdi       # 0x2068
callq 0x1030
xorl %ebx, %ebx
leaq 0xe46(%rip), %r14       # 0x202e
movss (%rsp,%rbx,4), %xmm0
movss %xmm0, 0x64(%rsp)
cvtss2sd %xmm0, %xmm0
movq %r14, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x1040
movss 0x64(%rsp), %xmm1
testq %rbx, %rbx
je 0x1239
movq %rbx, %rax
leaq -0x1(%rax), %rcx
movq %rcx, %rdx
shrq %rdx
movss (%rsp,%rdx,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1239
movss %xmm0, (%rsp,%rax,4)
movss %xmm1, (%rsp,%rdx,4)
movq %rdx, %rax
cmpq $0x1, %rcx
ja 0x1212
incq %rbx
cmpq $0x9, %rbx
jne 0x11e8
leaq 0xe2c(%rip), %rdi       # 0x2075
callq 0x1030
movl $0x9, %r15d
xorl %ebx, %ebx
leaq 0xddc(%rip), %r14       # 0x2039
movss (%rsp), %xmm0
movss -0x4(%rsp,%r15,4), %xmm1
movss %xmm1, (%rsp)
movss %xmm0, -0x4(%rsp,%r15,4)
decq %r15
cmpq $0x2, %r15
jb 0x12f6
movl $0x1, %ecx
xorl %edx, %edx
xorl %eax, %eax
addq $0x2, %rdx
cmpq %r15, %rdx
jae 0x12dd
movss (%rsp,%rcx,4), %xmm1
movss (%rsp,%rdx,4), %xmm2
ucomiss %xmm1, %xmm2
movss (%rsp,%rax,4), %xmm0
jbe 0x12af
ucomiss %xmm1, %xmm0
jbe 0x12f6
leaq (%rsp,%rcx,4), %rsi
jmp 0x12be
ucomiss %xmm2, %xmm0
jbe 0x12f6
leaq (%rsp,%rdx,4), %rsi
movaps %xmm2, %xmm1
movq %rdx, %rcx
movss %xmm1, (%rsp,%rax,4)
movss %xmm0, (%rsi)
leaq (%rcx,%rcx), %rdx
movq %rcx, %rax
leaq 0x1(,%rcx,2), %rcx
cmpq %r15, %rcx
jb 0x1287
jmp 0x12f6
movss (%rsp,%rax,4), %xmm0
movss (%rsp,%rcx,4), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x12f6
movss %xmm1, (%rsp,%rax,4)
movss %xmm0, (%rsp,%rcx,4)
xorps %xmm0, %xmm0
cvtss2sd (%rsp,%r15,4), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x1040
incq %rbx
cmpq $0x9, %rbx
jne 0x125d
leaq 0xd62(%rip), %rdi       # 0x2082
callq 0x1030
xorl %eax, %eax
testq %rax, %rax
je 0x135b
movss (%rsp,%rax,4), %xmm0
movq %rax, %rcx
leaq -0x1(%rcx), %rdx
movq %rdx, %rsi
shrq %rsi
movss (%rsp,%rsi,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x135b
movss %xmm1, (%rsp,%rcx,4)
movss %xmm0, (%rsp,%rsi,4)
movq %rsi, %rcx
cmpq $0x1, %rdx
ja 0x1334
incq %rax
cmpq $0x9, %rax
jne 0x1327
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
leaq 0xccf(%rip), %rdi       # 0x2043
movsd 0xc8c(%rip), %xmm1      # 0x2008
movb $0x2, %al
callq 0x1040
movl $0x411028f6, 0xc(%rsp)  # imm = 0x411028F6
movss 0x1c(%rsp), %xmm1
movss 0x20(%rsp), %xmm2
ucomiss %xmm1, %xmm2
movss 0xc6e(%rip), %xmm0      # 0x2010
jbe 0x13b0
ucomiss %xmm1, %xmm0
jbe 0x13c7
leaq 0x1c(%rsp), %rax
jmp 0x13bd
ucomiss %xmm2, %xmm0
jbe 0x13c7
leaq 0x20(%rsp), %rax
movaps %xmm2, %xmm1
movss %xmm1, 0xc(%rsp)
movss %xmm0, (%rax)
movl $0x3, %eax
movss 0xc(%rsp), %xmm0
leaq -0x1(%rax), %rcx
movq %rcx, %rdx
shrq %rdx
movss (%rsp,%rdx,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x13f9
movss %xmm1, (%rsp,%rax,4)
movss %xmm0, (%rsp,%rdx,4)
movq %rdx, %rax
cmpq $0x1, %rcx
ja 0x13d2
movl $0x9, %r15d
xorl %ebx, %ebx
leaq 0xc45(%rip), %r14       # 0x204d
movss (%rsp), %xmm0
movss -0x4(%rsp,%r15,4), %xmm1
movss %xmm1, (%rsp)
movss %xmm0, -0x4(%rsp,%r15,4)
decq %r15
cmpq $0x2, %r15
jb 0x14a1
movl $0x1, %ecx
xorl %edx, %edx
xorl %eax, %eax
addq $0x2, %rdx
cmpq %r15, %rdx
jae 0x1488
movss (%rsp,%rcx,4), %xmm1
movss (%rsp,%rdx,4), %xmm2
ucomiss %xmm1, %xmm2
movss (%rsp,%rax,4), %xmm0
jbe 0x145a
ucomiss %xmm1, %xmm0
jbe 0x14a1
leaq (%rsp,%rcx,4), %rsi
jmp 0x1469
ucomiss %xmm2, %xmm0
jbe 0x14a1
leaq (%rsp,%rdx,4), %rsi
movaps %xmm2, %xmm1
movq %rdx, %rcx
movss %xmm1, (%rsp,%rax,4)
movss %xmm0, (%rsi)
leaq (%rcx,%rcx), %rdx
movq %rcx, %rax
leaq 0x1(,%rcx,2), %rcx
cmpq %r15, %rcx
jb 0x1432
jmp 0x14a1
movss (%rsp,%rax,4), %xmm0
movss (%rsp,%rcx,4), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x14a1
movss %xmm1, (%rsp,%rax,4)
movss %xmm0, (%rsp,%rcx,4)
xorps %xmm0, %xmm0
cvtss2sd (%rsp,%r15,4), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x1040
incq %rbx
cmpq $0x9, %rbx
jne 0x1408
leaq 0xbed(%rip), %rdi       # 0x20b8
callq 0x1030
leaq 0xb81(%rip), %rbx       # 0x2058
xorl %r14d, %r14d
movl 0x50(%rsp,%r14,4), %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
testq %r14, %r14
je 0x1519
movq %r14, %rax
leaq -0x1(%rax), %rcx
movq %rcx, %rdx
shrq %rdx
movl 0x50(%rsp,%rdx,4), %esi
cmpl %esi, %ebp
jge 0x1519
movl %esi, 0x50(%rsp,%rax,4)
movl %ebp, 0x50(%rsp,%rdx,4)
movq %rdx, %rax
cmpq $0x1, %rcx
ja 0x14f6
incq %r14
cmpq $0x4, %r14
jne 0x14da
leaq 0xbaa(%rip), %rdi       # 0x20d3
callq 0x1030
movl $0x4, %r15d
leaq 0xb1d(%rip), %rbx       # 0x2058
xorl %r14d, %r14d
movl 0x50(%rsp), %eax
movl 0x4c(%rsp,%r15,4), %ecx
movl %ecx, 0x50(%rsp)
movl %eax, 0x4c(%rsp,%r15,4)
decq %r15
cmpq $0x2, %r15
jb 0x15cf
movl $0x1, %ecx
xorl %edx, %edx
xorl %eax, %eax
addq $0x2, %rdx
cmpq %r15, %rdx
jae 0x15bb
movl 0x50(%rsp,%rcx,4), %edi
movl 0x50(%rsp,%rdx,4), %r9d
movl 0x50(%rsp,%rax,4), %esi
cmpl %r9d, %edi
jge 0x158b
cmpl %edi, %esi
jle 0x15cf
leaq (%rsp,%rcx,4), %r8
addq $0x50, %r8
jmp 0x159e
cmpl %r9d, %esi
jle 0x15cf
leaq (%rsp,%rdx,4), %r8
addq $0x50, %r8
movl %r9d, %edi
movq %rdx, %rcx
movl %edi, 0x50(%rsp,%rax,4)
movl %esi, (%r8)
leaq (%rcx,%rcx), %rdx
movq %rcx, %rax
leaq 0x1(,%rcx,2), %rcx
cmpq %r15, %rcx
jb 0x1562
jmp 0x15cf
movl 0x50(%rsp,%rax,4), %edx
movl 0x50(%rsp,%rcx,4), %esi
cmpl %esi, %edx
jle 0x15cf
movl %esi, 0x50(%rsp,%rax,4)
movl %edx, 0x50(%rsp,%rcx,4)
movl 0x50(%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
incq %r14
cmpq $0x4, %r14
jne 0x153e
leaq 0xaf9(%rip), %rdi       # 0x20ee
callq 0x1030
leaq 0xa57(%rip), %rbx       # 0x2058
leaq 0xa0c(%rip), %r14       # 0x2014
xorl %r15d, %r15d
movl 0x40(%rsp,%r15,4), %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
testq %r15, %r15
je 0x1659
movq %r15, %rsi
leaq -0x1(%rsi), %r13
movq %r13, %r12
shrq %r12
movl 0x40(%rsp,%r12,4), %eax
cmpl %eax, %ebp
jge 0x1659
movl %eax, 0x40(%rsp,%rsi,4)
movl %ebp, 0x40(%rsp,%r12,4)
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1040
movq %r12, %rsi
cmpq $0x1, %r13
ja 0x1627
incq %r15
cmpq $0x4, %r15
jne 0x160b
leaq 0xab1(%rip), %rdi       # 0x211a
callq 0x1030
movl $0x4, %r12d
leaq 0x999(%rip), %rbx       # 0x2014
leaq 0x9d6(%rip), %r14       # 0x2058
xorl %r15d, %r15d
movl 0x40(%rsp), %eax
movl 0x3c(%rsp,%r12,4), %ecx
movl %ecx, 0x40(%rsp)
movl %eax, 0x3c(%rsp,%r12,4)
decq %r12
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1040
cmpq $0x2, %r12
jb 0x1744
movl $0x1, %edx
xorl %eax, %eax
xorl %esi, %esi
addq $0x2, %rax
cmpq %r12, %rax
jae 0x1726
movl 0x40(%rsp,%rdx,4), %edi
movl 0x40(%rsp,%rax,4), %r9d
movl 0x40(%rsp,%rsi,4), %ecx
cmpl %r9d, %edi
jge 0x16e5
cmpl %edi, %ecx
jle 0x1744
leaq (%rsp,%rdx,4), %r8
addq $0x40, %r8
jmp 0x16f8
cmpl %r9d, %ecx
jle 0x1744
leaq (%rsp,%rax,4), %r8
addq $0x40, %r8
movl %r9d, %edi
movq %rax, %rdx
movq %rdx, %r13
movl %edi, 0x40(%rsp,%rsi,4)
movl %ecx, (%r8)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
leaq (,%r13,2), %rax
leaq 0x1(,%r13,2), %rdx
movq %r13, %rsi
cmpq %r12, %rdx
jb 0x16bc
jmp 0x1744
movl 0x40(%rsp,%rsi,4), %eax
movl 0x40(%rsp,%rdx,4), %ecx
cmpl %ecx, %eax
jle 0x1744
movl %ecx, 0x40(%rsp,%rsi,4)
movl %eax, 0x40(%rsp,%rdx,4)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
movl 0x40(%rsp,%r12,4), %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
incq %r15
cmpq $0x4, %r15
jne 0x1685
leaq 0x9dc(%rip), %rdi       # 0x2146
callq 0x1030
leaq 0x8e2(%rip), %rbx       # 0x2058
xorl %r14d, %r14d
movl 0x30(%rsp,%r14,4), %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
testq %r14, %r14
je 0x17b8
movq %r14, %rax
leaq -0x1(%rax), %rcx
movq %rcx, %rdx
shrq %rdx
movl 0x30(%rsp,%rdx,4), %esi
cmpl %esi, %ebp
jge 0x17b8
movl %esi, 0x30(%rsp,%rax,4)
movl %ebp, 0x30(%rsp,%rdx,4)
movq %rdx, %rax
cmpq $0x1, %rcx
ja 0x1795
incq %r14
cmpq $0x4, %r14
jne 0x1779
leaq 0x9af(%rip), %rdi       # 0x2177
callq 0x1030
movl $0x4, %r15d
leaq 0x87e(%rip), %rbx       # 0x2058
xorl %r14d, %r14d
movl 0x30(%rsp), %eax
movl 0x2c(%rsp,%r15,4), %ecx
movl %ecx, 0x30(%rsp)
movl %eax, 0x2c(%rsp,%r15,4)
decq %r15
cmpq $0x2, %r15
jb 0x186e
movl $0x1, %ecx
xorl %edx, %edx
xorl %eax, %eax
addq $0x2, %rdx
cmpq %r15, %rdx
jae 0x185a
movl 0x30(%rsp,%rcx,4), %edi
movl 0x30(%rsp,%rdx,4), %r9d
movl 0x30(%rsp,%rax,4), %esi
cmpl %r9d, %edi
jge 0x182a
cmpl %edi, %esi
jle 0x186e
leaq (%rsp,%rcx,4), %r8
addq $0x30, %r8
jmp 0x183d
cmpl %r9d, %esi
jle 0x186e
leaq (%rsp,%rdx,4), %r8
addq $0x30, %r8
movl %r9d, %edi
movq %rdx, %rcx
movl %edi, 0x30(%rsp,%rax,4)
movl %esi, (%r8)
leaq (%rcx,%rcx), %rdx
movq %rcx, %rax
leaq 0x1(,%rcx,2), %rcx
cmpq %r15, %rcx
jb 0x1801
jmp 0x186e
movl 0x30(%rsp,%rax,4), %edx
movl 0x30(%rsp,%rcx,4), %esi
cmpl %esi, %edx
jle 0x186e
movl %esi, 0x30(%rsp,%rax,4)
movl %edx, 0x30(%rsp,%rcx,4)
movl 0x30(%rsp,%r15,4), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1040
incq %r14
cmpq $0x4, %r14
jne 0x17dd
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq