// File: /workspace/github_c_makefile_star2_O2/theck01[P]offbrand_lib/src/tests/obmap_test.c
// Function: main
int main (){

  uint32_t i;

  obmap *test_map, *map_copy;
  obtest *a, *b, *c, *d, *e, *f, *g, *h;
  obtest *test_array[ARRAY_SIZE];
  obtest *test;

  test_map = obmap_new();
  a = obtest_new(1);
  b = obtest_new(2);
  c = obtest_new(3);
  d = obtest_new(103923);
  e = obtest_new(1+MAP_CAPACITIES[0]); /* ensures hash collision with a */
  f = obtest_new(1+2*MAP_CAPACITIES[0]);
  g = obtest_new(1+3*MAP_CAPACITIES[0]);
  h = obtest_new(1+4*MAP_CAPACITIES[0]);

  assert(ob_hash((obj *)a)%MAP_CAPACITIES[0] == ob_hash((obj *)e)%MAP_CAPACITIES[0]);

  assert(obmap_lookup(test_map, (obj *)a) == NULL);

  obmap_insert(test_map, (obj *)a, (obj *)b);
  test = (obtest *)obmap_lookup(test_map, (obj *)a);

  assert(test);
  assert(ob_compare((obj *)b, (obj *)test) == OB_EQUAL_TO);
  assert(ob_reference_count((obj *)test) > 1);

  obmap_insert(test_map, (obj *)e, (obj *)c);
  obmap_insert(test_map, (obj *)f, (obj *)d);
  obmap_insert(test_map, (obj *)g, (obj *)e);
  obmap_insert(test_map, (obj *)h, (obj *)f);
  test = (obtest *)obmap_lookup(test_map, (obj *)a);

  assert(ob_compare((obj *)b, (obj *)test) == OB_EQUAL_TO);
  assert(ob_compare((obj *)c, (obj *)test) != OB_EQUAL_TO);

  test = (obtest *)obmap_lookup(test_map, (obj *)e);

  assert(ob_compare((obj *)c, (obj *)test) == OB_EQUAL_TO);
  assert(ob_compare((obj *)b, (obj *)test) != OB_EQUAL_TO);

  test = (obtest *)obmap_lookup(test_map, (obj *)a);
  obmap_insert(test_map, (obj *)a, NULL); /* remove binding of a -> b */

  assert(obmap_lookup(test_map, (obj *)a) == NULL);
  assert(ob_reference_count((obj *)test) == 1);

  test = (obtest *)obmap_lookup(test_map, (obj *)h);
  assert(ob_compare((obj *)f, (obj *)test) == OB_EQUAL_TO);

  map_copy = obmap_copy(test_map);
  obmap_insert(test_map, (obj *)e, NULL); /* remove binding of e -> c */
  test = (obtest *)obmap_lookup(map_copy, (obj *)e);

  assert(ob_compare((obj *)test, (obj *)c) == OB_EQUAL_TO);

  obmap_remove(test_map, (obj *)e);
  test = (obtest *)obmap_lookup(map_copy, (obj *)e);

  assert(ob_compare((obj *)test, (obj *)c) == OB_EQUAL_TO);

  test = (obtest *)obmap_lookup(test_map, (obj *)e);

  assert(test == NULL);

  assert(ob_hash((obj *)test_map) != ob_hash((obj *)map_copy));
  assert(ob_compare((obj *)test_map, (obj *)map_copy) != OB_EQUAL_TO);

  obmap_insert(test_map, (obj *)e, (obj *)c);

  assert(ob_hash((obj *)test_map) == ob_hash((obj *)map_copy));
  assert(ob_compare((obj *)test_map, (obj *)map_copy) == OB_EQUAL_TO);

  obmap_clear(map_copy);

  assert(obmap_lookup(map_copy, (obj *)e) == NULL);
  assert(obmap_lookup(map_copy, (obj *)a) == NULL);
  assert(obmap_lookup(map_copy, (obj *)f) == NULL);

  for(i=0; i<ARRAY_SIZE; i++){
    test_array[i] = obtest_new(i);
    obmap_insert(test_map, (obj *)test_array[i], (obj *)test_array[i]);
  }

  for(i=0; i<ARRAY_SIZE; i++)
    assert(ob_compare((obj *) test_array[i],
                   obmap_lookup(test_map, (obj *)test_array[i])) ==OB_EQUAL_TO);

  ob_release((obj *)a);
  ob_release((obj *)b);
  ob_release((obj *)c);
  ob_release((obj *)d);
  ob_release((obj *)e);
  ob_release((obj *)f);
  ob_release((obj *)g);
  ob_release((obj *)h);

  ob_release((obj *)test_map);
  ob_release((obj *)map_copy);

  for(i=0; i<ARRAY_SIZE; i++)
    ob_release((obj *)test_array[i]);

  printf("obmap: TESTS PASSED\n");

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4048, %rsp           # imm = 0x4048
callq 0x18c8
movq %rax, %rbx
pushq $0x1
popq %rdi
callq 0x2518
movq %rax, %rbp
pushq $0x2
popq %rdi
callq 0x2518
movq %rax, 0x8(%rsp)
pushq $0x3
popq %rdi
callq 0x2518
movq %rax, %r14
movl $0x195f3, %edi          # imm = 0x195F3
callq 0x2518
movq %rax, 0x20(%rsp)
leaq 0x41c2(%rip), %rax      # 0x53f0
movl (%rax), %r13d
leal 0x1(%r13), %edi
callq 0x2518
movq %rax, %r12
leal 0x1(,%r13,2), %edi
callq 0x2518
movq %rax, 0x28(%rsp)
leal 0x1(%r13,%r13,2), %edi
callq 0x2518
movq %rax, 0x18(%rsp)
leal 0x1(,%r13,4), %edi
callq 0x2518
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
callq 0x32ba
xorl %edx, %edx
divq %r13
movq %rdx, %r15
movq %r12, (%rsp)
movq %r12, %rdi
callq 0x32ba
xorl %edx, %edx
divq %r13
cmpl %edx, %r15d
jne 0x165d
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1efb
testq %rax, %rax
jne 0x1679
movq %rbx, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdx
callq 0x1b26
movq %rbx, %rdi
movq %rbp, 0x38(%rsp)
movq %rbp, %rsi
callq 0x1efb
testq %rax, %rax
movq (%rsp), %r13
movq 0x28(%rsp), %rbp
je 0x1695
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x32f3
testb %al, %al
jne 0x16b1
movq %r15, %rdi
callq 0x3414
cmpl $0x1, %eax
jbe 0x16cd
movq %rbp, %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rbp
movq %r14, %rdx
callq 0x1b26
movq %rbx, %rdi
movq %r12, %rsi
movq 0x20(%rsp), %rdx
callq 0x1b26
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r13, %rdx
callq 0x1b26
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x1b26
movq %rbx, %rdi
movq 0x38(%rsp), %r14
movq %r14, %rsi
callq 0x1efb
movq %rax, %r15
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x32f3
testb %al, %al
jne 0x16e9
movq %rbp, %rdi
movq %r15, %rsi
callq 0x32f3
testb %al, %al
je 0x1705
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1efb
movq %rax, %r15
movq %rbp, %rdi
movq %rax, %rsi
callq 0x32f3
testb %al, %al
jne 0x1721
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x32f3
testb %al, %al
je 0x173d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1efb
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1b26
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1efb
testq %rax, %rax
jne 0x1759
movq %r15, %rdi
callq 0x3414
cmpl $0x1, %eax
jne 0x1775
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x1efb
movq %r12, %rdi
movq %rax, %rsi
callq 0x32f3
testb %al, %al
jne 0x1791
movq %rbx, %rdi
callq 0x1998
movq %rax, %r15
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x1b26
movq %r15, %rdi
movq %r13, %rsi
callq 0x1efb
movq %rax, %rdi
movq %rbp, %rsi
callq 0x32f3
testb %al, %al
jne 0x17ad
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1f4f
movq %r15, %rdi
movq %r13, %rsi
callq 0x1efb
movq %rax, %rdi
movq %rbp, %rsi
callq 0x32f3
testb %al, %al
jne 0x17c9
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1efb
testq %rax, %rax
jne 0x17e5
movq %rbx, %rdi
callq 0x32ba
movq %rax, %r13
movq %r15, %rdi
callq 0x32ba
cmpq %rax, %r13
je 0x1801
movq %rbx, %rdi
movq %r15, %rsi
callq 0x32f3
testb %al, %al
movq (%rsp), %rsi
je 0x181d
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x1b26
movq %rbx, %rdi
callq 0x32ba
movq %rax, %r13
movq %r15, %rdi
callq 0x32ba
cmpq %rax, %r13
jne 0x1839
movq %rbx, %rdi
movq %r15, %rsi
callq 0x32f3
testb %al, %al
jne 0x1855
movq %r15, %rdi
callq 0x1fa4
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x1efb
testq %rax, %rax
jne 0x1871
movq %r15, %rdi
movq %r14, %rsi
callq 0x1efb
testq %rax, %rax
jne 0x188d
movq %r15, %rdi
movq %r12, %rsi
callq 0x1efb
testq %rax, %rax
jne 0x18a9
xorl %r13d, %r13d
movq 0x8(%rsp), %r12
cmpq $0x800, %r13            # imm = 0x800
je 0x1575
movl %r13d, %edi
callq 0x2518
movq %rax, 0x40(%rsp,%r13,8)
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0x1b26
incq %r13
jmp 0x154c
movq %rbp, 0x30(%rsp)
movq %r12, %rbp
xorl %r12d, %r12d
cmpq $0x800, %r12            # imm = 0x800
je 0x15c8
movq 0x40(%rsp,%r12,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1efb
movq %r13, %rdi
movq %rax, %rsi
callq 0x32f3
incq %r12
testb %al, %al
je 0x1580
leaq 0x3dc6(%rip), %rdi      # 0x5378
leaq 0x3a96(%rip), %rsi      # 0x504f
leaq 0x3aa6(%rip), %rcx      # 0x5066
pushq $0x6b
popq %rdx
callq 0x1050
movq %r14, %rdi
callq 0x33aa
movq %rbp, %rdi
callq 0x33aa
movq 0x30(%rsp), %rdi
callq 0x33aa
movq 0x20(%rsp), %rdi
callq 0x33aa
movq (%rsp), %rdi
callq 0x33aa
movq 0x28(%rsp), %rdi
callq 0x33aa
movq 0x18(%rsp), %rdi
callq 0x33aa
movq 0x10(%rsp), %rdi
callq 0x33aa
movq %rbx, %rdi
callq 0x33aa
movq %r15, %rdi
callq 0x33aa
xorl %ebx, %ebx
cmpq $0x800, %rbx            # imm = 0x800
je 0x163d
movq 0x40(%rsp,%rbx,8), %rdi
callq 0x33aa
incq %rbx
jmp 0x1625
leaq 0x3d92(%rip), %rdi      # 0x53d6
callq 0x1040
xorl %eax, %eax
addq $0x4048, %rsp           # imm = 0x4048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x39a0(%rip), %rdi      # 0x5004
leaq 0x39e4(%rip), %rsi      # 0x504f
leaq 0x39f4(%rip), %rcx      # 0x5066
pushq $0x25
jmp 0x15c2
leaq 0x39f1(%rip), %rdi      # 0x5071
leaq 0x39c8(%rip), %rsi      # 0x504f
leaq 0x39d8(%rip), %rcx      # 0x5066
pushq $0x27
jmp 0x15c2
leaq 0x39fe(%rip), %rdi      # 0x509a
leaq 0x39ac(%rip), %rsi      # 0x504f
leaq 0x39bc(%rip), %rcx      # 0x5066
pushq $0x2c
jmp 0x15c2
leaq 0x39e7(%rip), %rdi      # 0x509f
leaq 0x3990(%rip), %rsi      # 0x504f
leaq 0x39a0(%rip), %rcx      # 0x5066
pushq $0x2d
jmp 0x15c2
leaq 0x39fc(%rip), %rdi      # 0x50d0
leaq 0x3974(%rip), %rsi      # 0x504f
leaq 0x3984(%rip), %rcx      # 0x5066
pushq $0x2e
jmp 0x15c2
leaq 0x39af(%rip), %rdi      # 0x509f
leaq 0x3958(%rip), %rsi      # 0x504f
leaq 0x3968(%rip), %rcx      # 0x5066
pushq $0x36
jmp 0x15c2
leaq 0x39e8(%rip), %rdi      # 0x50f4
leaq 0x393c(%rip), %rsi      # 0x504f
leaq 0x394c(%rip), %rcx      # 0x5066
pushq $0x37
jmp 0x15c2
leaq 0x39fd(%rip), %rdi      # 0x5125
leaq 0x3920(%rip), %rsi      # 0x504f
leaq 0x3930(%rip), %rcx      # 0x5066
pushq $0x3b
jmp 0x15c2
leaq 0x3a12(%rip), %rdi      # 0x5156
leaq 0x3904(%rip), %rsi      # 0x504f
leaq 0x3914(%rip), %rcx      # 0x5066
pushq $0x3c
jmp 0x15c2
leaq 0x3911(%rip), %rdi      # 0x5071
leaq 0x38e8(%rip), %rsi      # 0x504f
leaq 0x38f8(%rip), %rcx      # 0x5066
pushq $0x41
jmp 0x15c2
leaq 0x3a0b(%rip), %rdi      # 0x5187
leaq 0x38cc(%rip), %rsi      # 0x504f
leaq 0x38dc(%rip), %rcx      # 0x5066
pushq $0x42
jmp 0x15c2
leaq 0x3a14(%rip), %rdi      # 0x51ac
leaq 0x38b0(%rip), %rsi      # 0x504f
leaq 0x38c0(%rip), %rcx      # 0x5066
pushq $0x45
jmp 0x15c2
leaq 0x3a29(%rip), %rdi      # 0x51dd
leaq 0x3894(%rip), %rsi      # 0x504f
leaq 0x38a4(%rip), %rcx      # 0x5066
pushq $0x4b
jmp 0x15c2
leaq 0x3a0d(%rip), %rdi      # 0x51dd
leaq 0x3878(%rip), %rsi      # 0x504f
leaq 0x3888(%rip), %rcx      # 0x5066
pushq $0x50
jmp 0x15c2
leaq 0x3a22(%rip), %rdi      # 0x520e
leaq 0x385c(%rip), %rsi      # 0x504f
leaq 0x386c(%rip), %rcx      # 0x5066
pushq $0x54
jmp 0x15c2
leaq 0x3a13(%rip), %rdi      # 0x521b
leaq 0x3840(%rip), %rsi      # 0x504f
leaq 0x3850(%rip), %rcx      # 0x5066
pushq $0x56
jmp 0x15c2
leaq 0x3a2c(%rip), %rdi      # 0x5250
leaq 0x3824(%rip), %rsi      # 0x504f
leaq 0x3834(%rip), %rcx      # 0x5066
pushq $0x57
jmp 0x15c2
leaq 0x3a4c(%rip), %rdi      # 0x528c
leaq 0x3808(%rip), %rsi      # 0x504f
leaq 0x3818(%rip), %rcx      # 0x5066
pushq $0x5b
jmp 0x15c2
leaq 0x3a65(%rip), %rdi      # 0x52c1
leaq 0x37ec(%rip), %rsi      # 0x504f
leaq 0x37fc(%rip), %rcx      # 0x5066
pushq $0x5c
jmp 0x15c2
leaq 0x3a85(%rip), %rdi      # 0x52fd
leaq 0x37d0(%rip), %rsi      # 0x504f
leaq 0x37e0(%rip), %rcx      # 0x5066
pushq $0x60
jmp 0x15c2
leaq 0x3a92(%rip), %rdi      # 0x5326
leaq 0x37b4(%rip), %rsi      # 0x504f
leaq 0x37c4(%rip), %rcx      # 0x5066
pushq $0x61
jmp 0x15c2
leaq 0x3a9f(%rip), %rdi      # 0x534f
leaq 0x3798(%rip), %rsi      # 0x504f
leaq 0x37a8(%rip), %rcx      # 0x5066
pushq $0x62
jmp 0x15c2
nopl (%rax)