// File: /workspace/github_cpp_makefile_star2_O2/vssense[P]Compiler/src/front-end/translator.cpp
// Function: TranslateStatement(Node*, _IO_FILE*, unsigned long)
void TranslateStatement(Node* node, FILE* file, size_t num_tabs)
{
    assert(node);
    assert(file);

    SetTabs(file, num_tabs);

    switch (node->type)
    {
        case ASSG_TYPE :
        {
            if (node->left->type == ID_TYPE)
            {
                fprintf(file, "%s %s ", node->left->value.name, OPERATORS[ASSIGNMENT].rus_name);
            }
            else
            {
                fprintf(file, "can't interpret this construction");
            }
            
            TranslateExpression(node->right, file);
            fprintf(file, ";\n");
            break;
        }
        case DECL_TYPE :
        {
            fprintf(file, "%s %s %s ", OPERATORS[DECLARATOR].rus_name, node->left->value.name, OPERATORS[ASSIGNMENT].rus_name);
            TranslateExpression(node->right, file);
            fprintf(file, ";\n");
            break;
        }
        case COND_TYPE :
        {
            TranslateCondition(node, file, num_tabs);
            break;
        }
        case LOOP_TYPE :
        {
            TranslateLoop(node, file, num_tabs);
            break;
        }
        case CALL_TYPE :
        {
            if (!TranslateStdCall(node, file))
            {
                fprintf(file, "%s(", node->left->value.name);
                TranslateParams(node->right, file);
                fprintf(file, ");\n");
            }
            break;
        }
        case JUMP_TYPE :
        {
            fprintf(file, "%s ", OPERATORS[RET].rus_name);
            if (node->right != nullptr)
            {
                TranslateExpression(node->right, file);
            }
            fprintf(file, ";\n");
            break;
        }
        default :
        {
            fprintf(file, "can't interpret this construction ");
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x4d94
movq %rsi, %rbx
testq %rsi, %rsi
je 0x4dad
movq %rdx, %r15
movq %rdi, %r14
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x4bb1
movl (%r14), %eax
decl %eax
cmpl $0xc, %eax
ja 0x4cbd
leaq 0x25da(%rip), %rcx      # 0x7220
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%r14), %rax
movq 0x8(%rax), %rcx
leaq 0x27d4(%rip), %rsi      # 0x7432
leaq 0x18f4(%rip), %rdx      # 0x6559
leaq 0x1956(%rip), %r8       # 0x65c2
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x4d39
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5034
leaq 0x279e(%rip), %rsi      # 0x7438
leaq 0x18fa(%rip), %rdx      # 0x659b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
movq 0x20(%r14), %rdi
testq %rdi, %rdi
jne 0x4d3d
jmp 0x4d45
leaq 0x277c(%rip), %rdi      # 0x7440
pushq $0x22
jmp 0x4d4e
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4f2f
movq 0x18(%r14), %rax
cmpl $0x4, (%rax)
jne 0x4d24
movq 0x8(%rax), %rdx
leaq 0x273e(%rip), %rsi      # 0x7435
leaq 0x18c4(%rip), %rcx      # 0x65c2
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x4d39
movq %r14, %rdi
movq %rbx, %rsi
callq 0x50e1
testb %al, %al
je 0x4d64
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26e5(%rip), %rdi      # 0x7410
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x21b0
movq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x4dca
leaq 0x1f6b(%rip), %rdi      # 0x6cb7
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21b0
movq 0x18(%r14), %rax
movq 0x8(%rax), %rdx
leaq 0x25ee(%rip), %rsi      # 0x7361
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
movq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x51c9
leaq 0x26ac(%rip), %rdi      # 0x743c
pushq $0x3
jmp 0x4d4e
leaq 0x1341(%rip), %rdi      # 0x60dc
leaq 0x24b2(%rip), %rsi      # 0x7254
leaq 0x2637(%rip), %rcx      # 0x73e0
pushq $0x78
jmp 0x4dc4
leaq 0x1a77(%rip), %rdi      # 0x682b
leaq 0x2499(%rip), %rsi      # 0x7254
leaq 0x261e(%rip), %rcx      # 0x73e0
pushq $0x79
popq %rdx
callq 0x2090