// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/pigz.c
// Function: get_space
space *get_space(struct pool *pool) {
    struct space *space;

    // if can't create any more, wait for a space to show up
    possess(pool->have);
    if (pool->limit == 0)
        wait_for(pool->have, NOT_TO_BE, 0);

    // if a space is available, pull it from the list and return it
    if (pool->head != NULL) {
        space = pool->head;
        pool->head = space->next;
        twist(pool->have, BY, -1);      // one less in pool
        possess(space->use);
        twist(space->use, TO, 1);       // initially one user
        space->len = 0;
        return space;
    }

    // nothing available, don't want to wait, make a new space
    assert(pool->limit != 0);
    if (pool->limit > 0)
        pool->limit--;
    pool->made++;
    release(pool->have);
    space = alloc(NULL, sizeof(struct space));
    space->use = new_lock(1);           // initially one user
    space->buf = alloc(NULL, pool->size);
    space->size = pool->size;
    space->len = 0;
    space->pool = pool;                 // remember the pool this belongs to
    return space;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0xd430(%rip), %rsi      # 0x1c24a
movl $0x5bf, %edx            # imm = 0x5BF
callq 0x11900
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0xee50
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0xd405(%rip), %rcx      # 0x1c24a
movl $0x5c1, %r8d            # imm = 0x5C1
callq 0x11a50
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xeef1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
movq $-0x1, %rdx
leaq 0xd3b5(%rip), %rcx      # 0x1c24a
movl $0x5c7, %r8d            # imm = 0x5C7
callq 0x119a0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xd39c(%rip), %rsi      # 0x1c24a
movl $0x5c8, %edx            # imm = 0x5C8
callq 0x11900
movq -0x18(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movl $0x1, %edx
leaq 0xd37d(%rip), %rcx      # 0x1c24a
movl $0x5c9, %r8d            # imm = 0x5C9
callq 0x119a0
movq -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xefd6
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0xeefd
jmp 0xef1c
leaq 0xe981(%rip), %rdi      # 0x1d885
leaq 0xd33f(%rip), %rsi      # 0x1c24a
movl $0x5cf, %edx            # imm = 0x5CF
leaq 0xe97f(%rip), %rcx      # 0x1d896
callq 0x3220
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jle 0xef33
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0xd2fc(%rip), %rsi      # 0x1c24a
movl $0x5d3, %edx            # imm = 0x5D3
callq 0x11950
xorl %eax, %eax
movl %eax, %edi
movl $0x30, %esi
callq 0xac60
movq %rax, -0x18(%rbp)
movl $0x1, %edi
leaq 0xd2d4(%rip), %rsi      # 0x1c24a
movl $0x5d5, %edx            # imm = 0x5D5
callq 0x116a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0xac60
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq