// File: /workspace/github_c_makefile_star2_O1/stevenmherring[P]DNS/mutex-trie.c
// Function: insert
int insert(const char *string, size_t strlen, int32_t ip4_address) {
          int result = 0;
          if (strlen > 0) {
            int rv;
            // obtain the lock
            rv = pthread_mutex_lock(&lock);

            pthread_cleanup_push(cleanup_handler,&lock);

            assert(rv == 0);
            // Check to see if node exists
            if (allow_squatting && squat_search(string, strlen, &ip4_address)) {
              do {
                printf("Thread: %lu Blocked from insert'%s'\n", (long) pthread_self(), string);
                blocked++;
                if (blocked == blockedCount) {
                  printf("\nEveryone is Squatting, Free the last squatter!\n");
                  blocked--;
                  break;
                }
                rv = pthread_cond_wait(&cv, &lock);
                assert(rv == 0);
                blocked--;
                pthread_testcancel();
                printf("Thread: %lu No longer blocked\n", (long) pthread_self());
              } while (squat_search(string, strlen, &ip4_address));
            }
            /* Edge case: root is null */
            if (root == NULL) {
              root = new_leaf(string, strlen, ip4_address);
              result = 1;
            } else {
              result = _insert(string, strlen, ip4_address, root, NULL, NULL);
            }
            printf("Thread: %lu inserted '%s'\n", (long) pthread_self(), string);
            // Unlock
            //rv = pthread_mutex_unlock(&lock);
            pthread_cleanup_pop(1);
            assert(rv == 0);
          }
          return result;
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
testq %rsi, %rsi
je 0x1af4
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4726(%rip), %rdi      # 0x6128
callq 0x1200
movl %eax, %r15d
movq %rsp, %rdi
xorl %esi, %esi
callq 0x11d0
movq %rsp, %rdi
testl %eax, %eax
jne 0x1b8a
callq 0x11a0
testl %r15d, %r15d
jne 0x1bae
leaq 0x4764(%rip), %rax      # 0x6198
cmpl $0x0, (%rax)
je 0x1b0d
movq 0x4714(%rip), %rdi      # 0x6158
movq %rbx, %rsi
movq %r14, %rdx
callq 0x145a
testq %rax, %rax
je 0x1a58
movl 0xc(%rax), %r12d
testq %rax, %rax
je 0x1b0d
callq 0x1160
movq %rax, %r15
xorl %eax, %eax
movl %eax, %ebp
leaq 0x17b5(%rip), %r13      # 0x3229
leaq 0x1789(%rip), %rdi      # 0x3204
movq %r15, %rsi
movq %rbx, %rdx
movl %ebp, %eax
callq 0x10a0
incl 0x46d2(%rip)            # 0x6160
movl 0x46cc(%rip), %eax      # 0x6160
cmpl 0x46b6(%rip), %eax      # 0x6150
je 0x1afb
leaq 0x46c5(%rip), %rdi      # 0x6168
leaq 0x467e(%rip), %rsi      # 0x6128
callq 0x1090
testl %eax, %eax
jne 0x1b8f
decl 0x46a3(%rip)            # 0x6160
callq 0x10f0
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %eax
callq 0x10a0
movq 0x4682(%rip), %rdi      # 0x6158
movq %rbx, %rsi
movq %r14, %rdx
callq 0x145a
testq %rax, %rax
je 0x1aea
movl 0xc(%rax), %r12d
movl %r12d, %edx
testq %rax, %rax
jne 0x1a74
jmp 0x1b10
xorl %eax, %eax
jmp 0x1b7b
leaq 0x1915(%rip), %rdi      # 0x3417
callq 0x1080
decl 0x4653(%rip)            # 0x6160
movl %r12d, %edx
movq 0x4641(%rip), %rcx      # 0x6158
testq %rcx, %rcx
je 0x1b31
xorl %eax, %eax
movl %eax, %r8d
movq %rbx, %rdi
movq %r14, %rsi
movq %r8, %r9
callq 0x15df
jmp 0x1b48
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1348
movq %rax, 0x4615(%rip)      # 0x6158
movl $0x1, %eax
movl %eax, %ebp
callq 0x1160
leaq 0x16f2(%rip), %rdi      # 0x3248
xorl %ecx, %ecx
movq %rax, %rsi
movq %rbx, %rdx
movl %ecx, %eax
callq 0x10a0
movq %rsp, %rdi
callq 0x10b0
leaq 0x45b4(%rip), %rdi      # 0x6128
callq 0x1120
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1231
leaq 0x163c(%rip), %rdi      # 0x31d2
leaq 0x1467(%rip), %rsi      # 0x3004
leaq 0x1636(%rip), %rcx      # 0x31da
movl $0x12c, %edx            # imm = 0x12C
callq 0x10c0
leaq 0x161d(%rip), %rdi      # 0x31d2
leaq 0x1448(%rip), %rsi      # 0x3004
leaq 0x1617(%rip), %rcx      # 0x31da
movl $0x120, %edx            # imm = 0x120
callq 0x10c0