// File: CastellanZhang[P]lambdaFM/lambdafm_train.cpp
// Function: main
int main(int argc, char* argv[])
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    srand(time(NULL));
    trainer_option opt;
    try
    {
        opt.parse_option(argv_to_args(argc, argv));
    }
    catch(const invalid_argument& e)
    {
        cout << "invalid_argument:" << e.what() << endl;
        cout << train_help() << endl;
        return EXIT_FAILURE;
    }

    ftrl_trainer trainer(opt);

    if(opt.b_init) 
    {
        ifstream f_temp(opt.init_m_path.c_str());
        if(!trainer.loadModel(f_temp)) 
        {
            cout << "wrong model" << endl;
            return EXIT_FAILURE;
        }
        f_temp.close();
    }

    pc_frame frame;
    frame.init(trainer, opt.threads_num);
    frame.run();

    ofstream f_model(opt.model_path.c_str(), ofstream::out);
    trainer.outputModel(f_model);
    f_model.close();

    return 0;
}

// Assembly:
subq $0x6e8, %rsp            # imm = 0x6E8
movl $0x0, 0x6e4(%rsp)
movl %edi, 0x6e0(%rsp)
movq %rsi, 0x6d8(%rsp)
xorl %edi, %edi
movl %edi, 0x2c(%rsp)
callq 0x3110
movl 0x2c(%rsp), %edi
callq 0x3110
movl 0x2c(%rsp), %eax
movl %eax, %edi
callq 0x32a0
movl %eax, %edi
callq 0x32c0
leaq 0x610(%rsp), %rdi
callq 0x9860
movl 0x6e0(%rsp), %esi
movq 0x6d8(%rsp), %rdx
leaq 0x5f8(%rsp), %rdi
callq 0x7d20
jmp 0x7ea2
leaq 0x610(%rsp), %rdi
leaq 0x5f8(%rsp), %rsi
callq 0x99a0
jmp 0x7eb9
leaq 0x5f8(%rsp), %rdi
callq 0x8cf0
jmp 0x8047
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
jmp 0x7f02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
leaq 0x5f8(%rsp), %rdi
callq 0x8cf0
movl 0x5ec(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x82a9
movq 0x5f0(%rsp), %rdi
callq 0x30f0
movq %rax, 0x5e0(%rsp)
movq 0x1d086(%rip), %rdi     # 0x24fb8
leaq 0x135c8(%rip), %rsi     # 0x1b501
callq 0x32d0
movq %rax, 0x20(%rsp)
jmp 0x7f45
movq 0x5e0(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x32d0
movq %rax, 0x18(%rsp)
jmp 0x7f6a
movq 0x18(%rsp), %rdi
movq 0x1d012(%rip), %rsi     # 0x24f88
callq 0x3310
jmp 0x7f7d
leaq 0x5c0(%rsp), %rdi
callq 0x7ca0
jmp 0x7f8c
movq 0x1d025(%rip), %rdi     # 0x24fb8
leaq 0x5c0(%rsp), %rsi
callq 0x3270
movq %rax, 0x10(%rsp)
jmp 0x7fa7
movq 0x10(%rsp), %rdi
movq 0x1cfd5(%rip), %rsi     # 0x24f88
callq 0x3310
jmp 0x7fba
leaq 0x5c0(%rsp), %rdi
callq 0x3518
movl $0x1, 0x6e4(%rsp)
movl $0x1, 0x5bc(%rsp)
callq 0x3440
jmp 0x801d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
jmp 0x803b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
leaq 0x5c0(%rsp), %rdi
callq 0x3518
jmp 0x803b
jmp 0x828d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
jmp 0x82a9
callq 0x3440
jmp 0x8042
jmp 0x82a9
leaq 0x520(%rsp), %rdi
leaq 0x610(%rsp), %rsi
callq 0x43e0
jmp 0x805e
testb $0x1, 0x6a9(%rsp)
je 0x8175
leaq 0x630(%rsp), %rdi
callq 0x3100
movq %rax, %rsi
leaq 0x318(%rsp), %rdi
movl $0x8, %edx
callq 0x34d0
jmp 0x8090
leaq 0x520(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x6a20
movb %al, 0xf(%rsp)
jmp 0x80ab
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x813b
jmp 0x80b9
movq 0x1cef8(%rip), %rdi     # 0x24fb8
leaq 0x1344c(%rip), %rsi     # 0x1b513
callq 0x32d0
movq %rax, (%rsp)
jmp 0x80d2
movq (%rsp), %rdi
movq 0x1ceab(%rip), %rsi     # 0x24f88
callq 0x3310
jmp 0x80e4
movl $0x1, 0x6e4(%rsp)
movl $0x1, 0x5bc(%rsp)
jmp 0x8155
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
jmp 0x827e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x30a0
jmp 0x827e
leaq 0x318(%rsp), %rdi
callq 0x3090
jmp 0x814a
movl $0x0, 0x5bc(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x30a0
movl 0x5bc(%rsp), %eax
testl %eax, %eax
jne 0x826f
jmp 0x8173
jmp 0x8175
leaq 0x230(%rsp), %rdi
callq 0xabb0
jmp 0x8184
movl 0x6a0(%rsp), %edx
leaq 0x230(%rsp), %rdi
leaq 0x520(%rsp), %rsi
movl $0x1388, %ecx           # imm = 0x1388
movl $0x30d40, %r8d          # imm = 0x30D40
callq 0x14470
jmp 0x81ad
leaq 0x230(%rsp), %rdi
callq 0x14b80
jmp 0x81bc
leaq 0x610(%rsp), %rdi
callq 0x3100
movq %rax, %rsi
leaq 0x30(%rsp), %rdi
movl $0x10, %edx
callq 0x3330
jmp 0x81dd
leaq 0x520(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6a50
jmp 0x81f1
leaq 0x30(%rsp), %rdi
callq 0x33b0
jmp 0x81fd
movl $0x0, 0x6e4(%rsp)
movl $0x1, 0x5bc(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x33f0
leaq 0x230(%rsp), %rdi
callq 0xabf0
jmp 0x826f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
jmp 0x8260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5f0(%rsp)
movl %eax, 0x5ec(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x33f0
leaq 0x230(%rsp), %rdi
callq 0xabf0
jmp 0x827e
leaq 0x520(%rsp), %rdi
callq 0xac30
jmp 0x828d
leaq 0x520(%rsp), %rdi
callq 0xac30
jmp 0x82a9
leaq 0x610(%rsp), %rdi
callq 0xac70
movl 0x6e4(%rsp), %eax
addq $0x6e8, %rsp            # imm = 0x6E8
retq
leaq 0x610(%rsp), %rdi
callq 0xac70
movq 0x5f0(%rsp), %rdi
callq 0x3490
movq %rax, %rdi
callq 0xaba0
nopl (%rax,%rax)