// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jbe 0x203a
leaq 0x4339(%rip), %rdi      # 0x6128
callq 0x1200
movl %eax, -0x1c(%rbp)
leaq -0xaee(%rip), %rax      # 0x1310
movq %rax, -0x98(%rbp)
leaq 0x431c(%rip), %rax      # 0x6128
movq %rax, -0xa0(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x11d0
movl %eax, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
cmpq $0x0, %rax
je 0x1e50
movq -0x98(%rbp), %rax
movq -0xa0(%rbp), %rdi
callq *%rax
leaq -0x90(%rbp), %rdi
callq 0x1140
leaq -0x90(%rbp), %rdi
callq 0x11a0
cmpl $0x0, -0x1c(%rbp)
jne 0x1e64
jmp 0x1e83
leaq 0x23c1(%rip), %rdi      # 0x422c
leaq 0x21d2(%rip), %rsi      # 0x4044
movl $0x120, %edx            # imm = 0x120
leaq 0x23b6(%rip), %rcx      # 0x4234
callq 0x10b0
leaq 0x430e(%rip), %rax      # 0x6198
cmpl $0x0, (%rax)
je 0x1f8b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x14(%rbp), %rdx
callq 0x1640
cmpl $0x0, %eax
je 0x1f8b
jmp 0x1eaf
callq 0x1160
movq %rax, %rsi
movq -0x8(%rbp), %rdx
leaq 0x239c(%rip), %rdi      # 0x425e
movb $0x0, %al
callq 0x1090
movl 0x4291(%rip), %eax      # 0x6160
addl $0x1, %eax
movl %eax, 0x4288(%rip)      # 0x6160
movl 0x4282(%rip), %eax      # 0x6160
cmpl 0x426c(%rip), %eax      # 0x6150
jne 0x1f08
leaq 0x2396(%rip), %rdi      # 0x4283
movb $0x0, %al
callq 0x1090
movl 0x4266(%rip), %eax      # 0x6160
addl $-0x1, %eax
movl %eax, 0x425d(%rip)      # 0x6160
jmp 0x1f89
leaq 0x4259(%rip), %rdi      # 0x6168
leaq 0x4212(%rip), %rsi      # 0x6128
callq 0x1080
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1f26
jmp 0x1f45
leaq 0x22ff(%rip), %rdi      # 0x422c
leaq 0x2110(%rip), %rsi      # 0x4044
movl $0x12c, %edx            # imm = 0x12C
leaq 0x22f4(%rip), %rcx      # 0x4234
callq 0x10b0
movl 0x4215(%rip), %eax      # 0x6160
addl $-0x1, %eax
movl %eax, 0x420c(%rip)      # 0x6160
callq 0x10f0
callq 0x1160
movq %rax, %rsi
leaq 0x234c(%rip), %rdi      # 0x42b4
movb $0x0, %al
callq 0x1090
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x14(%rbp), %rdx
callq 0x1640
cmpl $0x0, %eax
jne 0x1eaf
jmp 0x1f8b
cmpq $0x0, 0x41c5(%rip)      # 0x6158
jne 0x1fb5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x1330
movq %rax, 0x41ac(%rip)      # 0x6158
movl $0x1, -0x18(%rbp)
jmp 0x1fd7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movq 0x4191(%rip), %rcx      # 0x6158
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x17e0
movl %eax, -0x18(%rbp)
callq 0x1160
movq %rax, %rsi
movq -0x8(%rbp), %rdx
leaq 0x22e9(%rip), %rdi      # 0x42d3
movb $0x0, %al
callq 0x1090
jmp 0x1ff3
jmp 0x1ff5
leaq -0x90(%rbp), %rdi
callq 0x10a0
movq -0x98(%rbp), %rax
movq -0xa0(%rbp), %rdi
callq *%rax
cmpl $0x0, -0x1c(%rbp)
jne 0x2019
jmp 0x2038
leaq 0x220c(%rip), %rdi      # 0x422c
leaq 0x201d(%rip), %rsi      # 0x4044
movl $0x13d, %edx            # imm = 0x13D
leaq 0x2201(%rip), %rcx      # 0x4234
callq 0x10b0
jmp 0x203a
movl -0x18(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)