// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/pigz.c
// Function: load
local size_t load(void) {
    // if already detected end of file, do nothing
    if (g.in_short) {
        g.in_eof = 1;
        g.in_left = 0;
        return 0;
    }

#ifndef NOTHREAD
    // if first time in or procs == 1, read a buffer to have something to
    // return, otherwise wait for the previous read job to complete
    if (g.procs > 1) {
        // if first time, fire up the read thread, ask for a read
        if (g.in_which == -1) {
            g.in_which = 1;
            g.load_state = new_lock(1);
            g.load_thread = launch(load_read, NULL);
        }

        // wait for the previously requested read to complete
        load_wait();

        // set up input buffer with the data just read
        g.in_next = g.in_which ? g.in_buf : g.in_buf2;
        g.in_left = g.in_len;

        // if not at end of file, alert read thread to load next buffer,
        // alternate between g.in_buf and g.in_buf2
        if (g.in_len == BUF) {
            g.in_which = 1 - g.in_which;
            possess(g.load_state);
            twist(g.load_state, TO, 1);
        }

        // at end of file -- join read thread (already exited), clean up
        else {
            join(g.load_thread);
            free_lock(g.load_state);
            g.in_which = -1;
        }
    }
    else
#endif
    {
        // don't use threads -- simply read a buffer into g.in_buf
        g.in_left = readn(g.ind, g.in_next = g.in_buf, BUF);
    }

    // note end of file
    if (g.in_left < BUF) {
        g.in_short = 1;

        // if we got bupkis, now is the time to mark eof
        if (g.in_left == 0)
            g.in_eof = 1;
    }

    // update the total and return the available bytes
    g.in_tot += g.in_left;
    return g.in_left;
}

// Assembly:
cmpl $0x0, 0x1a6b9(%rip)     # 0x2547c
je 0xaddd
movl $0x1, 0x1a6a9(%rip)     # 0x25478
movq $0x0, 0x1a696(%rip) # 0x25470
xorl %eax, %eax
retq
pushq %rbx
cmpl $0x2, 0x1260b(%rip)     # 0x1d3f0
jl 0xaebe
cmpl $-0x1, 0x226de(%rip)    # 0x2d4d0
jne 0xae3b
movl $0x1, 0x226d2(%rip)     # 0x2d4d0
leaq 0xa4fb(%rip), %rbx      # 0x15300
movl $0x1, %edi
movl $0xa17, %edx            # imm = 0xA17
movq %rbx, %rsi
callq 0xddaf
movq %rax, 0x226ba(%rip)     # 0x2d4d8
leaq 0x19f(%rip), %rdi       # 0xafc4
movl $0xa18, %ecx            # imm = 0xA18
xorl %esi, %esi
movq %rbx, %rdx
callq 0xe100
movq %rax, 0x226a5(%rip)     # 0x2d4e0
callq 0xa8dc
movl 0x2268a(%rip), %eax     # 0x2d4d0
testl %eax, %eax
leaq 0x1a649(%rip), %rcx     # 0x25498
leaq 0x125e6(%rip), %rdx     # 0x1d43c
cmoveq %rcx, %rdx
movq %rdx, 0x1a607(%rip)     # 0x25468
movq 0x22660(%rip), %rcx     # 0x2d4c8
movq %rcx, 0x1a601(%rip)     # 0x25470
cmpq $0x8000, %rcx           # imm = 0x8000
jne 0xaee5
movl $0x1, %ecx
subl %eax, %ecx
movl %ecx, 0x2264b(%rip)     # 0x2d4d0
movq 0x2264c(%rip), %rdi     # 0x2d4d8
leaq 0xa46d(%rip), %rbx      # 0x15300
movl $0xa26, %edx            # imm = 0xA26
movq %rbx, %rsi
callq 0xdf23
movq 0x22631(%rip), %rdi     # 0x2d4d8
movl $0x1, %edx
movl $0xa27, %r8d            # imm = 0xA27
xorl %esi, %esi
movq %rbx, %rcx
callq 0xdf81
jmp 0xaf1e
movl 0x1248c(%rip), %edi     # 0x1d350
leaq 0x12571(%rip), %rsi     # 0x1d43c
movq %rsi, 0x1a596(%rip)     # 0x25468
movl $0x8000, %edx           # imm = 0x8000
callq 0xaf4f
movq %rax, 0x1a58d(%rip)     # 0x25470
jmp 0xaf1e
movq 0x225f4(%rip), %rdi     # 0x2d4e0
leaq 0xa40d(%rip), %rbx      # 0x15300
movl $0xa2c, %edx            # imm = 0xA2C
movq %rbx, %rsi
callq 0xe280
movq 0x225d1(%rip), %rdi     # 0x2d4d8
movl $0xa2d, %edx            # imm = 0xA2D
movq %rbx, %rsi
callq 0xe0a3
movl $0xffffffff, 0x225b2(%rip) # imm = 0xFFFFFFFF
movq 0x1a54b(%rip), %rax     # 0x25470
cmpq $0x7fff, %rax           # imm = 0x7FFF
popq %rbx
ja 0xaf47
movl $0x1, 0x1a544(%rip)     # 0x2547c
testq %rax, %rax
jne 0xaf47
movl $0x1, 0x1a531(%rip)     # 0x25478
addq %rax, 0x1a532(%rip)     # 0x25480
retq