// File: fondoger[P]C0-Compiler/src/grammar.cpp
// Function: pPrintfStatement()
static void pPrintfStatement()
{
    std::string arg1, arg2;
    DataType temp_dtype;
    std::stringstream ss;
    assert(g_sym == PRINTFSY);
    readSymbol();
    test3(Symset({LPARENT}));
    readSymbol();
    if (g_sym == STRVALUE) {
        // insert string to strings table and get a
        // label for this string.
        arg1 = string2label(g_str);
        genMidCode(WRITE, "str", arg1, NONE);
        readSymbol();
        if (g_sym == COMMA) {
            readSymbol();
            pExpression(arg2, temp_dtype);
            std::string t = (temp_dtype == DT_INT ? "int" : "char");
            genMidCode(WRITE, t, arg2, NONE);
        }
    } else {
        pExpression(arg1, temp_dtype);
        std::string t = (temp_dtype == DT_INT ? "int" : "char");
        genMidCode(WRITE, t, arg1, NONE);
    }
    // break line for each printf
    //std::string newline = string2label("\\n");
    //genMidCode(WRITE, "str", newline, NONE);
    test3(Symset({RPARENT}));
    readSymbol();
    test3(Symset({SEMICOLON}));
    readSymbol();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3d0, %rsp            # imm = 0x3D0
leaq -0x20(%rbp), %rdi
callq 0x3450
leaq -0x40(%rbp), %rdi
callq 0x3450
leaq -0x1d0(%rbp), %rdi
callq 0x3270
jmp 0x1d2eb
leaq 0x2e3be(%rip), %rax     # 0x4b6b0
cmpl $0xd, (%rax)
jne 0x1d2f9
jmp 0x1d32f
leaq 0x1855d(%rip), %rdi     # 0x3585d
leaq 0x18121(%rip), %rsi     # 0x35428
movl $0x16b, %edx            # imm = 0x16B
leaq 0x1855c(%rip), %rcx     # 0x3586f
callq 0x3230
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
jmp 0x1d9cb
callq 0x2e050
jmp 0x1d336
jmp 0x1d338
movl $0x1d, -0x1fc(%rbp)
leaq -0x1fc(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq $0x1, -0x1f0(%rbp)
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
leaq -0x1e8(%rbp), %rdi
callq 0x227f0
jmp 0x1d377
movl $0x22, -0x220(%rbp)
movl $0x26, -0x21c(%rbp)
leaq -0x220(%rbp), %rax
movq %rax, -0x218(%rbp)
movq $0x2, -0x210(%rbp)
movq -0x218(%rbp), %rsi
movq -0x210(%rbp), %rdx
leaq -0x208(%rbp), %rdi
callq 0x227f0
jmp 0x1d3c0
movq -0x1e8(%rbp), %rdi
movq -0x208(%rbp), %rsi
callq 0x18170
jmp 0x1d3d5
movl $0x1d, -0x23c(%rbp)
leaq -0x23c(%rbp), %rax
movq %rax, -0x238(%rbp)
movq $0x1, -0x230(%rbp)
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdx
leaq -0x228(%rbp), %rdi
callq 0x227f0
jmp 0x1d414
leaq 0x2e295(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x228(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1d431
jmp 0x1d45e
callq 0x2e050
jmp 0x1d438
movl $0x1, -0x240(%rbp)
jmp 0x1d998
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
jmp 0x1d9bf
jmp 0x1d460
jmp 0x1d462
callq 0x2e050
jmp 0x1d469
leaq 0x2e240(%rip), %rax     # 0x4b6b0
cmpl $0x12, (%rax)
jne 0x1d672
leaq 0x2e260(%rip), %rsi     # 0x4b6e0
leaq -0x260(%rbp), %rdi
callq 0x2f5c0
jmp 0x1d48e
leaq -0x20(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movq %rsi, -0x3b0(%rbp)
callq 0x33d0
movq -0x3b0(%rbp), %rdi
callq 0x35e8
movl $0xf, -0x264(%rbp)
leaq -0x289(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x3570
movq -0x3a8(%rbp), %rdx
leaq 0x183ab(%rip), %rsi     # 0x35887
leaq -0x288(%rbp), %rdi
callq 0x3440
jmp 0x1d4ea
leaq 0x29b0f(%rip), %rcx     # 0x47000
leaq -0x264(%rbp), %rdi
leaq -0x288(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x26340
jmp 0x1d50a
leaq -0x288(%rbp), %rdi
callq 0x35e8
leaq -0x289(%rbp), %rdi
callq 0x3370
callq 0x2e050
jmp 0x1d529
leaq 0x2e180(%rip), %rax     # 0x4b6b0
cmpl $0x24, (%rax)
jne 0x1d66d
callq 0x2e050
jmp 0x1d540
leaq -0x40(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x1f630
jmp 0x1d54f
movl -0x44(%rbp), %eax
subl $0x1, %eax
leaq 0x1824d(%rip), %rcx     # 0x357a9
leaq 0x17b50(%rip), %rax     # 0x350b3
cmoveq %rcx, %rax
movq %rax, -0x3c0(%rbp)
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x3570
movq -0x3c0(%rbp), %rsi
movq -0x3b8(%rbp), %rdx
leaq -0x2b0(%rbp), %rdi
callq 0x3440
jmp 0x1d59d
leaq -0x2b1(%rbp), %rdi
callq 0x3370
movl $0xf, -0x2b8(%rbp)
leaq 0x29a46(%rip), %rcx     # 0x47000
leaq -0x2b8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x26340
jmp 0x1d5d3
leaq -0x2b0(%rbp), %rdi
callq 0x35e8
jmp 0x1d66d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
jmp 0x1d616
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x35e8
leaq -0x289(%rbp), %rdi
callq 0x3370
jmp 0x1d9bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x2b1(%rbp), %rdi
callq 0x3370
jmp 0x1d9bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x35e8
jmp 0x1d9bf
jmp 0x1d759
leaq -0x20(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x1f630
jmp 0x1d681
movl -0x44(%rbp), %eax
subl $0x1, %eax
leaq 0x1811b(%rip), %rcx     # 0x357a9
leaq 0x17a1e(%rip), %rax     # 0x350b3
cmoveq %rcx, %rax
movq %rax, -0x3d0(%rbp)
leaq -0x2d9(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x3570
movq -0x3d0(%rbp), %rsi
movq -0x3c8(%rbp), %rdx
leaq -0x2d8(%rbp), %rdi
callq 0x3440
jmp 0x1d6cf
leaq -0x2d9(%rbp), %rdi
callq 0x3370
movl $0xf, -0x2e0(%rbp)
leaq 0x29914(%rip), %rcx     # 0x47000
leaq -0x2e0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x26340
jmp 0x1d705
leaq -0x2d8(%rbp), %rdi
callq 0x35e8
jmp 0x1d759
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x2d9(%rbp), %rdi
callq 0x3370
jmp 0x1d9bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x35e8
jmp 0x1d9bf
jmp 0x1d75b
movl $0x1e, -0x2fc(%rbp)
leaq -0x2fc(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq $0x1, -0x2f0(%rbp)
movq -0x2f8(%rbp), %rsi
movq -0x2f0(%rbp), %rdx
leaq -0x2e8(%rbp), %rdi
callq 0x227f0
jmp 0x1d79a
movl $0x22, -0x320(%rbp)
movl $0x26, -0x31c(%rbp)
leaq -0x320(%rbp), %rax
movq %rax, -0x318(%rbp)
movq $0x2, -0x310(%rbp)
movq -0x318(%rbp), %rsi
movq -0x310(%rbp), %rdx
leaq -0x308(%rbp), %rdi
callq 0x227f0
jmp 0x1d7e3
movq -0x2e8(%rbp), %rdi
movq -0x308(%rbp), %rsi
callq 0x18170
jmp 0x1d7f8
movl $0x1e, -0x33c(%rbp)
leaq -0x33c(%rbp), %rax
movq %rax, -0x338(%rbp)
movq $0x1, -0x330(%rbp)
movq -0x338(%rbp), %rsi
movq -0x330(%rbp), %rdx
leaq -0x328(%rbp), %rdi
callq 0x227f0
jmp 0x1d837
leaq 0x2de72(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x328(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1d854
jmp 0x1d86a
callq 0x2e050
jmp 0x1d85b
movl $0x1, -0x240(%rbp)
jmp 0x1d998
jmp 0x1d86c
jmp 0x1d86e
callq 0x2e050
jmp 0x1d875
jmp 0x1d877
movl $0x26, -0x35c(%rbp)
leaq -0x35c(%rbp), %rax
movq %rax, -0x358(%rbp)
movq $0x1, -0x350(%rbp)
movq -0x358(%rbp), %rsi
movq -0x350(%rbp), %rdx
leaq -0x348(%rbp), %rdi
callq 0x227f0
jmp 0x1d8b6
movl $0x22, -0x380(%rbp)
movl $0x26, -0x37c(%rbp)
leaq -0x380(%rbp), %rax
movq %rax, -0x378(%rbp)
movq $0x2, -0x370(%rbp)
movq -0x378(%rbp), %rsi
movq -0x370(%rbp), %rdx
leaq -0x368(%rbp), %rdi
callq 0x227f0
jmp 0x1d8ff
movq -0x348(%rbp), %rdi
movq -0x368(%rbp), %rsi
callq 0x18170
jmp 0x1d914
movl $0x26, -0x39c(%rbp)
leaq -0x39c(%rbp), %rax
movq %rax, -0x398(%rbp)
movq $0x1, -0x390(%rbp)
movq -0x398(%rbp), %rsi
movq -0x390(%rbp), %rdx
leaq -0x388(%rbp), %rdi
callq 0x227f0
jmp 0x1d953
leaq 0x2dd56(%rip), %rax     # 0x4b6b0
movl (%rax), %esi
leaq -0x388(%rbp), %rdi
callq 0x18b40
xorb $-0x1, %al
testb $0x1, %al
jne 0x1d970
jmp 0x1d983
callq 0x2e050
jmp 0x1d977
movl $0x1, -0x240(%rbp)
jmp 0x1d998
jmp 0x1d985
jmp 0x1d987
callq 0x2e050
jmp 0x1d98e
movl $0x0, -0x240(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x35f0
leaq -0x40(%rbp), %rdi
callq 0x35e8
leaq -0x20(%rbp), %rdi
callq 0x35e8
addq $0x3d0, %rsp            # imm = 0x3D0
popq %rbp
retq
leaq -0x1d0(%rbp), %rdi
callq 0x35f0
leaq -0x40(%rbp), %rdi
callq 0x35e8
leaq -0x20(%rbp), %rdi
callq 0x35e8
movq -0x1d8(%rbp), %rdi
callq 0x3560
nopl (%rax)