// File: /workspace/github_cpp_makefile_star2_O1/pointwiseproduct[P]untyped_lambda/untyped_lambda.cpp
// Function: internal_data::lo_most_reduction(std::unique_ptr<internal_data::expr, std::default_delete<internal_data::expr>>&)
bool lo_most_reduction(std::unique_ptr<expr> &e){
        if(e->get_kind() == expr::kind::sequence){
            sequence *seq = static_cast<sequence*>(e.get());
            if(seq->vec.size() == 1){
                e.swap(seq->vec[0]);
                return true;
            }else{
                bool mod = false;
                seq->vec[0].reset(seq->vec[0]->replace(expr::variable_map(), assignment_table, mod));
                if(seq->vec[0]->get_kind() == expr::kind::lambda){
                    lambda &lam = *static_cast<lambda*>(seq->vec[0].get());
                    std::size_t s = (std::min)(lam.variable_seq.size(), seq->vec.size() - 1);
                    expr::variable_map map;
                    if(lam.variable_seq.size() <= s){
                        for(std::size_t i = 0; i < lam.variable_seq.size(); ++i){
                            map.insert(std::make_pair(lam.variable_seq[i].str, seq->vec[i + 1].get()));
                        }
                        {
                            expr *f = lam.seq->replace(map, assignment_table, mod);
                            seq->vec.erase(seq->vec.begin(), seq->vec.begin() + s + 1);
                            seq->vec.insert(seq->vec.begin(), std::move(std::unique_ptr<expr>(f)));
                        }
                        if(seq->vec.size() > 1){
                            return true;
                        }else{
                            std::unique_ptr<expr> f(std::move(*seq->vec.begin()));
                            *seq->vec.begin() = nullptr;
                            e.swap(f);
                            return true;
                        }
                    }else{
                        if(s > 0){
                            for(std::size_t i = 0; i < s; ++i){
                                map.insert(std::make_pair(lam.variable_seq[i].str, seq->vec[i + 1].get()));
                            }
                            std::unique_ptr<expr> f(lam.seq->replace(map, assignment_table, mod));
                            if(f->get_kind() == expr::kind::sequence){
                                lam.seq.swap(f);
                            }else{
                                lam.get_seq()->vec.clear();
                                lam.get_seq()->vec.push_back(std::move(f));
                            }
                            lam.variable_seq.erase(lam.variable_seq.begin(), lam.variable_seq.begin() + s);
                        }
                        e.swap(seq->vec[0]);
                        return true;
                    }
                }else{
                    if(seq->vec[0]->get_kind() == expr::kind::variable){
                        return lo_most_reduction(seq->vec[0]);
                    }else{
                        return lo_most_reduction(seq->vec[0]);
                    }
                }
            }
        }else if(e->get_kind() == expr::kind::lambda){
            return lo_most_reduction(static_cast<lambda*>(e.get())->seq);
        }else if(e->get_kind() == expr::kind::variable){
            variable *var = static_cast<variable*>(e.get());
            auto iter = assignment_table.find(var->str);
            if(iter != assignment_table.end()){
                e.reset(iter->second->copy());
                return true;
            }else{
                return false;
            }
        }

        // unreached point.
        return false;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
movq (%rdi), %rax
callq *(%rax)
movq (%rbx), %r12
cmpl $0x1, %eax
je 0x40ff
movq (%r12), %rax
movq %r12, %rdi
callq *(%rax)
movq (%rbx), %rdi
cmpl $0x2, %eax
jne 0x4120
addq $0x20, %rdi
jmp 0x40d5
movq 0x8(%r12), %r14
movq 0x10(%r12), %rax
subq %r14, %rax
cmpq $0x8, %rax
jne 0x4134
movq (%r14), %rax
movq %rax, (%rbx)
movq %r12, (%r14)
jmp 0x4559
movq (%rdi), %rax
callq *(%rax)
testl %eax, %eax
je 0x4300
xorl %ebp, %ebp
jmp 0x455c
leaq 0x7(%rsp), %rcx
movb $0x0, (%rcx)
movq (%r14), %rdi
leaq 0x58(%rsp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x8(%r13)
movaps %xmm0, 0x18(%r13)
movaps %xmm0, -0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq $0x0, 0x20(%r13)
movq (%rdi), %rax
leaq 0xb0e0(%rip), %rdx      # 0xf250
leaq 0x50(%rsp), %rsi
callq *0x10(%rax)
leaq 0x8(%r12), %r15
movq (%r14), %rdi
movq %rax, (%r14)
testq %rdi, %rdi
je 0x418e
movq (%rdi), %rax
callq *0x38(%rax)
leaq 0x50(%rsp), %rdi
callq 0x6a4a
movq (%r15), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
movq (%r15), %rcx
movq (%rcx), %rdi
cmpl $0x2, %eax
jne 0x434b
movq 0x10(%rdi), %rax
subq 0x8(%rdi), %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rax
movq 0x10(%r12), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
decq %rdx
cmpq %rax, %rdx
cmovaeq %rax, %rdx
movl $0x0, 0x58(%rsp)
xorl %eax, %eax
movq %rax, 0x60(%rsp)
movq %r13, 0x68(%rsp)
movq %r13, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movq 0x10(%rdi), %rax
subq 0x8(%rdi), %rax
leaq 0x8(%rdi), %rcx
movq %rcx, 0x48(%rsp)
sarq $0x3, %rax
imulq %rsi, %rax
cmpq %rdx, %rax
jbe 0x435f
testq %rdx, %rdx
je 0x4540
movq %rdi, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
movq %r15, 0x8(%rsp)
movl $0x2, %r13d
leaq 0x30(%rsp), %r14
xorl %ebp, %ebp
leaq 0x20(%rsp), %r12
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx,%rbp,8), %r15
movq %r14, 0x20(%rsp)
movq -0x8(%rax,%r13,8), %rsi
movq (%rax,%r13,8), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x6ac6
movq %r15, 0x40(%rsp)
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x8802
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x429b
callq 0x31f0
incq %rbp
addq $0x5, %r13
cmpq %rbp, 0x18(%rsp)
jne 0x424c
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
leaq 0xaf94(%rip), %rdx      # 0xf250
leaq 0x50(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq *0x10(%rax)
movq %rax, 0x20(%rsp)
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %r14
cmpl $0x1, %eax
jne 0x44c6
movq 0x20(%rsp), %rax
movq %rax, 0x20(%rcx)
movq %r14, 0x20(%rsp)
jmp 0x4516
movq (%rbx), %rsi
addq $0x8, %rsi
leaq 0xaf42(%rip), %rdi      # 0xf250
callq 0x8778
leaq 0xaf3e(%rip), %rcx      # 0xf258
cmpq %rcx, %rax
setne %bpl
je 0x455c
movq 0x40(%rax), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq (%rbx), %rdi
movq %rax, (%rbx)
testq %rdi, %rdi
je 0x455c
movq (%rdi), %rax
callq *0x38(%rax)
jmp 0x455c
movq (%rdi), %rax
callq *(%rax)
movq (%r15), %rdi
callq 0x40c4
movl %eax, %ebp
jmp 0x455c
movq %rdx, 0x18(%rsp)
movq %r15, 0x8(%rsp)
movq 0x10(%rdi), %rax
cmpq 0x8(%rdi), %rax
je 0x4418
movl $0x2, %r13d
xorl %r14d, %r14d
leaq 0x20(%rsp), %rbp
movq %rdi, 0x10(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx,%r14,8), %r15
leaq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq -0x8(%rax,%r13,8), %rsi
movq (%rax,%r13,8), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x6ac6
movq %r15, 0x40(%rsp)
leaq 0x50(%rsp), %rdi
movq %rbp, %r15
movq %rbp, %rsi
callq 0x8802
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x43e6
callq 0x31f0
incq %r14
movq 0x10(%rsp), %rdi
movq 0x10(%rdi), %rax
subq 0x8(%rdi), %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
addq $0x5, %r13
cmpq %rax, %r14
movq %r15, %rbp
jb 0x438a
movq 0x20(%rdi), %rdi
movq (%rdi), %rax
leaq 0xae2a(%rip), %rdx      # 0xf250
leaq 0x50(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq *0x10(%rax)
movq %rax, %r15
movq 0x8(%rsp), %r13
movq (%r13), %rsi
movq 0x18(%rsp), %rax
leaq (%rsi,%rax,8), %rdx
addq $0x8, %rdx
movq %r13, %rdi
callq 0x89e0
movq (%r13), %rsi
leaq 0x20(%rsp), %rdx
movq %r15, (%rdx)
movq %r13, %rdi
callq 0x8a84
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4478
movq (%rdi), %rax
callq *0x38(%rax)
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
ja 0x454f
movq (%rax), %r14
xorl %ecx, %ecx
movq %rcx, (%rax)
movq (%r13), %rax
movq (%rax), %rdi
movq %rcx, (%rax)
testq %rdi, %rdi
je 0x44ac
movq (%rdi), %rax
callq *0x38(%rax)
movq (%rbx), %rdi
movq %r14, (%rbx)
testq %rdi, %rdi
je 0x454f
movq (%rdi), %rax
callq *0x38(%rax)
jmp 0x454f
movq 0x8(%r14), %r12
movq 0x10(%r14), %r13
cmpq %r12, %r13
je 0x4504
movq %r12, %rbp
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x44e5
movq (%rdi), %rax
callq *0x38(%rax)
movq $0x0, (%rbp)
addq $0x8, %rbp
cmpq %r13, %rbp
jne 0x44d6
movq %r12, 0x10(%r14)
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %rdi
addq $0x8, %rdi
leaq 0x20(%rsp), %rsi
callq 0x83da
movq 0x48(%rsp), %rdi
movq (%rdi), %rsi
movq 0x18(%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%rsi,%rax,8), %rdx
callq 0x8b80
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4540
movq (%rdi), %rax
callq *0x38(%rax)
movq (%r15), %rax
movq (%rbx), %rcx
movq (%rax), %rdx
movq %rdx, (%rbx)
movq %rcx, (%rax)
leaq 0x50(%rsp), %rdi
callq 0x6a4a
movb $0x1, %bpl
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4574
jmp 0x45af
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4587
movq (%rdi), %rax
callq *0x38(%rax)
movq $0x0, 0x20(%rsp)
jmp 0x45cb
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x45cb
movq (%rdi), %rax
callq *0x38(%rax)
jmp 0x45cb
jmp 0x45af
jmp 0x45af
jmp 0x45af
jmp 0x45af
movq %rax, %rbx
jmp 0x45cb
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x45cb
callq 0x31f0
leaq 0x50(%rsp), %rdi
callq 0x6a4a
movq %rbx, %rdi
callq 0x3360
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
jne 0x45c6
jmp 0x45cb