// File: /workspace/github_cpp_makefile_star2_O2/Falldog[P]dcinja/src/dcinja.cpp
// Function: execute(cxxopts::ParseResult&)
int execute(cxxopts::ParseResult& result) {
    json data;
    std::string content;

    // 0. change current working dir
    if (result.count("cwd")) {
        auto cwd = result["cwd"].as<std::string>();
        if (chdir(cwd.c_str()) != 0) {
            std::cout << "cwd fail, please make sure your dir path exists" << std::endl;
            exit(1);
        }
    }

    // 1. prepare json data & extra envs
    //    priority: envs(-e) >> json(-j) >> json-file(-f)
    if (result.count("json-file")) {
        auto& json_files = result["json-file"].as<std::vector<std::string>>();
        for (size_t i=0 ; i<json_files.size() ; ++i) {
            std::string json_content;
            read_source(json_files[i], json_content);
            data.merge_patch(
                json::parse(json_content.begin(), json_content.end())
            );
        }
    }
    if (result.count("json")) {
        auto& jsons = result["json"].as<std::vector<std::string>>();
        for (size_t i=0 ; i<jsons.size() ; ++i) {
            data.merge_patch(
                json::parse(jsons[i])
            );
        }
    }
    if (result.count("envs")) {
        auto& envs = result["envs"].as<std::vector<std::string>>();
        for (size_t i=0 ; i<envs.size() ; ++i) {
            auto idx = envs[i].find_first_of("=");
            if (idx == std::string::npos) {
                char * _env = std::getenv(envs[i].c_str());
                if (_env) {
                    std::string value = _env;
                    data[envs[i]] = value;
                }
            }
            else {
                std::string key = envs[i].substr(0, idx);
                std::string value = envs[i].substr(idx+1);
                data[key] = value;
            }
        }
    }
    if (result.count("force-system-envs")) {
        for (json::iterator it = data.begin(); it != data.end(); ++it) {
            char * _env = std::getenv(it.key().c_str());
            if (_env) {
                std::string value = _env;
                data[it.key()] = value;
            }
        }
    }
    if (result.count("verbose")) {
        std::cerr << "<<< JSON content: >>>" << std::endl;
        std::cerr << data.dump(4) << std::endl;
    }

    // 2. read source content
    if (result.count("src")) {
        auto src = result["src"].as<std::string>();
        read_source(src, content);
    } else {
        read_source("", content);
    }

    // 3. convert content -> template
    std::pair<std::string, std::string> x_delims = parse_delimiters(result["expression"].as<std::string>());
    std::pair<std::string, std::string> t_delims = parse_delimiters(result["statement"].as<std::string>());
    std::pair<std::string, std::string> c_delims = parse_delimiters(result["comment"].as<std::string>());

    inja::Environment env;
    env.set_expression(x_delims.first, x_delims.second);
    env.set_statement(t_delims.first, t_delims.second);
    env.set_comment(c_delims.first, c_delims.second);

    inja::Template tmpl = env.parse(content);

    // 4. render output from template
    if (result.count("dest")) {
        auto dest = result["dest"].as<std::string>();
        std::ofstream ofs;
        ofs.open(dest, std::ofstream::out | std::ofstream::trunc);
        env.render_to(ofs, tmpl, data);
        ofs.close();
    } else {
        env.render_to(std::cout, tmpl, data);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x698, %rsp            # imm = 0x698
movq %rdi, %r14
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0xc9aa
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x3b193(%rip), %rsi     # 0x464f3
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xb40d
leaq 0x3b152(%rip), %rsi     # 0x464f3
leaq 0x3b8(%rsp), %rdi
leaq 0x370(%rsp), %rdx
callq 0xc0a4
leaq 0x3b8(%rsp), %rsi
movq %r14, %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xca3c
leaq 0x88(%rsp), %rdi
movq %rax, %rsi
callq 0x95f0
leaq 0x3b8(%rsp), %rdi
callq 0x9898
movq 0x88(%rsp), %rdi
callq 0x9660
testl %eax, %eax
jne 0xbdc2
leaq 0x88(%rsp), %rdi
callq 0x9898
leaq 0x3b229(%rip), %rsi     # 0x4663d
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %r14, 0x10(%rsp)
movq %r14, %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xb583
leaq 0x3b1df(%rip), %rsi     # 0x4663d
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xcac2
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
xorl %ebp, %ebp
leaq 0x678(%rsp), %r15
leaq 0x3b8(%rsp), %r12
leaq 0x300(%rsp), %r13
xorl %r14d, %r14d
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x5, %rax
cmpq %rax, %r14
jae 0xb583
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
andq $0x0, 0x90(%rsp)
movb $0x0, 0x98(%rsp)
movq (%rbx), %rsi
addq %rbp, %rsi
movq %r15, %rdi
callq 0x95f0
movq %r15, %rdi
leaq 0x88(%rsp), %rsi
callq 0x9afc
movq %r15, %rdi
callq 0x9898
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq %rsi, %rdx
xorps %xmm0, %xmm0
movaps %xmm0, 0x300(%rsp)
movaps %xmm0, 0x310(%rsp)
movq %r12, %rdi
movq %r13, %rcx
pushq $0x1
popq %r8
xorl %r9d, %r9d
callq 0xcc3a
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0xcb48
movq %r12, %rdi
callq 0xccf0
movq %r13, %rdi
callq 0x33e76
leaq 0x88(%rsp), %rdi
callq 0x9898
incq %r14
addq $0x20, %rbp
jmp 0xb4ba
leaq 0x3b07f(%rip), %rsi     # 0x46609
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xb683
leaq 0x3b038(%rip), %rsi     # 0x46609
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xcac2
movq %rax, %rbx
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x9898
xorl %r13d, %r13d
leaq 0x2e0(%rsp), %r15
leaq 0x18(%rsp), %r12
xorl %ebp, %ebp
movq (%rbx), %rsi
movq 0x8(%rbx), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rax, %rbp
jae 0xb683
addq %r13, %rsi
xorps %xmm0, %xmm0
movaps %xmm0, 0x2e0(%rsp)
movaps %xmm0, 0x2f0(%rsp)
movq %r14, %rdi
movq %r15, %rdx
pushq $0x1
popq %rcx
xorl %r8d, %r8d
callq 0xcd0a
movq %r12, %rdi
movq %r14, %rsi
callq 0xcb48
movq %r14, %rdi
callq 0xccf0
movq %r15, %rdi
callq 0x33e76
incq %rbp
addq $0x20, %r13
jmp 0xb625
leaq 0x3aec9(%rip), %rsi     # 0x46553
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xb81f
leaq 0x3ae82(%rip), %rsi     # 0x46553
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xcac2
movq %rax, %r14
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x9898
xorl %r12d, %r12d
leaq 0x3b8(%rsp), %r13
xorl %ebp, %ebp
movq (%r14), %rdi
movq 0x8(%r14), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq %rax, %rbp
jae 0xb81f
addq %r12, %rdi
leaq 0x3b209(%rip), %rsi     # 0x4694a
xorl %edx, %edx
callq 0x9210
cmpq $-0x1, %rax
je 0xb7b7
movq %rax, %rbx
movq (%r14), %rsi
addq %r12, %rsi
movq %r15, %rdi
xorl %edx, %edx
movq %rax, %rcx
callq 0x9430
movq (%r14), %rsi
addq %r12, %rsi
incq %rbx
movq %r13, %rdi
movq %rbx, %rdx
pushq $-0x1
popq %rcx
callq 0x9430
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0xcdca
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0xcde4
movq %rax, %rdi
leaq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0xceca
movq %rbx, %rdi
callq 0xccf0
movq %r13, %rdi
callq 0x9898
jmp 0xb80b
movq (%r14), %rax
movq (%rax,%r12), %rdi
callq 0x94f0
testq %rax, %rax
je 0xb813
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0xc0a4
leaq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0xcdca
movq (%r14), %rsi
addq %r12, %rsi
leaq 0x18(%rsp), %rdi
callq 0xcde4
movq %rax, %rdi
leaq 0x58(%rsp), %rbx
movq %rbx, %rsi
callq 0xceca
movq %rbx, %rdi
callq 0xccf0
movq %r15, %rdi
callq 0x9898
incq %rbp
addq $0x20, %r12
jmp 0xb720
leaq 0x3ada1(%rip), %rsi     # 0x465c7
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xb919
leaq 0x88(%rsp), %rbx
leaq 0x18(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xcf0a
leaq 0x3b8(%rsp), %r15
leaq 0x370(%rsp), %r12
leaq 0x360(%rsp), %r13
movq %r15, %rdi
movq %r14, %rsi
callq 0xcf3a
movq %rbx, %rdi
movq %r15, %rsi
callq 0xcf30
testb %al, %al
je 0xb919
movq %rbx, %rdi
callq 0xcf60
movq (%rax), %rdi
callq 0x94f0
testq %rax, %rax
je 0xb90f
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0xc0a4
movq %r13, %rdi
movq %r15, %rsi
callq 0xcdca
movq %rbx, %rdi
callq 0xcf60
movq %r14, %rdi
movq %rax, %rsi
callq 0xcde4
movq %rax, %rdi
movq %r13, %rsi
callq 0xceca
movq %r13, %rdi
callq 0xccf0
movq %r15, %rdi
callq 0x9898
movq %rbx, %rdi
callq 0xd01a
jmp 0xb899
leaq 0x3ae04(%rip), %rsi     # 0x46724
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %rbp, %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xb9bc
movq 0x6667f(%rip), %rdi     # 0x71fe0
leaq 0x3ae19(%rip), %rsi     # 0x46781
callq 0x93c0
movq %rax, %rdi
callq 0x91f0
leaq 0x88(%rsp), %rdi
leaq 0x18(%rsp), %rsi
pushq $0x4
popq %rdx
pushq $0x20
popq %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xd070
movq 0x66646(%rip), %rdi     # 0x71fe0
leaq 0x88(%rsp), %rsi
callq 0x9390
movq %rax, %rdi
callq 0x91f0
leaq 0x88(%rsp), %rdi
callq 0x9898
leaq 0x3ab51(%rip), %rsi     # 0x46514
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %rbp, %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xba90
leaq 0x3ab0c(%rip), %rsi     # 0x46514
leaq 0x3b8(%rsp), %rdi
leaq 0x370(%rsp), %rdx
callq 0xc0a4
leaq 0x3b8(%rsp), %rsi
movq %rbp, %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xca3c
leaq 0x88(%rsp), %rdi
movq %rax, %rsi
callq 0x95f0
leaq 0x3b8(%rsp), %rdi
callq 0x9898
leaq 0x340(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x95f0
leaq 0x340(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x9afc
leaq 0x340(%rsp), %rdi
callq 0x9898
leaq 0x88(%rsp), %rdi
jmp 0xbac6
leaq 0x3ae84(%rip), %rsi     # 0x4691b
leaq 0x320(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0xc0a4
leaq 0x320(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x9afc
leaq 0x320(%rsp), %rdi
callq 0x9898
leaq 0x3ec29(%rip), %rsi     # 0x4a6fb
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %rbp, %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xca3c
leaq 0x638(%rsp), %rdi
movq %rax, %rsi
callq 0x9c70
leaq 0x88(%rsp), %rdi
callq 0x9898
leaq 0x3ab99(%rip), %rsi     # 0x466bc
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %rbp, %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xca3c
leaq 0x5f8(%rsp), %rdi
movq %rax, %rsi
callq 0x9c70
leaq 0x88(%rsp), %rdi
callq 0x9898
leaq 0x3ab7e(%rip), %rsi     # 0x466f2
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rdx
callq 0xc0a4
leaq 0x88(%rsp), %rsi
movq %rbp, %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xca3c
leaq 0x5b8(%rsp), %rdi
movq %rax, %rsi
callq 0x9c70
leaq 0x88(%rsp), %rdi
callq 0x9898
leaq 0x88(%rsp), %rdi
callq 0xd16a
leaq 0x658(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0x638(%rsp), %rsi
callq 0xd1c0
leaq 0x618(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0x5f8(%rsp), %rsi
callq 0xd26c
leaq 0x5d8(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0x5b8(%rsp), %rsi
callq 0xd33e
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rdx
leaq 0x370(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xd378
leaq 0x3a8ec(%rip), %rsi     # 0x46534
leaq 0x3b8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0xc0a4
leaq 0x3b8(%rsp), %rsi
movq %rbp, %rdi
callq 0xc708
movq %rax, %rbx
leaq 0x3b8(%rsp), %rdi
callq 0x9898
testq %rbx, %rbx
je 0xbd38
leaq 0x3a8aa(%rip), %rsi     # 0x46534
leaq 0x3b8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xc0a4
leaq 0x3b8(%rsp), %rsi
movq %rbp, %rdi
callq 0xc9c6
movq %rax, %rdi
callq 0xca3c
leaq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x95f0
leaq 0x3b8(%rsp), %rdi
callq 0x9898
leaq 0x3b8(%rsp), %rdi
callq 0x9750
leaq 0x3b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x30
popq %rdx
callq 0x91e0
leaq 0x88(%rsp), %rdi
leaq 0x3b8(%rsp), %rsi
leaq 0x370(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0xd3f4
leaq 0x3b8(%rsp), %rdi
callq 0x9620
leaq 0x3b8(%rsp), %rdi
callq 0x9670
leaq 0x68(%rsp), %rdi
callq 0x9898
jmp 0xbd59
movq 0x66241(%rip), %rsi     # 0x71f80
leaq 0x88(%rsp), %rdi
leaq 0x370(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0xd3f4
leaq 0x370(%rsp), %rdi
callq 0xd46c
leaq 0x88(%rsp), %rdi
callq 0xd482
leaq 0x5b8(%rsp), %rdi
callq 0xd4ba
leaq 0x5f8(%rsp), %rdi
callq 0xd4ba
leaq 0x638(%rsp), %rdi
callq 0xd4ba
leaq 0x28(%rsp), %rdi
callq 0x9898
leaq 0x18(%rsp), %rdi
callq 0xccf0
xorl %eax, %eax
addq $0x698, %rsp            # imm = 0x698
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x661b7(%rip), %rdi     # 0x71f80
leaq 0x3a981(%rip), %rsi     # 0x46751
callq 0x93c0
movq %rax, %rdi
callq 0x91f0
pushq $0x1
popq %rdi
callq 0x94e0
jmp 0xbe43
movq %rax, %rbx
leaq 0x320(%rsp), %rdi
jmp 0xc03c
jmp 0xc01f
jmp 0xbfdc
movq %rax, %rbx
jmp 0xbedc
jmp 0xbe43
movq %rax, %rbx
leaq 0x340(%rsp), %rdi
jmp 0xbfec
jmp 0xbfdc
jmp 0xc01f
jmp 0xc01f
jmp 0xc01f
jmp 0xc01f
jmp 0xc01f
jmp 0xc01f
jmp 0xbee3
movq %rax, %rbx
jmp 0xbef3
jmp 0xbf0c
movq %rax, %rbx
jmp 0xbf1c
movq %rax, %rbx
jmp 0xbf29
movq %rax, %rbx
jmp 0xbf36
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xc01f
jmp 0xbfdc
jmp 0xbfdc
jmp 0xbfdc
movq %rax, %rbx
leaq 0x3b8(%rsp), %rdi
callq 0x9670
leaq 0x68(%rsp), %rdi
jmp 0xbeee
movq %rax, %rbx
leaq 0x3b8(%rsp), %rdi
callq 0x9898
leaq 0x370(%rsp), %rdi
callq 0xd46c
jmp 0xbf0f
jmp 0xbf8c
jmp 0xbf8c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xd482
leaq 0x5b8(%rsp), %rdi
callq 0xd4ba
leaq 0x5f8(%rsp), %rdi
callq 0xd4ba
leaq 0x638(%rsp), %rdi
callq 0xd4ba
jmp 0xc041
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
jmp 0xbf29
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x9898
jmp 0xbf36
jmp 0xbfdc
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0xccf0
jmp 0xc015
jmp 0xbfdc
jmp 0xc01f
jmp 0xc01f
movq %rax, %rbx
jmp 0xc034
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xccf0
jmp 0xbfaa
jmp 0xc01f
jmp 0xbfdc
movq %rax, %rbx
leaq 0x3b8(%rsp), %rdi
jmp 0xbfec
jmp 0xc01f
jmp 0xc01f
movq %rax, %rbx
jmp 0xbfcd
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xccf0
leaq 0x2e0(%rsp), %rdi
callq 0x33e76
jmp 0xc041
movq %rax, %rbx
jmp 0xc015
movq %rax, %rbx
leaq 0x678(%rsp), %rdi
callq 0x9898
jmp 0xc015
movq %rax, %rbx
jmp 0xc008
movq %rax, %rbx
leaq 0x3b8(%rsp), %rdi
callq 0xccf0
leaq 0x300(%rsp), %rdi
callq 0x33e76
leaq 0x88(%rsp), %rdi
jmp 0xc03c
movq %rax, %rbx
jmp 0xc041
movq %rax, %rbx
leaq 0x360(%rsp), %rdi
callq 0xccf0
leaq 0x3b8(%rsp), %rdi
callq 0x9898
leaq 0x28(%rsp), %rdi
callq 0x9898
leaq 0x18(%rsp), %rdi
callq 0xccf0
movq %rbx, %rdi
callq 0x97a0