// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
testq %rdi, %rdi
je 0x4fa3
movq %rsi, %rbx
testq %rsi, %rsi
je 0x4fc2
movq %rdx, %r15
movq %rdi, %r14
testq %rdx, %rdx
je 0x4e3e
movq %r15, %r12
movl $0x9, %edi
movq %rbx, %rsi
callq 0x2120
decq %r12
jne 0x4e2c
movl (%r14), %eax
decl %eax
cmpl $0xc, %eax
ja 0x4ec4
leaq 0x23a1(%rip), %rcx      # 0x71f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%r14), %rax
movq 0x8(%rax), %rcx
leaq 0x259b(%rip), %rsi      # 0x7402
leaq 0x16ed(%rip), %rdx      # 0x655b
leaq 0x174f(%rip), %r8       # 0x65c4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x4f43
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x526c
leaq 0x2567(%rip), %rsi      # 0x7408
leaq 0x16f5(%rip), %rdx      # 0x659d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
movq 0x20(%r14), %rdi
testq %rdi, %rdi
jne 0x4f47
jmp 0x4f4f
leaq 0x2545(%rip), %rdi      # 0x7410
movl $0x22, %esi
jmp 0x4f5b
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5157
movq 0x18(%r14), %rax
cmpl $0x4, (%rax)
jne 0x4f2a
movq 0x8(%rax), %rdx
leaq 0x2506(%rip), %rsi      # 0x7405
leaq 0x16be(%rip), %rcx      # 0x65c4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
jmp 0x4f43
movq %r14, %rdi
movq %rbx, %rsi
callq 0x531d
testb %al, %al
je 0x4f70
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24af(%rip), %rdi      # 0x73e0
movl $0x21, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x21b0
movq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x4fe1
leaq 0x1d29(%rip), %rdi      # 0x6c7f
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x21b0
movq 0x18(%r14), %rax
movq 0x8(%rax), %rdx
leaq 0x23b2(%rip), %rsi      # 0x7331
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
movq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x5408
leaq 0x2470(%rip), %rdi      # 0x740c
movl $0x3, %esi
jmp 0x4f5b
leaq 0x1134(%rip), %rdi      # 0x60de
leaq 0x2273(%rip), %rsi      # 0x7224
leaq 0x23f8(%rip), %rcx      # 0x73b0
movl $0x78, %edx
callq 0x2090
leaq 0x182a(%rip), %rdi      # 0x67f3
leaq 0x2254(%rip), %rsi      # 0x7224
leaq 0x23d9(%rip), %rcx      # 0x73b0
movl $0x79, %edx
callq 0x2090