// File: /workspace/github_cpp_makefile_star2_O2/demon386[P]git-store/main.cpp
// Function: process_write_cmd(boost::program_options::variables_map const&)
void process_write_cmd(const po::variables_map& options) {
    if (!options.count("subargs")) {
        return;
    }
    auto subargs = options["subargs"].as<std::vector<std::string>>();
    if (subargs.size() == 0) {
        return;
    }
    auto subargs_str = boost::algorithm::join(subargs, " ");
    int ret = 0;
    ret = subprocess::run_cmd("git reset --mixed");
    if (ret != 0) {
        return;
    }

    if (subargs.size() == 1 && !fs::is_directory(subargs_str)
            && !options.count("tree")) {
        std::cout << "hashing blob object" << std::endl;
        ret = subprocess::run_cmd("git hash-object -w " + subargs_str);
    } else {
        std::cout << "hashing tree" << std::endl;
        ret = subprocess::run_cmd("git add " + subargs_str);
        if (ret != 0) {
            return;
        }
        ret = subprocess::run_cmd("git write-tree && git reset --mixed");
    }
    if (ret == 0) {
        if (options.count("delete")) {
            // @todo: check file is inside git repo.
            // to avoid accidently delete files under / or things like that.
            subprocess::run_cmd("rm -rf " + subargs_str);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r14
leaq 0x8e7d(%rip), %rsi      # 0x30f2b
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0xc1b0
leaq 0x10(%r14), %rbx
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x2101c
movq %rax, %r15
leaq -0x60(%rbp), %rdi
callq 0xc9a0
testq %r15, %r15
je 0x28319
leaq 0x8e44(%rip), %rsi      # 0x30f2b
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0xc1b0
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
callq 0x20cf2
movq %rax, %rdi
callq 0x2ad4b
leaq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x10d3a
leaq -0x60(%rbp), %rdi
callq 0xc9a0
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
je 0x28310
leaq 0x5357(%rip), %rdx      # 0x2d489
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x28da0
leaq 0x8f26(%rip), %rsi      # 0x3106c
leaq -0x40(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xc1b0
leaq -0x40(%rbp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x27f49
movl %eax, %r15d
movq %r14, %rdi
callq 0xc9a0
testl %r15d, %r15d
jne 0x28307
movq -0x70(%rbp), %rax
subq -0x78(%rbp), %rax
cmpq $0x20, %rax
jne 0x281ef
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xc660
leaq -0x40(%rbp), %rdi
callq 0x24c99
testb %al, %al
je 0x281ac
leaq -0x40(%rbp), %rdi
callq 0xc9a0
jmp 0x281ef
leaq 0x8e99(%rip), %rsi      # 0x3104c
leaq -0x98(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0xc1b0
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0x2101c
movq %rax, %r14
leaq -0x98(%rbp), %rdi
callq 0xc9a0
leaq -0x40(%rbp), %rdi
callq 0xc9a0
testq %r14, %r14
je 0x2825a
movq 0x20dc2(%rip), %rdi     # 0x48fb8
leaq 0x8e47(%rip), %rsi      # 0x31044
callq 0xc4c0
movq %rax, %rdi
callq 0xc230
leaq 0x8e40(%rip), %rsi      # 0x31051
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x15d84
leaq -0x40(%rbp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x27f49
movl %eax, %r15d
movq %r14, %rdi
callq 0xc9a0
testl %r15d, %r15d
jne 0x28307
leaq 0x8e12(%rip), %rsi      # 0x3105a
leaq -0x40(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xc1b0
jmp 0x28289
movq 0x20d57(%rip), %rdi     # 0x48fb8
leaq 0x8db4(%rip), %rsi      # 0x3101c
callq 0xc4c0
movq %rax, %rdi
callq 0xc230
leaq 0x8db4(%rip), %rsi      # 0x31030
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x15d84
leaq -0x40(%rbp), %r15
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x27f49
movl %eax, %r14d
movq %r15, %rdi
callq 0xc9a0
testl %r14d, %r14d
jne 0x28307
leaq 0x8dcf(%rip), %rsi      # 0x3107e
leaq -0x40(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xc1b0
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x2101c
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0xc9a0
testq %rbx, %rbx
je 0x28307
leaq 0x8da2(%rip), %rsi      # 0x31085
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x15d84
leaq -0x40(%rbp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x27f49
movq %rbx, %rdi
callq 0xc9a0
leaq -0x60(%rbp), %rdi
callq 0xc9a0
leaq -0x78(%rbp), %rdi
callq 0xe840
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x28358
jmp 0x28358
jmp 0x28344
jmp 0x28358
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0xc9a0
jmp 0x28347
jmp 0x28344
jmp 0x28358
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0xc9a0
jmp 0x2835b
jmp 0x28358
jmp 0x28358
jmp 0x28358
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0xc9a0
jmp 0x28369
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0xe840
jmp 0x28389
jmp 0x28378
jmp 0x2837d
movq %rax, %rbx
jmp 0x28389
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0xc9a0
movq %rbx, %rdi
callq 0xc850