// File: fei3189[P]PLSI/main.cpp
// Function: main
int main(int argc, char **argv) {
    if (argc < 4) {
        cerr << "usage: ./plsa train stopwords num_topics" << endl;
        exit(-1);
    }
    vector<string> docs, w_stop;
    string line;

    ifstream fin;
    fin.open(argv[1], ios_base::in);
    if (!fin) {
        cerr << "Train file: " << argv[1] << " does not exist" << endl;
        exit(-2);
    }
    getline(fin, line); // Ignore the first line
    for (; getline(fin, line); ) {
        docs.push_back(line);
    }
    fin.close();
    
    fin.open(argv[2], ios_base::in);
    if (!fin) {
        cerr << "Stop words file: " << argv[2] << " does not exist" << endl;
        exit(-3);
    }
    for (; getline(fin, line); ) {
        w_stop.push_back(line);
    }
    fin.close();

    PLSI plsa = PLSI::train(docs, atoi(argv[3]), w_stop);
    plsa.output();
    return 0;
}

// Assembly:
subq $0x3a8, %rsp            # imm = 0x3A8
movl $0x0, 0x3a4(%rsp)
movl %edi, 0x3a0(%rsp)
movq %rsi, 0x398(%rsp)
cmpl $0x4, 0x3a0(%rsp)
jge 0x24c7
movq 0x13b4e(%rip), %rdi     # 0x15ff0
leaq 0xcb7b(%rip), %rsi      # 0xf024
callq 0x21d0
movq %rax, %rdi
movq 0x13b08(%rip), %rsi     # 0x15fc0
callq 0x2210
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
leaq 0x380(%rsp), %rdi
callq 0x2880
leaq 0x368(%rsp), %rdi
callq 0x2880
leaq 0x348(%rsp), %rdi
callq 0x2260
leaq 0x140(%rsp), %rdi
callq 0x2220
jmp 0x24fd
movq 0x398(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x140(%rsp), %rdi
movl $0x8, %edx
callq 0x2140
jmp 0x251d
movq 0x140(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x140(%rsp,%rax), %rdi
callq 0x20e0
movb %al, 0x57(%rsp)
jmp 0x253c
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0x2549
jmp 0x25e7
movq 0x13aa0(%rip), %rdi     # 0x15ff0
leaq 0xcaf6(%rip), %rsi      # 0xf04d
callq 0x21d0
movq %rax, 0x48(%rsp)
jmp 0x2563
movq 0x48(%rsp), %rdi
movq 0x398(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x21d0
movq %rax, 0x40(%rsp)
jmp 0x2580
movq 0x40(%rsp), %rdi
leaq 0xcace(%rip), %rsi      # 0xf05a
callq 0x21d0
movq %rax, 0x38(%rsp)
jmp 0x2598
movq 0x38(%rsp), %rdi
movq 0x13a1c(%rip), %rsi     # 0x15fc0
callq 0x2210
jmp 0x25ab
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
callq 0x2230
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0x2845
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0x2838
leaq 0x140(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x2060
jmp 0x25fe
jmp 0x2600
leaq 0x140(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x2060
movq %rax, 0x30(%rsp)
jmp 0x261c
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, 0x2f(%rsp)
jmp 0x2636
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0x2640
jmp 0x2659
leaq 0x380(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x2890
jmp 0x2657
jmp 0x2600
leaq 0x140(%rsp), %rdi
callq 0x2070
jmp 0x2668
movq 0x398(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x140(%rsp), %rdi
movl $0x8, %edx
callq 0x2140
jmp 0x2688
movq 0x140(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x140(%rsp,%rax), %rdi
callq 0x20e0
movb %al, 0x2e(%rsp)
jmp 0x26a7
movb 0x2e(%rsp), %al
testb $0x1, %al
jne 0x26b1
jmp 0x271d
movq 0x13938(%rip), %rdi     # 0x15ff0
leaq 0xc9ab(%rip), %rsi      # 0xf06a
callq 0x21d0
movq %rax, 0x20(%rsp)
jmp 0x26cb
movq 0x20(%rsp), %rdi
movq 0x398(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x21d0
movq %rax, 0x18(%rsp)
jmp 0x26e8
movq 0x18(%rsp), %rdi
leaq 0xc966(%rip), %rsi      # 0xf05a
callq 0x21d0
movq %rax, 0x10(%rsp)
jmp 0x2700
movq 0x10(%rsp), %rdi
movq 0x138b4(%rip), %rsi     # 0x15fc0
callq 0x2210
jmp 0x2713
movl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
callq 0x2230
jmp 0x271f
leaq 0x140(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x2060
movq %rax, 0x8(%rsp)
jmp 0x273b
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, 0x7(%rsp)
jmp 0x2755
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x275f
jmp 0x2778
leaq 0x368(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x2890
jmp 0x2776
jmp 0x271f
leaq 0x140(%rsp), %rdi
callq 0x2070
jmp 0x2787
movq 0x398(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x2290
movl %eax, %edx
leaq 0x58(%rsp), %rdi
leaq 0x380(%rsp), %rsi
leaq 0x368(%rsp), %rcx
callq 0x2900
jmp 0x27b6
leaq 0x58(%rsp), %rdi
callq 0x2990
jmp 0x27c2
movl $0x0, 0x3a4(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x2bc0
leaq 0x140(%rsp), %rdi
callq 0x2080
leaq 0x348(%rsp), %rdi
callq 0x2130
leaq 0x368(%rsp), %rdi
callq 0x2c30
leaq 0x380(%rsp), %rdi
callq 0x2c30
movl 0x3a4(%rsp), %eax
addq $0x3a8, %rsp            # imm = 0x3A8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x2bc0
leaq 0x140(%rsp), %rdi
callq 0x2080
leaq 0x348(%rsp), %rdi
callq 0x2130
leaq 0x368(%rsp), %rdi
callq 0x2c30
leaq 0x380(%rsp), %rdi
callq 0x2c30
movq 0x138(%rsp), %rdi
callq 0x22e0
nopl (%rax)