// File: /workspace/github_c_makefile_star2_O3/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 $0x4038, %rsp           # imm = 0x4038
callq 0x1bc0
movq %rax, %rbx
movl $0x1, %edi
callq 0x2774
movq %rax, %r14
movl $0x2, %edi
callq 0x2774
movq %rax, %r12
movl $0x3, %edi
callq 0x2774
movq %rax, 0x8(%rsp)
movl $0x195f3, %edi          # imm = 0x195F3
callq 0x2774
movq %rax, 0x20(%rsp)
leaq 0x3eec(%rip), %rax      # 0x53f0
movl (%rax), %r13d
leal 0x1(%r13), %edi
callq 0x2774
movq %rax, %rbp
leal 0x1(,%r13,2), %edi
callq 0x2774
movq %rax, (%rsp)
leal 0x1(%r13,%r13,2), %edi
callq 0x2774
movq %rax, 0x18(%rsp)
leal 0x1(,%r13,4), %edi
callq 0x2774
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x3620
xorl %edx, %edx
divq %r13
movq %rdx, %r15
movq %rbp, %rdi
callq 0x3620
xorl %edx, %edx
divq %r13
cmpl %edx, %r15d
jne 0x1914
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2211
testq %rax, %rax
jne 0x1933
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1e27
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2211
testq %rax, %rax
movq 0x8(%rsp), %r13
je 0x1952
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x365f
testb %al, %al
jne 0x1971
movq %r15, %rdi
callq 0x374e
cmpl $0x1, %eax
jbe 0x1990
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1e27
movq %rbx, %rdi
movq (%rsp), %r15
movq %r15, %rsi
movq 0x20(%rsp), %rdx
callq 0x1e27
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
callq 0x1e27
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x1e27
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2211
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x365f
testb %al, %al
jne 0x19af
movq %r13, %rdi
movq %r15, %rsi
callq 0x365f
testb %al, %al
je 0x19ce
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2211
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x365f
testb %al, %al
jne 0x19ed
movq %r12, %rdi
movq %r15, %rsi
callq 0x365f
testb %al, %al
je 0x1a0c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2211
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1e27
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2211
testq %rax, %rax
jne 0x1a2b
movq %r15, %rdi
callq 0x374e
cmpl $0x1, %eax
jne 0x1a4a
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x2211
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x365f
testb %al, %al
jne 0x1a69
movq %rbx, %rdi
callq 0x1c97
movq %rax, %r15
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1e27
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2211
movq %rax, %rdi
movq %r13, %rsi
callq 0x365f
testb %al, %al
jne 0x1a88
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2265
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2211
movq %rax, %rdi
movq %r13, %rsi
callq 0x365f
testb %al, %al
jne 0x1aa7
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2211
testq %rax, %rax
jne 0x1ac6
movq %rbx, %rdi
callq 0x3620
movq %rax, %r13
movq %r15, %rdi
callq 0x3620
cmpq %rax, %r13
je 0x1ae5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x365f
testb %al, %al
movq 0x8(%rsp), %rdx
je 0x1b04
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1e27
movq %rbx, %rdi
callq 0x3620
movq %rax, %r13
movq %r15, %rdi
callq 0x3620
cmpq %rax, %r13
jne 0x1b23
movq %rbx, %rdi
movq %r15, %rsi
callq 0x365f
testb %al, %al
jne 0x1b42
movq %r15, %rdi
callq 0x22ba
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2211
testq %rax, %rax
jne 0x1b61
movq %r15, %rdi
movq %r14, %rsi
callq 0x2211
testq %rax, %rax
jne 0x1b80
movq %r14, 0x28(%rsp)
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x2211
testq %rax, %rax
jne 0x1b9f
movq %r12, %r14
xorl %r13d, %r13d
movl %r13d, %edi
callq 0x2774
movq %rax, 0x30(%rsp,%r13,8)
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0x1e27
incq %r13
cmpq $0x800, %r13            # imm = 0x800
jne 0x1809
xorl %r12d, %r12d
movq 0x30(%rsp,%r12,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2211
movq %r13, %rdi
movq %rax, %rsi
callq 0x365f
testb %al, %al
jne 0x18f5
incq %r12
cmpq $0x800, %r12            # imm = 0x800
jne 0x1833
movq 0x28(%rsp), %rdi
callq 0x36e2
movq %r14, %rdi
callq 0x36e2
movq 0x8(%rsp), %rdi
callq 0x36e2
movq 0x20(%rsp), %rdi
callq 0x36e2
movq %rbp, %rdi
callq 0x36e2
movq (%rsp), %rdi
callq 0x36e2
movq 0x18(%rsp), %rdi
callq 0x36e2
movq 0x10(%rsp), %rdi
callq 0x36e2
movq %rbx, %rdi
callq 0x36e2
movq %r15, %rdi
callq 0x36e2
xorl %ebx, %ebx
movq 0x30(%rsp,%rbx,8), %rdi
callq 0x36e2
incq %rbx
cmpq $0x800, %rbx            # imm = 0x800
jne 0x18bf
leaq 0x3afa(%rip), %rdi      # 0x53d6
callq 0x1040
xorl %eax, %eax
addq $0x4038, %rsp           # imm = 0x4038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3a7c(%rip), %rdi      # 0x5378
leaq 0x374c(%rip), %rsi      # 0x504f
leaq 0x375c(%rip), %rcx      # 0x5066
movl $0x6b, %edx
callq 0x1050
leaq 0x36e9(%rip), %rdi      # 0x5004
leaq 0x372d(%rip), %rsi      # 0x504f
leaq 0x373d(%rip), %rcx      # 0x5066
movl $0x25, %edx
callq 0x1050
leaq 0x3737(%rip), %rdi      # 0x5071
leaq 0x370e(%rip), %rsi      # 0x504f
leaq 0x371e(%rip), %rcx      # 0x5066
movl $0x27, %edx
callq 0x1050
leaq 0x3741(%rip), %rdi      # 0x509a
leaq 0x36ef(%rip), %rsi      # 0x504f
leaq 0x36ff(%rip), %rcx      # 0x5066
movl $0x2c, %edx
callq 0x1050
leaq 0x3727(%rip), %rdi      # 0x509f
leaq 0x36d0(%rip), %rsi      # 0x504f
leaq 0x36e0(%rip), %rcx      # 0x5066
movl $0x2d, %edx
callq 0x1050
leaq 0x3739(%rip), %rdi      # 0x50d0
leaq 0x36b1(%rip), %rsi      # 0x504f
leaq 0x36c1(%rip), %rcx      # 0x5066
movl $0x2e, %edx
callq 0x1050
leaq 0x36e9(%rip), %rdi      # 0x509f
leaq 0x3692(%rip), %rsi      # 0x504f
leaq 0x36a2(%rip), %rcx      # 0x5066
movl $0x36, %edx
callq 0x1050
leaq 0x371f(%rip), %rdi      # 0x50f4
leaq 0x3673(%rip), %rsi      # 0x504f
leaq 0x3683(%rip), %rcx      # 0x5066
movl $0x37, %edx
callq 0x1050
leaq 0x3731(%rip), %rdi      # 0x5125
leaq 0x3654(%rip), %rsi      # 0x504f
leaq 0x3664(%rip), %rcx      # 0x5066
movl $0x3b, %edx
callq 0x1050
leaq 0x3743(%rip), %rdi      # 0x5156
leaq 0x3635(%rip), %rsi      # 0x504f
leaq 0x3645(%rip), %rcx      # 0x5066
movl $0x3c, %edx
callq 0x1050
leaq 0x363f(%rip), %rdi      # 0x5071
leaq 0x3616(%rip), %rsi      # 0x504f
leaq 0x3626(%rip), %rcx      # 0x5066
movl $0x41, %edx
callq 0x1050
leaq 0x3736(%rip), %rdi      # 0x5187
leaq 0x35f7(%rip), %rsi      # 0x504f
leaq 0x3607(%rip), %rcx      # 0x5066
movl $0x42, %edx
callq 0x1050
leaq 0x373c(%rip), %rdi      # 0x51ac
leaq 0x35d8(%rip), %rsi      # 0x504f
leaq 0x35e8(%rip), %rcx      # 0x5066
movl $0x45, %edx
callq 0x1050
leaq 0x374e(%rip), %rdi      # 0x51dd
leaq 0x35b9(%rip), %rsi      # 0x504f
leaq 0x35c9(%rip), %rcx      # 0x5066
movl $0x4b, %edx
callq 0x1050
leaq 0x372f(%rip), %rdi      # 0x51dd
leaq 0x359a(%rip), %rsi      # 0x504f
leaq 0x35aa(%rip), %rcx      # 0x5066
movl $0x50, %edx
callq 0x1050
leaq 0x3741(%rip), %rdi      # 0x520e
leaq 0x357b(%rip), %rsi      # 0x504f
leaq 0x358b(%rip), %rcx      # 0x5066
movl $0x54, %edx
callq 0x1050
leaq 0x372f(%rip), %rdi      # 0x521b
leaq 0x355c(%rip), %rsi      # 0x504f
leaq 0x356c(%rip), %rcx      # 0x5066
movl $0x56, %edx
callq 0x1050
leaq 0x3745(%rip), %rdi      # 0x5250
leaq 0x353d(%rip), %rsi      # 0x504f
leaq 0x354d(%rip), %rcx      # 0x5066
movl $0x57, %edx
callq 0x1050
leaq 0x3762(%rip), %rdi      # 0x528c
leaq 0x351e(%rip), %rsi      # 0x504f
leaq 0x352e(%rip), %rcx      # 0x5066
movl $0x5b, %edx
callq 0x1050
leaq 0x3778(%rip), %rdi      # 0x52c1
leaq 0x34ff(%rip), %rsi      # 0x504f
leaq 0x350f(%rip), %rcx      # 0x5066
movl $0x5c, %edx
callq 0x1050
leaq 0x3795(%rip), %rdi      # 0x52fd
leaq 0x34e0(%rip), %rsi      # 0x504f
leaq 0x34f0(%rip), %rcx      # 0x5066
movl $0x60, %edx
callq 0x1050
leaq 0x379f(%rip), %rdi      # 0x5326
leaq 0x34c1(%rip), %rsi      # 0x504f
leaq 0x34d1(%rip), %rcx      # 0x5066
movl $0x61, %edx
callq 0x1050
leaq 0x37a9(%rip), %rdi      # 0x534f
leaq 0x34a2(%rip), %rsi      # 0x504f
leaq 0x34b2(%rip), %rcx      # 0x5066
movl $0x62, %edx
callq 0x1050
nop