// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x4090, %rsp           # imm = 0x4090
movl $0x0, -0x4(%rbp)
callq 0x1a10
movq %rax, -0x10(%rbp)
movl $0x1, %edi
callq 0x2b40
movq %rax, -0x20(%rbp)
movl $0x2, %edi
callq 0x2b40
movq %rax, -0x28(%rbp)
movl $0x3, %edi
callq 0x2b40
movq %rax, -0x30(%rbp)
movl $0x195f3, %edi          # imm = 0x195F3
callq 0x2b40
movq %rax, -0x38(%rbp)
leaq 0x51f6(%rip), %rax      # 0x6410
movl (%rax), %edi
addl $0x1, %edi
callq 0x2b40
movq %rax, -0x40(%rbp)
leaq 0x51e1(%rip), %rax      # 0x6410
movl (%rax), %edi
shll %edi
addl $0x1, %edi
callq 0x2b40
movq %rax, -0x48(%rbp)
leaq 0x51ca(%rip), %rax      # 0x6410
imull $0x3, (%rax), %edi
addl $0x1, %edi
callq 0x2b40
movq %rax, -0x50(%rbp)
leaq 0x51b4(%rip), %rax      # 0x6410
movl (%rax), %edi
shll $0x2, %edi
addl $0x1, %edi
callq 0x2b40
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3fd0
leaq 0x5193(%rip), %rcx      # 0x6410
movl (%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, -0x4070(%rbp)
movq -0x40(%rbp), %rdi
callq 0x3fd0
leaq 0x5175(%rip), %rcx      # 0x6410
movl (%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, %rax
movq -0x4070(%rbp), %rdx
cmpq %rax, %rdx
jne 0x12b3
jmp 0x12d2
leaq 0x4d4a(%rip), %rdi      # 0x6004
leaq 0x4d8e(%rip), %rsi      # 0x604f
movl $0x25, %edx
leaq 0x4d99(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x22a0
cmpq $0x0, %rax
jne 0x12e7
jmp 0x1306
leaq 0x4d83(%rip), %rdi      # 0x6071
leaq 0x4d5a(%rip), %rsi      # 0x604f
movl $0x27, %edx
leaq 0x4d65(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x1d80
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
cmpq $0x0, -0x4068(%rbp)
je 0x1337
jmp 0x1356
leaq 0x56e2(%rip), %rdi      # 0x6a20
leaq 0x4d0a(%rip), %rsi      # 0x604f
movl $0x2c, %edx
leaq 0x4d15(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x28(%rbp), %rdi
movq -0x4068(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x1370
jmp 0x138f
leaq 0x4d23(%rip), %rdi      # 0x609a
leaq 0x4cd1(%rip), %rsi      # 0x604f
movl $0x2d, %edx
leaq 0x4cdc(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x4068(%rbp), %rdi
callq 0x4280
cmpl $0x1, %eax
jbe 0x13a2
jmp 0x13c1
leaq 0x4d22(%rip), %rdi      # 0x60cb
leaq 0x4c9f(%rip), %rsi      # 0x604f
movl $0x2e, %edx
leaq 0x4caa(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x1d80
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x1d80
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x1d80
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x1d80
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
movq -0x28(%rbp), %rdi
movq -0x4068(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x1433
jmp 0x1452
leaq 0x4c60(%rip), %rdi      # 0x609a
leaq 0x4c0e(%rip), %rsi      # 0x604f
movl $0x36, %edx
leaq 0x4c19(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x30(%rbp), %rdi
movq -0x4068(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
je 0x146c
jmp 0x148b
leaq 0x4c7c(%rip), %rdi      # 0x60ef
leaq 0x4bd5(%rip), %rsi      # 0x604f
movl $0x37, %edx
leaq 0x4be0(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
movq -0x30(%rbp), %rdi
movq -0x4068(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x14b9
jmp 0x14d8
leaq 0x4c60(%rip), %rdi      # 0x6120
leaq 0x4b88(%rip), %rsi      # 0x604f
movl $0x3b, %edx
leaq 0x4b93(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x28(%rbp), %rdi
movq -0x4068(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
je 0x14f2
jmp 0x1511
leaq 0x4c58(%rip), %rdi      # 0x6151
leaq 0x4b4f(%rip), %rsi      # 0x604f
movl $0x3c, %edx
leaq 0x4b5a(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1d80
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x22a0
cmpq $0x0, %rax
jne 0x154b
jmp 0x156a
leaq 0x4b1f(%rip), %rdi      # 0x6071
leaq 0x4af6(%rip), %rsi      # 0x604f
movl $0x41, %edx
leaq 0x4b01(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x4068(%rbp), %rdi
callq 0x4280
cmpl $0x1, %eax
jne 0x157d
jmp 0x159c
leaq 0x4bfe(%rip), %rdi      # 0x6182
leaq 0x4ac4(%rip), %rsi      # 0x604f
movl $0x42, %edx
leaq 0x4acf(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
movq -0x48(%rbp), %rdi
movq -0x4068(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x15ca
jmp 0x15e9
leaq 0x4bd6(%rip), %rdi      # 0x61a7
leaq 0x4a77(%rip), %rsi      # 0x604f
movl $0x45, %edx
leaq 0x4a82(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
callq 0x1b70
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1d80
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
movq -0x4068(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x1635
jmp 0x1654
leaq 0x4b9c(%rip), %rdi      # 0x61d8
leaq 0x4a0c(%rip), %rsi      # 0x604f
movl $0x4b, %edx
leaq 0x4a17(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2340
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
movq -0x4068(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x168f
jmp 0x16ae
leaq 0x4b42(%rip), %rdi      # 0x61d8
leaq 0x49b2(%rip), %rsi      # 0x604f
movl $0x50, %edx
leaq 0x49bd(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x22a0
movq %rax, -0x4068(%rbp)
cmpq $0x0, -0x4068(%rbp)
jne 0x16ce
jmp 0x16ed
leaq 0x4b34(%rip), %rdi      # 0x6209
leaq 0x4973(%rip), %rsi      # 0x604f
movl $0x54, %edx
leaq 0x497e(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
callq 0x3fd0
movq %rax, -0x4078(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3fd0
movq %rax, %rcx
movq -0x4078(%rbp), %rax
cmpq %rcx, %rax
je 0x1717
jmp 0x1736
leaq 0x4af8(%rip), %rdi      # 0x6216
leaq 0x492a(%rip), %rsi      # 0x604f
movl $0x56, %edx
leaq 0x4935(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
je 0x174d
jmp 0x176c
leaq 0x4af7(%rip), %rdi      # 0x624b
leaq 0x48f4(%rip), %rsi      # 0x604f
movl $0x57, %edx
leaq 0x48ff(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x1d80
movq -0x10(%rbp), %rdi
callq 0x3fd0
movq %rax, -0x4080(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3fd0
movq %rax, %rcx
movq -0x4080(%rbp), %rax
cmpq %rcx, %rax
jne 0x17a7
jmp 0x17c6
leaq 0x4ad9(%rip), %rdi      # 0x6287
leaq 0x489a(%rip), %rsi      # 0x604f
movl $0x5b, %edx
leaq 0x48a5(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x17dd
jmp 0x17fc
leaq 0x4ad8(%rip), %rdi      # 0x62bc
leaq 0x4864(%rip), %rsi      # 0x604f
movl $0x5c, %edx
leaq 0x486f(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x23d0
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x22a0
cmpq $0x0, %rax
jne 0x181a
jmp 0x1839
leaq 0x4ad7(%rip), %rdi      # 0x62f8
leaq 0x4827(%rip), %rsi      # 0x604f
movl $0x60, %edx
leaq 0x4832(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x22a0
cmpq $0x0, %rax
jne 0x184e
jmp 0x186d
leaq 0x4acc(%rip), %rdi      # 0x6321
leaq 0x47f3(%rip), %rsi      # 0x604f
movl $0x61, %edx
leaq 0x47fe(%rip), %rcx      # 0x6066
callq 0x1050
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x22a0
cmpq $0x0, %rax
jne 0x1882
jmp 0x18a1
leaq 0x4ac1(%rip), %rdi      # 0x634a
leaq 0x47bf(%rip), %rsi      # 0x604f
movl $0x62, %edx
leaq 0x47ca(%rip), %rcx      # 0x6066
callq 0x1050
movl $0x0, -0x8(%rbp)
cmpl $0x800, -0x8(%rbp)      # imm = 0x800
jae 0x18f1
movl -0x8(%rbp), %edi
callq 0x2b40
movq %rax, %rcx
movl -0x8(%rbp), %eax
movq %rcx, -0x4060(%rbp,%rax,8)
movq -0x10(%rbp), %rdi
movl -0x8(%rbp), %eax
movq -0x4060(%rbp,%rax,8), %rsi
movl -0x8(%rbp), %eax
movq -0x4060(%rbp,%rax,8), %rdx
callq 0x1d80
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x18a8
movl $0x0, -0x8(%rbp)
cmpl $0x800, -0x8(%rbp)      # imm = 0x800
jae 0x196c
movl -0x8(%rbp), %eax
movq -0x4060(%rbp,%rax,8), %rax
movq %rax, -0x4088(%rbp)
movq -0x10(%rbp), %rdi
movl -0x8(%rbp), %eax
movq -0x4060(%rbp,%rax,8), %rsi
callq 0x22a0
movq -0x4088(%rbp), %rdi
movq %rax, %rsi
callq 0x4070
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x1940
jmp 0x195f
leaq 0x4a2c(%rip), %rdi      # 0x6373
leaq 0x4701(%rip), %rsi      # 0x604f
movl $0x6b, %edx
leaq 0x470c(%rip), %rcx      # 0x6066
callq 0x1050
jmp 0x1961
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x18f8
movq -0x20(%rbp), %rdi
callq 0x4190
movq -0x28(%rbp), %rdi
callq 0x4190
movq -0x30(%rbp), %rdi
callq 0x4190
movq -0x38(%rbp), %rdi
callq 0x4190
movq -0x40(%rbp), %rdi
callq 0x4190
movq -0x48(%rbp), %rdi
callq 0x4190
movq -0x50(%rbp), %rdi
callq 0x4190
movq -0x58(%rbp), %rdi
callq 0x4190
movq -0x10(%rbp), %rdi
callq 0x4190
movq -0x18(%rbp), %rdi
callq 0x4190
movl $0x0, -0x8(%rbp)
cmpl $0x800, -0x8(%rbp)      # imm = 0x800
jae 0x19f1
movl -0x8(%rbp), %eax
movq -0x4060(%rbp,%rax,8), %rdi
callq 0x4190
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x19cd
leaq 0x49d9(%rip), %rdi      # 0x63d1
movb $0x0, %al
callq 0x1040
xorl %eax, %eax
addq $0x4090, %rsp           # imm = 0x4090
popq %rbp
retq
nopw (%rax,%rax)