// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movl %edx, 0xc(%rsp)
testq %rsi, %rsi
je 0x1abe
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4746(%rip), %rdi      # 0x6128
callq 0x1200
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x11d0
testl %eax, %eax
jne 0x1b55
leaq 0x10(%rsp), %rdi
callq 0x11a0
testl %ebp, %ebp
jne 0x1b83
leaq 0x4782(%rip), %rax      # 0x6198
cmpl $0x0, (%rax)
je 0x1ad7
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14c3
testl %eax, %eax
je 0x1ad7
callq 0x1160
movq %rax, %r15
xorl %eax, %eax
movl %eax, %ebp
leaq 0x17df(%rip), %r13      # 0x3229
leaq 0xc(%rsp), %r12
leaq 0x17ae(%rip), %rdi      # 0x3204
movq %r15, %rsi
movq %rbx, %rdx
movl %ebp, %eax
callq 0x10a0
incl 0x46f7(%rip)            # 0x6160
movl 0x46f1(%rip), %eax      # 0x6160
cmpl 0x46db(%rip), %eax      # 0x6150
je 0x1ac5
leaq 0x46ea(%rip), %rdi      # 0x6168
leaq 0x46a3(%rip), %rsi      # 0x6128
callq 0x1090
testl %eax, %eax
jne 0x1b64
decl 0x46c8(%rip)            # 0x6160
callq 0x10f0
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %eax
callq 0x10a0
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x14c3
testl %eax, %eax
jne 0x1a4f
jmp 0x1ad7
xorl %eax, %eax
jmp 0x1b46
leaq 0x194b(%rip), %rdi      # 0x3417
callq 0x1080
decl 0x4689(%rip)            # 0x6160
movq 0x467a(%rip), %rcx      # 0x6158
movl 0xc(%rsp), %edx
testq %rcx, %rcx
je 0x1afc
xorl %eax, %eax
movl %eax, %r8d
movq %rbx, %rdi
movq %r14, %rsi
movq %r8, %r9
callq 0x159e
jmp 0x1b11
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1318
movq %rax, 0x464a(%rip)      # 0x6158
pushq $0x1
popq %rax
movl %eax, %ebp
callq 0x1160
leaq 0x1729(%rip), %rdi      # 0x3248
xorl %ecx, %ecx
movq %rax, %rsi
movq %rbx, %rdx
movl %ecx, %eax
callq 0x10a0
leaq 0x10(%rsp), %rdi
callq 0x10b0
leaq 0x45e9(%rip), %rdi      # 0x6128
callq 0x1120
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x130c
leaq 0x10(%rsp), %rdi
callq 0x1140
leaq 0x1667(%rip), %rdi      # 0x31d2
leaq 0x1492(%rip), %rsi      # 0x3004
leaq 0x1661(%rip), %rcx      # 0x31da
movl $0x12c, %edx            # imm = 0x12C
callq 0x10c0
leaq 0x1648(%rip), %rdi      # 0x31d2
leaq 0x1473(%rip), %rsi      # 0x3004
leaq 0x1642(%rip), %rcx      # 0x31da
movl $0x120, %edx            # imm = 0x120
callq 0x10c0