// File: /workspace/github_cpp_makefile_star2_O2/Computer-Kids-Club[P]screenshare-pro-backend/base64.c
// Function: base64_encode_block(char const*, int, char*, base64_encodestate*)
int base64_encode_block(const char *plaintext_in, int length_in, char *code_out, base64_encodestate *state_in) {
    const char *plainchar = plaintext_in;
    const char *const plaintextend = plaintext_in + length_in;
    char *codechar = code_out;
    char result;
    char fragment;

    result = state_in->result;

    switch (state_in->step) {
        while (1) {
            case step_A:
                if (plainchar == plaintextend) {
                    state_in->result = result;
                    state_in->step = step_A;
                    return codechar - code_out;
                }
                fragment = *plainchar++;
                result = (fragment & 0x0fc) >> 2;
                *codechar++ = base64_encode_value(result);
                result = (fragment & 0x003) << 4;
            case step_B:
                if (plainchar == plaintextend) {
                    state_in->result = result;
                    state_in->step = step_B;
                    return codechar - code_out;
                }
                fragment = *plainchar++;
                result |= (fragment & 0x0f0) >> 4;
                *codechar++ = base64_encode_value(result);
                result = (fragment & 0x00f) << 2;
            case step_C:
                if (plainchar == plaintextend) {
                    state_in->result = result;
                    state_in->step = step_C;
                    return codechar - code_out;
                }
                fragment = *plainchar++;
                result |= (fragment & 0x0c0) >> 6;
                *codechar++ = base64_encode_value(result);
                result = (fragment & 0x03f) >> 0;
                *codechar++ = base64_encode_value(result);

                ++(state_in->stepcount);
                if (state_in->stepcount == CHARS_PER_LINE / 4) {
                    *codechar++ = '\n';
                    state_in->stepcount = 0;
                }
        }
    }
    /* control should not reach here */
    return codechar - code_out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movslq %esi, %r8
addq %rdi, %r8
movb 0x4(%rcx), %r9b
movl (%rcx), %r10d
cmpl $0x2, %r10d
je 0x5882
cmpl $0x1, %r10d
je 0x587d
xorl %eax, %eax
movq %rdx, %rsi
testl %r10d, %r10d
je 0x5887
jmp 0x5980
movq %rdx, %rsi
jmp 0x58b5
movq %rdx, %rsi
jmp 0x58f3
cmpq %r8, %rdi
je 0x596d
movzbl (%rdi), %r9d
incq %rdi
movl %r9d, %eax
shrl $0x2, %eax
leaq 0x1ca6(%rip), %r10      # 0x754a
movb (%rax,%r10), %al
movb %al, (%rsi)
incq %rsi
shlb $0x4, %r9b
andb $0x30, %r9b
cmpq %r8, %rdi
je 0x5971
movb (%rdi), %al
incq %rdi
movl %eax, %r10d
shrb $0x4, %r10b
orb %r9b, %r10b
movb $0x3d, %r9b
cmpb $0x3f, %r10b
jg 0x58e5
movsbq %r10b, %r9
leaq 0x1c69(%rip), %r10      # 0x754a
movb (%r9,%r10), %r9b
movb %r9b, (%rsi)
incq %rsi
shlb $0x2, %al
andb $0x3c, %al
movl %eax, %r9d
cmpq %r8, %rdi
je 0x5966
movzbl (%rdi), %eax
incq %rdi
movl %eax, %r10d
shrb $0x6, %r10b
orb %r9b, %r10b
movb $0x3d, %r9b
cmpb $0x3f, %r10b
jg 0x5920
movsbq %r10b, %r9
leaq 0x1c2e(%rip), %r10      # 0x754a
movb (%r9,%r10), %r9b
movb %r9b, (%rsi)
andl $0x3f, %eax
movl %eax, %r9d
leaq 0x1c1a(%rip), %r10      # 0x754a
movb (%rax,%r10), %r10b
leaq 0x2(%rsi), %rax
movb %r10b, 0x1(%rsi)
movl 0x8(%rcx), %r10d
incl %r10d
movl %r10d, 0x8(%rcx)
cmpl $0x12, %r10d
jne 0x595e
movb $0xa, 0x2(%rsi)
addq $0x3, %rsi
andl $0x0, 0x8(%rcx)
jmp 0x5887
movq %rax, %rsi
jmp 0x5887
movl $0x2, %eax
jmp 0x5976
xorl %eax, %eax
jmp 0x5976
movl $0x1, %eax
movb %r9b, 0x4(%rcx)
movl %eax, (%rcx)
subl %edx, %esi
movl %esi, %eax
popq %rbp
retq