// File: /workspace/github_c_makefile_star2_O1/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 0x1b80
movq %rax, %rbx
movl $0x1, %edi
callq 0x2730
movq %rax, %r14
movl $0x2, %edi
callq 0x2730
movq %rax, %r12
movl $0x3, %edi
callq 0x2730
movq %rax, 0x8(%rsp)
movl $0x195f3, %edi          # imm = 0x195F3
callq 0x2730
movq %rax, 0x20(%rsp)
leaq 0x3f2c(%rip), %rax      # 0x53f0
movl (%rax), %r13d
leal 0x1(%r13), %edi
callq 0x2730
movq %rax, %rbp
leal 0x1(,%r13,2), %edi
callq 0x2730
movq %rax, (%rsp)
leal 0x1(%r13,%r13,2), %edi
callq 0x2730
movq %rax, 0x18(%rsp)
leal 0x1(,%r13,4), %edi
callq 0x2730
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x352c
xorl %edx, %edx
divq %r13
movq %rdx, %r15
movq %rbp, %rdi
callq 0x352c
xorl %edx, %edx
divq %r13
cmpl %edx, %r15d
jne 0x18d4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21d1
testq %rax, %rax
jne 0x18f3
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1de7
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21d1
testq %rax, %rax
movq 0x8(%rsp), %r13
je 0x1912
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x356b
testb %al, %al
jne 0x1931
movq %r15, %rdi
callq 0x365a
cmpl $0x1, %eax
jbe 0x1950
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1de7
movq %rbx, %rdi
movq (%rsp), %r15
movq %r15, %rsi
movq 0x20(%rsp), %rdx
callq 0x1de7
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
callq 0x1de7
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x1de7
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21d1
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x356b
testb %al, %al
jne 0x196f
movq %r13, %rdi
movq %r15, %rsi
callq 0x356b
testb %al, %al
je 0x198e
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x21d1
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x356b
testb %al, %al
jne 0x19ad
movq %r12, %rdi
movq %r15, %rsi
callq 0x356b
testb %al, %al
je 0x19cc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21d1
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1de7
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21d1
testq %rax, %rax
jne 0x19eb
movq %r15, %rdi
callq 0x365a
cmpl $0x1, %eax
jne 0x1a0a
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x21d1
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x356b
testb %al, %al
jne 0x1a29
movq %rbx, %rdi
callq 0x1c57
movq %rax, %r15
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1de7
movq %r15, %rdi
movq %rbp, %rsi
callq 0x21d1
movq %rax, %rdi
movq %r13, %rsi
callq 0x356b
testb %al, %al
jne 0x1a48
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2225
movq %r15, %rdi
movq %rbp, %rsi
callq 0x21d1
movq %rax, %rdi
movq %r13, %rsi
callq 0x356b
testb %al, %al
jne 0x1a67
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x21d1
testq %rax, %rax
jne 0x1a86
movq %rbx, %rdi
callq 0x352c
movq %rax, %r13
movq %r15, %rdi
callq 0x352c
cmpq %rax, %r13
je 0x1aa5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x356b
testb %al, %al
movq 0x8(%rsp), %rdx
je 0x1ac4
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1de7
movq %rbx, %rdi
callq 0x352c
movq %rax, %r13
movq %r15, %rdi
callq 0x352c
cmpq %rax, %r13
jne 0x1ae3
movq %rbx, %rdi
movq %r15, %rsi
callq 0x356b
testb %al, %al
jne 0x1b02
movq %r15, %rdi
callq 0x227a
movq %r15, %rdi
movq %rbp, %rsi
callq 0x21d1
testq %rax, %rax
jne 0x1b21
movq %r15, %rdi
movq %r14, %rsi
callq 0x21d1
testq %rax, %rax
jne 0x1b40
movq %r14, 0x28(%rsp)
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x21d1
testq %rax, %rax
jne 0x1b5f
movq %r12, %r14
xorl %r13d, %r13d
movl %r13d, %edi
callq 0x2730
movq %rax, 0x30(%rsp,%r13,8)
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rdx
callq 0x1de7
incq %r13
cmpq $0x800, %r13            # imm = 0x800
jne 0x17c9
xorl %r12d, %r12d
movq 0x30(%rsp,%r12,8), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x21d1
movq %r13, %rdi
movq %rax, %rsi
callq 0x356b
testb %al, %al
jne 0x18b5
incq %r12
cmpq $0x800, %r12            # imm = 0x800
jne 0x17f3
movq 0x28(%rsp), %rdi
callq 0x35ee
movq %r14, %rdi
callq 0x35ee
movq 0x8(%rsp), %rdi
callq 0x35ee
movq 0x20(%rsp), %rdi
callq 0x35ee
movq %rbp, %rdi
callq 0x35ee
movq (%rsp), %rdi
callq 0x35ee
movq 0x18(%rsp), %rdi
callq 0x35ee
movq 0x10(%rsp), %rdi
callq 0x35ee
movq %rbx, %rdi
callq 0x35ee
movq %r15, %rdi
callq 0x35ee
xorl %ebx, %ebx
movq 0x30(%rsp,%rbx,8), %rdi
callq 0x35ee
incq %rbx
cmpq $0x800, %rbx            # imm = 0x800
jne 0x187f
leaq 0x3b3a(%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 0x3abc(%rip), %rdi      # 0x5378
leaq 0x378c(%rip), %rsi      # 0x504f
leaq 0x379c(%rip), %rcx      # 0x5066
movl $0x6b, %edx
callq 0x1050
leaq 0x3729(%rip), %rdi      # 0x5004
leaq 0x376d(%rip), %rsi      # 0x504f
leaq 0x377d(%rip), %rcx      # 0x5066
movl $0x25, %edx
callq 0x1050
leaq 0x3777(%rip), %rdi      # 0x5071
leaq 0x374e(%rip), %rsi      # 0x504f
leaq 0x375e(%rip), %rcx      # 0x5066
movl $0x27, %edx
callq 0x1050
leaq 0x3781(%rip), %rdi      # 0x509a
leaq 0x372f(%rip), %rsi      # 0x504f
leaq 0x373f(%rip), %rcx      # 0x5066
movl $0x2c, %edx
callq 0x1050
leaq 0x3767(%rip), %rdi      # 0x509f
leaq 0x3710(%rip), %rsi      # 0x504f
leaq 0x3720(%rip), %rcx      # 0x5066
movl $0x2d, %edx
callq 0x1050
leaq 0x3779(%rip), %rdi      # 0x50d0
leaq 0x36f1(%rip), %rsi      # 0x504f
leaq 0x3701(%rip), %rcx      # 0x5066
movl $0x2e, %edx
callq 0x1050
leaq 0x3729(%rip), %rdi      # 0x509f
leaq 0x36d2(%rip), %rsi      # 0x504f
leaq 0x36e2(%rip), %rcx      # 0x5066
movl $0x36, %edx
callq 0x1050
leaq 0x375f(%rip), %rdi      # 0x50f4
leaq 0x36b3(%rip), %rsi      # 0x504f
leaq 0x36c3(%rip), %rcx      # 0x5066
movl $0x37, %edx
callq 0x1050
leaq 0x3771(%rip), %rdi      # 0x5125
leaq 0x3694(%rip), %rsi      # 0x504f
leaq 0x36a4(%rip), %rcx      # 0x5066
movl $0x3b, %edx
callq 0x1050
leaq 0x3783(%rip), %rdi      # 0x5156
leaq 0x3675(%rip), %rsi      # 0x504f
leaq 0x3685(%rip), %rcx      # 0x5066
movl $0x3c, %edx
callq 0x1050
leaq 0x367f(%rip), %rdi      # 0x5071
leaq 0x3656(%rip), %rsi      # 0x504f
leaq 0x3666(%rip), %rcx      # 0x5066
movl $0x41, %edx
callq 0x1050
leaq 0x3776(%rip), %rdi      # 0x5187
leaq 0x3637(%rip), %rsi      # 0x504f
leaq 0x3647(%rip), %rcx      # 0x5066
movl $0x42, %edx
callq 0x1050
leaq 0x377c(%rip), %rdi      # 0x51ac
leaq 0x3618(%rip), %rsi      # 0x504f
leaq 0x3628(%rip), %rcx      # 0x5066
movl $0x45, %edx
callq 0x1050
leaq 0x378e(%rip), %rdi      # 0x51dd
leaq 0x35f9(%rip), %rsi      # 0x504f
leaq 0x3609(%rip), %rcx      # 0x5066
movl $0x4b, %edx
callq 0x1050
leaq 0x376f(%rip), %rdi      # 0x51dd
leaq 0x35da(%rip), %rsi      # 0x504f
leaq 0x35ea(%rip), %rcx      # 0x5066
movl $0x50, %edx
callq 0x1050
leaq 0x3781(%rip), %rdi      # 0x520e
leaq 0x35bb(%rip), %rsi      # 0x504f
leaq 0x35cb(%rip), %rcx      # 0x5066
movl $0x54, %edx
callq 0x1050
leaq 0x376f(%rip), %rdi      # 0x521b
leaq 0x359c(%rip), %rsi      # 0x504f
leaq 0x35ac(%rip), %rcx      # 0x5066
movl $0x56, %edx
callq 0x1050
leaq 0x3785(%rip), %rdi      # 0x5250
leaq 0x357d(%rip), %rsi      # 0x504f
leaq 0x358d(%rip), %rcx      # 0x5066
movl $0x57, %edx
callq 0x1050
leaq 0x37a2(%rip), %rdi      # 0x528c
leaq 0x355e(%rip), %rsi      # 0x504f
leaq 0x356e(%rip), %rcx      # 0x5066
movl $0x5b, %edx
callq 0x1050
leaq 0x37b8(%rip), %rdi      # 0x52c1
leaq 0x353f(%rip), %rsi      # 0x504f
leaq 0x354f(%rip), %rcx      # 0x5066
movl $0x5c, %edx
callq 0x1050
leaq 0x37d5(%rip), %rdi      # 0x52fd
leaq 0x3520(%rip), %rsi      # 0x504f
leaq 0x3530(%rip), %rcx      # 0x5066
movl $0x60, %edx
callq 0x1050
leaq 0x37df(%rip), %rdi      # 0x5326
leaq 0x3501(%rip), %rsi      # 0x504f
leaq 0x3511(%rip), %rcx      # 0x5066
movl $0x61, %edx
callq 0x1050
leaq 0x37e9(%rip), %rdi      # 0x534f
leaq 0x34e2(%rip), %rsi      # 0x504f
leaq 0x34f2(%rip), %rcx      # 0x5066
movl $0x62, %edx
callq 0x1050
nop