// File: /workspace/github_c_makefile_star2_O3/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 0x1aed
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4725(%rip), %rdi      # 0x6128
callq 0x1200
movl %eax, %r15d
movq %rsp, %rdi
xorl %esi, %esi
callq 0x11d0
movq %rsp, %rdi
testl %eax, %eax
jne 0x1b86
callq 0x11a0
testl %r15d, %r15d
jne 0x1baa
leaq 0x4763(%rip), %rax      # 0x6198
cmpl $0x0, (%rax)
je 0x1b06
movq 0x4713(%rip), %rdi      # 0x6158
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1458
testq %rax, %rax
je 0x1b06
movq %rax, %r12
callq 0x1160
movq %rax, %r15
xorl %eax, %eax
movl %eax, %ebp
leaq 0x17ba(%rip), %r13      # 0x3229
movq %r12, %rcx
movl 0xc(%rcx), %r12d
leaq 0x1787(%rip), %rdi      # 0x3204
movq %r15, %rsi
movq %rbx, %rdx
movl %ebp, %eax
callq 0x10a0
incl 0x46d0(%rip)            # 0x6160
movl 0x46ca(%rip), %eax      # 0x6160
cmpl 0x46b4(%rip), %eax      # 0x6150
je 0x1af4
leaq 0x46c3(%rip), %rdi      # 0x6168
leaq 0x467c(%rip), %rsi      # 0x6128
callq 0x1090
testl %eax, %eax
jne 0x1b8b
decl 0x46a1(%rip)            # 0x6160
callq 0x10f0
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %eax
callq 0x10a0
movq 0x4680(%rip), %rdi      # 0x6158
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1458
movq %rax, %rcx
testq %rax, %rax
jne 0x1a72
jmp 0x1b06
xorl %eax, %eax
jmp 0x1b77
leaq 0x191c(%rip), %rdi      # 0x3417
callq 0x1080
decl 0x465a(%rip)            # 0x6160
movq 0x464b(%rip), %rcx      # 0x6158
testq %rcx, %rcx
je 0x1b2a
xorl %eax, %eax
movl %eax, %r8d
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
movq %r8, %r9
callq 0x15dd
jmp 0x1b44
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x1348
movq %rax, 0x4619(%rip)      # 0x6158
movl $0x1, %eax
movl %eax, %ebp
callq 0x1160
leaq 0x16f6(%rip), %rdi      # 0x3248
xorl %ecx, %ecx
movq %rax, %rsi
movq %rbx, %rdx
movl %ecx, %eax
callq 0x10a0
movq %rsp, %rdi
callq 0x10b0
leaq 0x45b8(%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 0x1640(%rip), %rdi      # 0x31d2
leaq 0x146b(%rip), %rsi      # 0x3004
leaq 0x163a(%rip), %rcx      # 0x31da
movl $0x12c, %edx            # imm = 0x12C
callq 0x10c0
leaq 0x1621(%rip), %rdi      # 0x31d2
leaq 0x144c(%rip), %rsi      # 0x3004
leaq 0x161b(%rip), %rcx      # 0x31da
movl $0x120, %edx            # imm = 0x120
callq 0x10c0