// File: kiranbhanushali[P]recursive-descent-parser-generator/template.cpp
// Function: generate_template(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void generate_template(string line){

    string function_template_begin = R"(
 void )" ;
    function_template_begin+=line[0] ;
    function_template_begin+= R"( () {
    )";
    
    string function = " int temp_pos = pos ;\n ";
    int if_stmt = 1 ,open_bracket = 1;
    for( int i =3;i<line.size();i++){
        if( line[i] =='|') {
            function += R"(
                if( cur=='$'){
                    return ;
                }
            )";
            if(open_bracket>1) {
                function+='}';
                open_bracket--;
            }
            
            function+=R"(
                pos = temp_pos;
                cur = line[pos];
            )";
            if_stmt = 1;
            continue;
        }
        
        // null symbol
        if(line[i]=='^'){
            continue;
        }
        
       if( isTerminal(line[i])){
            // matches statement 
            
            if( if_stmt) {
                function+= " if( cur== " ;
                function+=  "'" ;
                function+= line[i] ;
                function +=  "'){"
                                "match('" ;
                function+= line[i];
                function+= "');";
                if_stmt = 0 ; 
                open_bracket++;
            }
            else{
                function+= "match('" ;
                function+= line[i];
               function += "');";
            }
        }else{
            function +=  line[i];
            function += "();";
            if(!function_declaration_mp[line[i]]){
                funct_declaration+= "void ";
                funct_declaration+= line[i];
                funct_declaration+="();\n";
                function_declaration_mp[line[i]] = 1;
            }
        }

    }
    if(open_bracket>1)
    {
        open_bracket--;
        function+=R"(
                if( cur=='$'){
                    return ;
                }
            )";
        while(open_bracket--)
        function+="}\n";
    }


    string end_block = R"(
        }
    )";


    output_funct = function_template_begin + function + end_block + output_funct;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x2310
movq -0x100(%rbp), %rdx
leaq 0x2823(%rip), %rsi      # 0x52f7
leaq -0x28(%rbp), %rdi
callq 0x3190
jmp 0x2adf
leaq -0x29(%rbp), %rdi
callq 0x2200
movq -0x108(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2350
movq %rax, -0x110(%rbp)
jmp 0x2b01
movq -0x110(%rbp), %rax
movsbl (%rax), %esi
leaq -0x28(%rbp), %rdi
callq 0x20d0
jmp 0x2b16
leaq 0x27e2(%rip), %rsi      # 0x52ff
leaq -0x28(%rbp), %rdi
callq 0x21b0
jmp 0x2b28
leaq -0x61(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x2310
movq -0x118(%rbp), %rdx
leaq 0x27c4(%rip), %rsi      # 0x530a
leaq -0x60(%rbp), %rdi
callq 0x3190
jmp 0x2b51
leaq -0x61(%rbp), %rdi
callq 0x2200
movl $0x1, -0x68(%rbp)
movl $0x1, -0x6c(%rbp)
movl $0x3, -0x70(%rbp)
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rax
movq %rax, -0x120(%rbp)
callq 0x2100
movq %rax, %rcx
movq -0x120(%rbp), %rax
cmpq %rcx, %rax
jae 0x2f25
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x128(%rbp)
jmp 0x2bb2
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0x2c6c
leaq 0x2756(%rip), %rsi      # 0x5322
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2bd7
cmpl $0x1, -0x6c(%rbp)
jle 0x2c4e
leaq -0x60(%rbp), %rdi
movl $0x7d, %esi
callq 0x20d0
jmp 0x2bed
movl -0x6c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2c4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x2200
jmp 0x30cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x30c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x2200
jmp 0x30c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x30ba
leaq 0x2729(%rip), %rsi      # 0x537e
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2c60
movl $0x1, -0x68(%rbp)
jmp 0x2f17
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x130(%rbp)
jmp 0x2c85
movq -0x130(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x2c99
jmp 0x2f17
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x138(%rbp)
jmp 0x2cb2
movq -0x138(%rbp), %rax
movsbl (%rax), %edi
callq 0x4a90
movl %eax, -0x13c(%rbp)
jmp 0x2cc9
movl -0x13c(%rbp), %eax
cmpl $0x0, %eax
je 0x2df1
cmpl $0x0, -0x68(%rbp)
je 0x2d98
leaq 0x26e4(%rip), %rsi      # 0x53cd
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2cf4
leaq 0x26e7(%rip), %rsi      # 0x53e2
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2d06
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x148(%rbp)
jmp 0x2d1f
movq -0x148(%rbp), %rax
movsbl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x20d0
jmp 0x2d34
leaq 0x269e(%rip), %rsi      # 0x53d9
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2d46
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x150(%rbp)
jmp 0x2d5f
movq -0x150(%rbp), %rax
movsbl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x20d0
jmp 0x2d74
leaq 0x2669(%rip), %rsi      # 0x53e4
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2d86
movl $0x0, -0x68(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2dec
leaq 0x263d(%rip), %rsi      # 0x53dc
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2daa
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x158(%rbp)
jmp 0x2dc3
movq -0x158(%rbp), %rax
movsbl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x20d0
jmp 0x2dd8
leaq 0x2605(%rip), %rsi      # 0x53e4
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2dea
jmp 0x2dec
jmp 0x2f15
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x160(%rbp)
jmp 0x2e0a
movq -0x160(%rbp), %rax
movsbl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x20d0
jmp 0x2e1f
leaq 0x25c2(%rip), %rsi      # 0x53e8
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2e31
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x168(%rbp)
jmp 0x2e4a
movq -0x168(%rbp), %rsi
leaq 0x5400(%rip), %rdi      # 0x8258
callq 0x3280
movq %rax, -0x170(%rbp)
jmp 0x2e66
movq -0x170(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2f13
leaq 0x53bb(%rip), %rdi      # 0x8238
leaq 0x2475(%rip), %rsi      # 0x52f9
callq 0x21b0
jmp 0x2e8b
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x178(%rbp)
jmp 0x2ea4
movq -0x178(%rbp), %rax
movsbl (%rax), %esi
leaq 0x5383(%rip), %rdi      # 0x8238
callq 0x20d0
jmp 0x2ebc
leaq 0x5375(%rip), %rdi      # 0x8238
leaq 0x2522(%rip), %rsi      # 0x53ec
callq 0x21b0
jmp 0x2ed1
movq -0x108(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2350
movq %rax, -0x180(%rbp)
jmp 0x2eea
movq -0x180(%rbp), %rsi
leaq 0x5360(%rip), %rdi      # 0x8258
callq 0x3280
movq %rax, -0x188(%rbp)
jmp 0x2f06
movq -0x188(%rbp), %rax
movl $0x1, (%rax)
jmp 0x2f15
jmp 0x2f17
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x2b6f
cmpl $0x1, -0x6c(%rbp)
jle 0x2f6d
movl -0x6c(%rbp), %eax
decl %eax
movl %eax, -0x6c(%rbp)
leaq 0x23e8(%rip), %rsi      # 0x5322
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2f45
jmp 0x2f47
movl -0x6c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x6c(%rbp)
cmpl $0x0, %eax
je 0x2f6b
leaq 0x2396(%rip), %rsi      # 0x52f4
leaq -0x60(%rbp), %rdi
callq 0x21b0
jmp 0x2f69
jmp 0x2f47
jmp 0x2f6d
leaq -0x91(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x2310
movq -0x190(%rbp), %rdx
leaq 0x2463(%rip), %rsi      # 0x53f1
leaq -0x90(%rbp), %rdi
callq 0x3190
jmp 0x2f9c
leaq -0x91(%rbp), %rdi
callq 0x2200
leaq -0xf8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x33b0
jmp 0x2fbe
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x3360
jmp 0x2fda
leaq 0x5237(%rip), %rdx      # 0x8218
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x3360
jmp 0x2ff6
leaq 0x521b(%rip), %rdi      # 0x8218
leaq -0xb8(%rbp), %rsi
callq 0x2240
leaq -0xb8(%rbp), %rdi
callq 0x2368
leaq -0xd8(%rbp), %rdi
callq 0x2368
leaq -0xf8(%rbp), %rdi
callq 0x2368
leaq -0x90(%rbp), %rdi
callq 0x2368
leaq -0x60(%rbp), %rdi
callq 0x2368
leaq -0x28(%rbp), %rdi
callq 0x2368
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x2200
jmp 0x30ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x30ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x30a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x2368
leaq -0xf8(%rbp), %rdi
callq 0x2368
leaq -0x90(%rbp), %rdi
callq 0x2368
leaq -0x60(%rbp), %rdi
callq 0x2368
leaq -0x28(%rbp), %rdi
callq 0x2368
movq -0x38(%rbp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)