// File: /workspace/github_c_makefile_star2_O2/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, 0x19455(%rip)     # 0x2447c
je 0xb03e
movl $0x1, 0x19445(%rip)     # 0x24478
andq $0x0, 0x19435(%rip)     # 0x24470
xorl %eax, %eax
retq
pushq %rbx
cmpl $0x2, 0x113aa(%rip)     # 0x1c3f0
jl 0xb119
cmpl $-0x1, 0x2147d(%rip)    # 0x2c4d0
jne 0xb09a
movl $0x1, 0x21471(%rip)     # 0x2c4d0
leaq 0x929a(%rip), %rbx      # 0x14300
pushq $0x1
popq %rdi
movl $0xa17, %edx            # imm = 0xA17
movq %rbx, %rsi
callq 0xd5df
movq %rax, 0x2145b(%rip)     # 0x2c4d8
leaq 0x195(%rip), %rdi       # 0xb219
movl $0xa18, %ecx            # imm = 0xA18
xorl %esi, %esi
movq %rbx, %rdx
callq 0xd940
movq %rax, 0x21446(%rip)     # 0x2c4e0
callq 0xab8a
movl 0x2142b(%rip), %eax     # 0x2c4d0
testl %eax, %eax
leaq 0x193ea(%rip), %rcx     # 0x24498
leaq 0x11387(%rip), %rdx     # 0x1c43c
cmoveq %rcx, %rdx
movq %rdx, 0x193a8(%rip)     # 0x24468
movq 0x21401(%rip), %rcx     # 0x2c4c8
movq %rcx, 0x193a2(%rip)     # 0x24470
cmpq $0x8000, %rcx           # imm = 0x8000
jne 0xb140
pushq $0x1
popq %rcx
subl %eax, %ecx
movl %ecx, 0x213ee(%rip)     # 0x2c4d0
movq 0x213ef(%rip), %rdi     # 0x2c4d8
leaq 0x9210(%rip), %rbx      # 0x14300
movl $0xa26, %edx            # imm = 0xA26
movq %rbx, %rsi
callq 0xd763
movq 0x213d4(%rip), %rdi     # 0x2c4d8
pushq $0x1
popq %rdx
movl $0xa27, %r8d            # imm = 0xA27
xorl %esi, %esi
movq %rbx, %rcx
callq 0xd7c1
jmp 0xb176
movl 0x11231(%rip), %edi     # 0x1c350
leaq 0x11316(%rip), %rsi     # 0x1c43c
movq %rsi, 0x1933b(%rip)     # 0x24468
movl $0x8000, %edx           # imm = 0x8000
callq 0xb1a7
movq %rax, 0x19332(%rip)     # 0x24470
jmp 0xb17d
movq 0x21399(%rip), %rdi     # 0x2c4e0
leaq 0x91b2(%rip), %rbx      # 0x14300
movl $0xa2c, %edx            # imm = 0xA2C
movq %rbx, %rsi
callq 0xda9f
movq 0x21376(%rip), %rdi     # 0x2c4d8
movl $0xa2d, %edx            # imm = 0xA2D
movq %rbx, %rsi
callq 0xd8e3
orl $-0x1, 0x2135a(%rip)    # 0x2c4d0
movq 0x192f3(%rip), %rax     # 0x24470
cmpq $0x7fff, %rax           # imm = 0x7FFF
popq %rbx
ja 0xb19f
movl $0x1, 0x192ec(%rip)     # 0x2447c
testq %rax, %rax
jne 0xb19f
movl $0x1, 0x192d9(%rip)     # 0x24478
addq %rax, 0x192da(%rip)     # 0x24480
retq