// File: /workspace/github_c_makefile_star2_O3/wjmelements[P]evm/evm.c
// Function: assemble
static void assemble(const char *contents) {
    op_t *programStart = &ops[CONSTRUCTOR_OFFSET];
    uint32_t programLength = 0;
    scanInit();
    for (; scanValid(&contents); programLength++) {
        if (programLength > (PROGRAM_BUFFER_LENGTH - CONSTRUCTOR_OFFSET)) {
            fprintf(stderr, "Program size exceeds limit; terminating");
            break;
        }
        programStart[programLength] = scanNextOp(&contents);
    }
    scanFinalize(programStart, &programLength);
    if (labelJumpdests) {
        fprintLabels(stdout);
        return;
    }
    if (wrapConstructor) {
        if (programLength < 0x20) {
            // PUSHx<>3d5260xx60xxf3
            programStart -= 1;
            *programStart = (PUSH1 - 1) + programLength;
            *((uint32_t *)(programStart + programLength + 1)) = 0x0060523d + (programLength << 24);
            *((uint32_t *)(programStart + programLength + 5)) = 0xf30060 + ((32 - programLength) << 8);
            programLength += 8;
        } else if (programLength == 0x20) {
            // 7f<>3d5260203df3
            programStart -= 1;
            *programStart = PUSH32;
            *((uint32_t *)(programStart + programLength + 1)) = 0x2060523d;
            *((uint16_t *)(programStart + programLength + 5)) = 0xf33d;
            programLength += 7;
        } else {
            programStart -= 4;
            *((uint32_t *)programStart) = 0xf33d393d;
            if (programLength < 0x100) {
                // 60xx8060093d393df3<>
                programStart -= 3;
                *((uint32_t *)programStart) = 0x3d096080;
                programStart -= 2;
                *((uint16_t *)programStart) = 0x0060 | programLength << 8;
                programLength += 9;
            } else if (programLength < 0x10000) {
                // 61xxxx80600a3d393df3<>
                programStart -= 3;
                *((uint32_t *)programStart) = 0x3d0a6080;
                programStart -= 3;
                *((uint32_t *)programStart) = 0x80000061 | (programLength & 0xff) << 16 | (programLength & 0xff00);
                programLength += 10;
            }
        }
    }

    for (; programLength--;) printf("%02x", *programStart++);
    putchar('\n');
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x8(%rsp), %rbx
movq %rdi, (%rbx)
movl $0x0, 0x4(%rsp)
xorl %eax, %eax
callq 0xf81c
movq %rbx, %rdi
callq 0xf851
testl %eax, %eax
je 0x4b14
xorl %r14d, %r14d
leaq 0x8(%rsp), %rbx
leaq 0x13f4d(%rip), %r15     # 0x18a30
cmpl $0x7001, %r14d          # imm = 0x7001
jae 0x4c13
movq %rbx, %rdi
callq 0xfc27
movb %al, 0x1000(%r14,%r15)
incq %r14
movl %r14d, 0x4(%rsp)
movq %rbx, %rdi
callq 0xf851
testl %eax, %eax
jne 0x4ae3
leaq 0x14f15(%rip), %rbx     # 0x19a30
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x10326
cmpb $0x1, 0x13ee1(%rip)     # 0x18a10
jne 0x4b45
movq 0x13490(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
callq 0x1053b
jmp 0x4c8b
movl 0x4(%rsp), %eax
cmpb $0x1, 0x13eb8(%rip)     # 0x18a08
jne 0x4b9b
cmpl $0x1f, %eax
ja 0x4bad
leal 0x5f(%rax), %ecx
movb %cl, 0x14ecf(%rip)      # 0x19a2f
leaq 0x14ec8(%rip), %rbx     # 0x19a2f
leaq 0x13ec2(%rip), %rcx     # 0x18a30
movl %eax, %edx
shll $0x18, %edx
orl $0x60523d, %edx         # imm = 0x60523D
movl %edx, 0x1000(%rax,%rcx)
movl %eax, %edx
shll $0x8, %edx
movl $0xf32060, %esi         # imm = 0xF32060
subl %edx, %esi
movl %esi, 0x1004(%rax,%rcx)
addl $0x8, %eax
jmp 0x4c5d
subl $0x1, %eax
movl %eax, 0x4(%rsp)
jae 0x4c63
jmp 0x4c81
cmpl $0x20, %eax
jne 0x4bdd
movb $0x7f, 0x14e76(%rip)    # 0x19a2f
leaq 0x14e6f(%rip), %rbx     # 0x19a2f
movl $0x2060523d, 0x14e86(%rip) # imm = 0x2060523D
movw $0xf33d, 0x14e81(%rip)  # imm = 0xF33D
movl $0x27, %eax
jmp 0x4c5d
movl $0xf33d393d, 0x14e45(%rip) # imm = 0xF33D393D
cmpl $0xff, %eax
ja 0x4c1d
movl $0x3d096080, 0x14e31(%rip) # imm = 0x3D096080
movl %eax, %ecx
shll $0x8, %ecx
orl $0x60, %ecx
movw %cx, 0x14e20(%rip)      # 0x19a27
leaq 0x14e19(%rip), %rbx     # 0x19a27
addl $0x9, %eax
jmp 0x4c5d
callq 0x33fa
jmp 0x4b14
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x4c56
movl $0x3d0a6080, 0x14dfb(%rip) # imm = 0x3D0A6080
movzbl %al, %ecx
shll $0x10, %ecx
movl %eax, %edx
andl $0xff00, %edx           # imm = 0xFF00
addl %edx, %ecx
addl $0x80000061, %ecx       # imm = 0x80000061
movl %ecx, 0x14ddc(%rip)     # 0x19a26
leaq 0x14dd5(%rip), %rbx     # 0x19a26
addl $0xa, %eax
jmp 0x4c5d
leaq 0x14dcf(%rip), %rbx     # 0x19a2c
decl %eax
movl %eax, 0x4(%rsp)
leaq 0xd714(%rip), %r14      # 0x1237e
movzbl (%rbx), %esi
incq %rbx
movq %r14, %rdi
xorl %eax, %eax
callq 0x3100
subl $0x1, 0x4(%rsp)
jae 0x4c6a
movl $0xa, %edi
callq 0x3050
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)