// File: /workspace/github_c_makefile_star2_O0/madler[P]pigz/pigz.c
// Function: outb
local int outb(void *desc, unsigned char *buf, unsigned len) {
    (void)desc;

#ifndef NOTHREAD
    static thread *wr, *ch;

    if (g.procs > 1) {
        // if first time, initialize state and launch threads
        if (outb_write_more == NULL) {
            outb_write_more = new_lock(0);
            outb_check_more = new_lock(0);
            wr = launch(outb_write, NULL);
            ch = launch(outb_check, NULL);
        }

        // wait for previous write and check threads to complete
        possess(outb_check_more);
        wait_for(outb_check_more, TO_BE, 0);
        possess(outb_write_more);
        wait_for(outb_write_more, TO_BE, 0);

        // copy the output and alert the worker bees
        out_len = len;
        if (len) {
            g.out_tot += len;
            memcpy(out_copy, buf, len);
        }
        twist(outb_write_more, TO, 1);
        twist(outb_check_more, TO, 1);

        // if requested with len == 0, clean up -- terminate and join write and
        // check threads, free lock
        if (len == 0 && outb_write_more != NULL) {
            join(ch);
            join(wr);
            free_lock(outb_check_more);
            free_lock(outb_write_more);
            outb_write_more = NULL;
        }

        // return for more decompression while last buffer is being written and
        // having its check value calculated -- we wait for those to finish the
        // next time this function is called
        return 0;
    }
#endif

    // if just one process or no threads, then do it without threads
    if (len) {
        if (g.decode == 1)
            writen(g.outd, buf, len);
        g.out_check = CHECK(g.out_check, buf, len);
        g.out_tot += len;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpl $0x1, 0x18e56(%rip)     # 0x23830
jle 0xabd3
cmpq $0x0, 0x30f58(%rip)     # 0x3b940
jne 0xaa68
xorl %eax, %eax
movl %eax, %edi
leaq 0x11855(%rip), %rsi     # 0x1c24a
movl $0xd4e, %edx            # imm = 0xD4E
callq 0x116a0
movq %rax, 0x30f3a(%rip)     # 0x3b940
xorl %eax, %eax
movl %eax, %edi
leaq 0x11839(%rip), %rsi     # 0x1c24a
movl $0xd4f, %edx            # imm = 0xD4F
callq 0x116a0
movq %rax, 0x30f26(%rip)     # 0x3b948
leaq 0x3997(%rip), %rdi      # 0xe3c0
xorl %eax, %eax
movl %eax, %esi
leaq 0x11816(%rip), %rdx     # 0x1c24a
movl $0xd50, %ecx            # imm = 0xD50
callq 0x11c90
movq %rax, 0x30eeb(%rip)     # 0x3b930
leaq 0x3b94(%rip), %rdi      # 0xe5e0
xorl %eax, %eax
movl %eax, %esi
leaq 0x117f3(%rip), %rdx     # 0x1c24a
movl $0xd51, %ecx            # imm = 0xD51
callq 0x11c90
movq %rax, 0x30ed0(%rip)     # 0x3b938
movq 0x30ed9(%rip), %rdi     # 0x3b948
leaq 0x117d4(%rip), %rsi     # 0x1c24a
movl $0xd55, %edx            # imm = 0xD55
callq 0x11900
movq 0x30ec1(%rip), %rdi     # 0x3b948
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x117b6(%rip), %rcx     # 0x1c24a
movl $0xd56, %r8d            # imm = 0xD56
callq 0x11a50
movq 0x30e9a(%rip), %rdi     # 0x3b940
leaq 0x1179d(%rip), %rsi     # 0x1c24a
movl $0xd57, %edx            # imm = 0xD57
callq 0x11900
movq 0x30e82(%rip), %rdi     # 0x3b940
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x1177f(%rip), %rcx     # 0x1c24a
movl $0xd58, %r8d            # imm = 0xD58
callq 0x11a50
movl -0x1c(%rbp), %eax
movq %rax, 0x30e70(%rip)     # 0x3b950
cmpl $0x0, -0x1c(%rbp)
je 0xab0c
movl -0x1c(%rbp), %eax
addq 0x20dd8(%rip), %rax     # 0x2b8c8
movq %rax, 0x20dd1(%rip)     # 0x2b8c8
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
leaq 0x30e59(%rip), %rdi     # 0x3b960
callq 0x3360
movq 0x30e2d(%rip), %rdi     # 0x3b940
xorl %esi, %esi
movl $0x1, %edx
leaq 0x11729(%rip), %rcx     # 0x1c24a
movl $0xd60, %r8d            # imm = 0xD60
callq 0x119a0
movq 0x30e15(%rip), %rdi     # 0x3b948
xorl %esi, %esi
movl $0x1, %edx
leaq 0x11709(%rip), %rcx     # 0x1c24a
movl $0xd61, %r8d            # imm = 0xD61
callq 0x119a0
cmpl $0x0, -0x1c(%rbp)
jne 0xabc7
cmpq $0x0, 0x30de6(%rip)     # 0x3b940
je 0xabc7
movq 0x30dd5(%rip), %rdi     # 0x3b938
leaq 0x116e0(%rip), %rsi     # 0x1c24a
movl $0xd66, %edx            # imm = 0xD66
callq 0x11ec0
movq 0x30db5(%rip), %rdi     # 0x3b930
leaq 0x116c8(%rip), %rsi     # 0x1c24a
movl $0xd67, %edx            # imm = 0xD67
callq 0x11ec0
movq 0x30db5(%rip), %rdi     # 0x3b948
leaq 0x116b0(%rip), %rsi     # 0x1c24a
movl $0xd68, %edx            # imm = 0xD68
callq 0x11c00
movq 0x30d95(%rip), %rdi     # 0x3b940
leaq 0x11698(%rip), %rsi     # 0x1c24a
movl $0xd69, %edx            # imm = 0xD69
callq 0x11c00
movq $0x0, 0x30d79(%rip) # 0x3b940
movl $0x0, -0x4(%rbp)
jmp 0xac56
cmpl $0x0, -0x1c(%rbp)
je 0xac4f
cmpl $0x1, 0x18c28(%rip)     # 0x23808
jne 0xabf6
movl 0x18bac(%rip), %edi     # 0x23794
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0xe2c0
cmpl $0x1, 0x18bcb(%rip)     # 0x237c8
jne 0xac1a
movq 0x20cca(%rip), %rdi     # 0x2b8d0
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0xe030
movq %rax, -0x28(%rbp)
jmp 0xac33
movq 0x20caf(%rip), %rdi     # 0x2b8d0
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0xdf70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, 0x20c92(%rip)     # 0x2b8d0
movl -0x1c(%rbp), %eax
addq 0x20c80(%rip), %rax     # 0x2b8c8
movq %rax, 0x20c79(%rip)     # 0x2b8c8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop