// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
leaq 0x1b85(%rip), %rsi      # 0x42f7
leaq -0x88(%rbp), %r14
leaq -0x48(%rbp), %rdx
movq %r14, %rdi
callq 0x2b4a
movq (%rbx), %rax
movsbl (%rax), %esi
movq %r14, %rdi
callq 0x2100
leaq 0x1b65(%rip), %rsi      # 0x42ff
leaq -0x88(%rbp), %rdi
callq 0x2270
leaq 0x1b5d(%rip), %rsi      # 0x430a
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2b4a
pushq $0x1
popq %r12
pushq $0x3
popq %r13
leaq -0x48(%rbp), %r15
movl %r12d, %r14d
cmpq %r13, 0x8(%rbx)
jbe 0x2967
movq (%rbx), %rax
movzbl (%rax,%r13), %eax
cmpl $0x5e, %eax
je 0x295f
cmpl $0x7c, %eax
jne 0x2824
movq %r15, %rdi
leaq 0x1b2f(%rip), %rsi      # 0x4322
callq 0x2270
cmpl $0x2, %r12d
jl 0x280c
movq %r15, %rdi
pushq $0x7d
popq %rsi
callq 0x2100
decl %r12d
movq %r15, %rdi
leaq 0x1b68(%rip), %rsi      # 0x437e
callq 0x2270
pushq $0x1
popq %r14
jmp 0x295f
movsbl %al, %edi
callq 0x2ff8
testl %eax, %eax
je 0x28a0
testl %r14d, %r14d
je 0x292e
movq %r15, %rdi
leaq 0x1b8a(%rip), %rsi      # 0x43cd
callq 0x2270
movq %r15, %rdi
leaq 0x1b90(%rip), %rsi      # 0x43e2
callq 0x2270
movq (%rbx), %rax
movsbl (%rax,%r13), %esi
movq %r15, %rdi
callq 0x2100
movq %r15, %rdi
leaq 0x1b68(%rip), %rsi      # 0x43d9
callq 0x2270
movq (%rbx), %rax
movsbl (%rax,%r13), %esi
movq %r15, %rdi
callq 0x2100
movq %r15, %rdi
leaq 0x1b54(%rip), %rsi      # 0x43e4
callq 0x2270
incl %r12d
xorl %r14d, %r14d
jmp 0x295f
movq (%rbx), %rax
movsbl (%rax,%r13), %esi
movq %r15, %rdi
callq 0x2100
movq %r15, %rdi
leaq 0x1b2e(%rip), %rsi      # 0x43e8
callq 0x2270
movq (%rbx), %rsi
addq %r13, %rsi
leaq 0x3924(%rip), %rdi      # 0x61f0
callq 0x2b90
cmpl $0x0, (%rax)
jne 0x295f
leaq 0x38ef(%rip), %rdi      # 0x61d0
leaq 0x1a11(%rip), %rsi      # 0x42f9
callq 0x2270
movq (%rbx), %rax
movsbl (%rax,%r13), %esi
leaq 0x38d4(%rip), %rdi      # 0x61d0
callq 0x2100
leaq 0x38c8(%rip), %rdi      # 0x61d0
leaq 0x1add(%rip), %rsi      # 0x43ec
callq 0x2270
movq (%rbx), %rsi
addq %r13, %rsi
leaq 0x38cf(%rip), %rdi      # 0x61f0
callq 0x2b90
movl $0x1, (%rax)
jmp 0x295f
movq %r15, %rdi
leaq 0x1aa4(%rip), %rsi      # 0x43dc
callq 0x2270
movq (%rbx), %rax
movsbl (%rax,%r13), %esi
movq %r15, %rdi
callq 0x2100
xorl %r14d, %r14d
movq %r15, %rdi
leaq 0x1a8a(%rip), %rsi      # 0x43e4
callq 0x2270
incq %r13
jmp 0x27c9
cmpl $0x1, %r12d
jle 0x299a
leaq 0x19ae(%rip), %rsi      # 0x4322
leaq -0x48(%rbp), %rdi
callq 0x2270
leaq 0x1970(%rip), %rbx      # 0x42f4
leaq -0x48(%rbp), %r14
decl %r12d
je 0x299a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2270
jmp 0x2988
leaq 0x1a50(%rip), %rsi      # 0x43f1
leaq -0x68(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
callq 0x2b4a
leaq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x2c0a
leaq -0xc8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x2be1
leaq 0x37ca(%rip), %rdx      # 0x61b0
leaq -0xe8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x2be1
leaq 0x37b0(%rip), %rdi      # 0x61b0
leaq -0xe8(%rbp), %rbx
movq %rbx, %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2298
leaq -0xc8(%rbp), %rdi
callq 0x2298
leaq -0xa8(%rbp), %rdi
callq 0x2298
leaq -0x68(%rbp), %rdi
callq 0x2298
leaq -0x48(%rbp), %rdi
callq 0x2298
leaq -0x88(%rbp), %rdi
callq 0x2298
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a9c
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x2298
jmp 0x2a75
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x2298
jmp 0x2a86
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2298
jmp 0x2a9f
jmp 0x2a9c
jmp 0x2a95
movq %rax, %rbx
jmp 0x2aa8
jmp 0x2a9c
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2298
leaq -0x88(%rbp), %rdi
callq 0x2298
movq %rbx, %rdi
callq 0x2250