// File: /workspace/github_c_makefile_star2_O3/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, 0x1a3f9(%rip)     # 0x2548c
je 0xb0ad
movl $0x1, 0x1a3e9(%rip)     # 0x25488
movq $0x0, 0x1a3d6(%rip) # 0x25480
xorl %eax, %eax
retq
pushq %rbx
cmpl $0x2, 0x1234b(%rip)     # 0x1d400
jl 0xb18e
cmpl $-0x1, 0x2241e(%rip)    # 0x2d4e0
jne 0xb10b
movl $0x1, 0x22412(%rip)     # 0x2d4e0
leaq 0xa22b(%rip), %rbx      # 0x15300
movl $0x1, %edi
movl $0xa17, %edx            # imm = 0xA17
movq %rbx, %rsi
callq 0xe13f
movq %rax, 0x223fa(%rip)     # 0x2d4e8
leaq 0x19f(%rip), %rdi       # 0xb294
movl $0xa18, %ecx            # imm = 0xA18
xorl %esi, %esi
movq %rbx, %rdx
callq 0xe490
movq %rax, 0x223e5(%rip)     # 0x2d4f0
callq 0xabdd
movl 0x223ca(%rip), %eax     # 0x2d4e0
testl %eax, %eax
leaq 0x1a389(%rip), %rcx     # 0x254a8
leaq 0x12326(%rip), %rdx     # 0x1d44c
cmoveq %rcx, %rdx
movq %rdx, 0x1a347(%rip)     # 0x25478
movq 0x223a0(%rip), %rcx     # 0x2d4d8
movq %rcx, 0x1a341(%rip)     # 0x25480
cmpq $0x8000, %rcx           # imm = 0x8000
jne 0xb1b5
movl $0x1, %ecx
subl %eax, %ecx
movl %ecx, 0x2238b(%rip)     # 0x2d4e0
movq 0x2238c(%rip), %rdi     # 0x2d4e8
leaq 0xa19d(%rip), %rbx      # 0x15300
movl $0xa26, %edx            # imm = 0xA26
movq %rbx, %rsi
callq 0xe2b3
movq 0x22371(%rip), %rdi     # 0x2d4e8
movl $0x1, %edx
movl $0xa27, %r8d            # imm = 0xA27
xorl %esi, %esi
movq %rbx, %rcx
callq 0xe311
jmp 0xb1ee
movl 0x121cc(%rip), %edi     # 0x1d360
leaq 0x122b1(%rip), %rsi     # 0x1d44c
movq %rsi, 0x1a2d6(%rip)     # 0x25478
movl $0x8000, %edx           # imm = 0x8000
callq 0xb21f
movq %rax, 0x1a2cd(%rip)     # 0x25480
jmp 0xb1f5
movq 0x22334(%rip), %rdi     # 0x2d4f0
leaq 0xa13d(%rip), %rbx      # 0x15300
movl $0xa2c, %edx            # imm = 0xA2C
movq %rbx, %rsi
callq 0xe610
movq 0x22311(%rip), %rdi     # 0x2d4e8
movl $0xa2d, %edx            # imm = 0xA2D
movq %rbx, %rsi
callq 0xe433
movl $0xffffffff, 0x222f2(%rip) # imm = 0xFFFFFFFF
movq 0x1a28b(%rip), %rax     # 0x25480
cmpq $0x7fff, %rax           # imm = 0x7FFF
popq %rbx
ja 0xb217
movl $0x1, 0x1a284(%rip)     # 0x2548c
testq %rax, %rax
jne 0xb217
movl $0x1, 0x1a271(%rip)     # 0x25488
addq %rax, 0x1a272(%rip)     # 0x25490
retq