// File: /workspace/github_c_makefile_star2_O0/sharmaeklavya2[P]cerplag/compile_x86.c
// Function: addr_to_x86_arg
void addr_to_x86_arg(const AddrNode* an, char* dest, bool add_size, const char* index_reg) {
    if(an == NULL) {
        dest[0] = '\0';
        return;
    }
    switch(an->addr_type) {
        case ADDR_VAR:
        case ADDR_TEMP:
            if(add_size) {
                snprintf(dest, X86_ARG_SIZE, "%s [%s + %d]", std_size_name[an->type],
                    DATA_REG, an->offset);
            }
            else {
                snprintf(dest, X86_ARG_SIZE, "[%s + %d]", DATA_REG, an->offset);
            }
            break;
        case ADDR_CONST:
            if(an->type == TYPE_INTEGER) {
                snprintf(dest, X86_ARG_SIZE, "%d", an->imm.i);
            }
            else if(an->type == TYPE_REAL) {
                snprintf(dest, X86_ARG_SIZE, "%lf", an->imm.f);
            }
            else {
                snprintf(dest, X86_ARG_SIZE, "%c", (an->imm.b)?'1':'0');
            }
            break;
        case ADDR_ARR: {
            int size = TYPE_SIZES[an->type];
            int base_addr = an->base_addr->offset;
            if(an->index->addr_type == ADDR_CONST) {
                int i = an->index->imm.i;
                if(add_size) {
                    snprintf(dest, X86_ARG_SIZE, "%s [%s + %d]", std_size_name[an->type],
                        DATA_REG, base_addr + size * (i-1));
                }
                else {
                    snprintf(dest, X86_ARG_SIZE, "[%s + %d]", DATA_REG, base_addr + size * (i-1));
                }
            }
            else if(add_size) {
                snprintf(dest, X86_ARG_SIZE, "%s [%s + %s*%d + %d]", std_size_name[an->type],
                    DATA_REG, index_reg, size, base_addr - size);
            }
            else {
                snprintf(dest, X86_ARG_SIZE, "[%s + %s*%d + %d]", DATA_REG, index_reg,
                    size, base_addr - size);
            }
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x111ce
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
jmp 0x11443
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x30(%rbp)
subl $0x2, %eax
jb 0x111fe
jmp 0x111df
movl -0x30(%rbp), %eax
subl $0x2, %eax
je 0x1126c
jmp 0x111ed
movl -0x30(%rbp), %eax
subl $0x3, %eax
je 0x112f7
jmp 0x11443
testb $0x1, -0x11(%rbp)
je 0x11241
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
leaq 0xecda(%rip), %rcx      # 0x1fef0
imulq $0xa, %rax, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movl 0x28(%rax), %r9d
movl $0x1e, %esi
leaq 0x4c44(%rip), %rdx      # 0x15e75
leaq 0x4b34(%rip), %r8       # 0x15d6c
movb $0x0, %al
callq 0x30b0
jmp 0x11267
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x28(%rax), %r8d
movl $0x1e, %esi
leaq 0x4c1f(%rip), %rdx      # 0x15e78
leaq 0x4b0c(%rip), %rcx      # 0x15d6c
movb $0x0, %al
callq 0x30b0
jmp 0x11443
movq -0x8(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x11296
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x30(%rax), %ecx
movl $0x1e, %esi
leaq 0x37fb(%rip), %rdx      # 0x14a88
movb $0x0, %al
callq 0x30b0
jmp 0x112f2
movq -0x8(%rbp), %rax
cmpl $0x2, 0x18(%rax)
jne 0x112c2
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movsd 0x30(%rax), %xmm0
movl $0x1e, %esi
leaq 0x3897(%rip), %rdx      # 0x14b50
movb $0x1, %al
callq 0x30b0
jmp 0x112f0
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movb 0x30(%rax), %dl
movl $0x30, %ecx
movl $0x31, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movl $0x1e, %esi
leaq 0x4b99(%rip), %rdx      # 0x15e82
movb $0x0, %al
callq 0x30b0
jmp 0x112f2
jmp 0x11443
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
leaq 0x98f9(%rip), %rax      # 0x1ac00
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl 0x28(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
cmpl $0x2, 0x14(%rax)
jne 0x113bf
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x2c(%rbp)
testb $0x1, -0x11(%rbp)
je 0x11389
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
leaq 0xeb9d(%rip), %rcx      # 0x1fef0
imulq $0xa, %rax, %rax
addq %rax, %rcx
movl -0x28(%rbp), %r9d
movl -0x24(%rbp), %eax
movl -0x2c(%rbp), %edx
subl $0x1, %edx
imull %edx, %eax
addl %eax, %r9d
movl $0x1e, %esi
leaq 0x4afc(%rip), %rdx      # 0x15e75
leaq 0x49ec(%rip), %r8       # 0x15d6c
movb $0x0, %al
callq 0x30b0
jmp 0x113ba
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %r8d
movl -0x24(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
imull %ecx, %eax
addl %eax, %r8d
movl $0x1e, %esi
leaq 0x4acc(%rip), %rdx      # 0x15e78
leaq 0x49b9(%rip), %rcx      # 0x15d6c
movb $0x0, %al
callq 0x30b0
jmp 0x11441
testb $0x1, -0x11(%rbp)
je 0x11410
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
leaq 0xeb19(%rip), %rcx      # 0x1fef0
imulq $0xa, %rax, %rax
addq %rax, %rcx
movq -0x20(%rbp), %r9
movl -0x24(%rbp), %r10d
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl $0x1e, %esi
leaq 0x4a8d(%rip), %rdx      # 0x15e85
leaq 0x496d(%rip), %r8       # 0x15d6c
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x30b0
jmp 0x1143f
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %r8
movl -0x24(%rbp), %r9d
movl -0x28(%rbp), %eax
subl -0x24(%rbp), %eax
movl $0x1e, %esi
leaq 0x4a5a(%rip), %rdx      # 0x15e88
leaq 0x4937(%rip), %rcx      # 0x15d6c
movl %eax, (%rsp)
movb $0x0, %al
callq 0x30b0
jmp 0x11441
jmp 0x11443
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)