// File: sharmaeklavya2[P]ctmeans/src/main.cpp
// Function: main
int main(int argc, char* argv[]) {
    // parse command-line args

#ifdef DEBUG
    feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT);
#endif
    int c, reps=0, max_epochs=0, max_t=0, seed=0;
    double eps_obj=0, eps_t=0;
    bool use_kd = true;
    const char* directory = nullptr;

    if(argc < 3 || argc > 10) {
        fprintf(stderr, "usage: %s\n", usage);
        return 2;
    }
    else {
        directory = argv[1];
        c = atoi(argv[2]);
        switch(argc) {
        case 10:
            seed = atoi(argv[9]);
        case 9:
            eps_t = atof(argv[8]);
        case 8:
            max_t = atoi(argv[7]);
        case 7:
            eps_obj = atof(argv[6]);
        case 6:
            max_epochs = atoi(argv[5]);
        case 5:
            use_kd = bool(atoi(argv[4]));
        case 4:
            reps = atoi(argv[3]);
        }

        if(reps <= 0) {reps = 1;}
        if(max_epochs <= 0) {max_epochs = 300;}
        if(eps_obj <= 0.0) {eps_obj = 0.0001;}
        if(max_t <= 0) {max_t = c;}
        if(eps_t <= 0.0) {eps_t = 0.0;}
        if(seed <= 0) {seed = int(time(nullptr));}
    }
    srand(seed);

    if(chdir(directory) != 0) {
        fprintf(stderr, "Couldn't chdir to %s\n", directory);
        perror("main");
        return 1;
    }

    FILE* fp = NULL;

    // store cmd args

    fp = fopen("args.json", "w");
    if(fp == nullptr) {
        fprintf(stderr, "Couldn't open args.json\n");
        perror("main");
    }
    else {
        string s = get_json_dict_template(
            " c,reps,use_kd,max_epochs,eps_obj,max_t, eps_t,seed",
            "%d,  %d,    %s,        %d, %.10lg,   %d,%.10lg,  %d");
        fprintf(fp, s.c_str(),
            c, reps, (use_kd? "true": "false"), max_epochs, eps_obj, max_t, eps_t, seed);
        fclose(fp);
    }

    // read input

    int n, d;

    fp = fopen("in.shape.txt", "r");
    if(fp == NULL) {
        fprintf(stderr, "Couldn't open in.shape.txt\n");
        perror("main");
        return 1;
    }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
    fscanf(fp, "%d%d", &n, &d);
#pragma GCC diagnostic pop
    fclose(fp);

    Matrix X(n, d);
    clock_t start_clock = clock();
    loadtxt("in.txt", X);
    clock_t end_clock = clock();
    double time_to_load_data = get_elapsed(start_clock, end_clock);
    printf("Time to load data: %lg\n", time_to_load_data);

    // cluster

    CTMeans model(X, c, 2, max_t, eps_t);
    start_clock = clock();
    double obj = model.cluster(use_kd, reps, max_epochs, eps_obj, stderr, 1, true);
    end_clock = clock();
    printf("Objective: %lg\n", obj);
    double time_to_cluster = get_elapsed(start_clock, end_clock);
    printf("Time to cluster: %lg\n", time_to_cluster);

    // write output

    start_clock = clock();
    // Matrix U(n, c, true);
    // model.get_dense_U(U);
    vector<int> labels;
    model.get_labels(labels);
    vector<double> flatu;
    model.get_flat_U(flatu);

    savetxt("centroids.txt", model.C);
    savetxt("labels.txt", labels.cbegin(), labels.cend());
    // savetxt("memberships.txt", U);
    savetxt("flatu.txt", flatu.cbegin(), flatu.cend());
    printf("flatu size: %zd, %lf, %lf\n", flatu.size(),
        double(flatu.size())/n, double(flatu.size())/n/c);
    end_clock = clock();

    double avg_sigC = output_vec_vec_to_file("sigc.txt", "SigC", n, c, model.SigC);
    printf("Average %s: %lf, %lf, %lf\n", "SigC", avg_sigC, avg_sigC/n, avg_sigC/n/c);
    double avg_heap_ops = 0;
    if(use_kd) {
        avg_heap_ops = output_vec_vec_to_file("heap_ops.txt", "heap_ops", n, c, model.P);
        printf("Average %s: %lf, %lf, %lf\n", "heap_ops", avg_heap_ops, avg_heap_ops/n, avg_heap_ops/n/c);
    }
    double time_to_save = get_elapsed(start_clock, end_clock);
    printf("Time to save: %lg\n", time_to_save);

    // write times

    fp = fopen("times.json", "w");
    if(fp == nullptr) {
        fprintf(stderr, "Couldn't open time.json\n");
        perror("main");
    }
    else {
        string s = get_json_dict_template(
            "load_data,cluster,  save",
            "   %.10lg, %.10lg,%.10lg");
        fprintf(fp, s.c_str(), time_to_load_data, time_to_cluster, time_to_save);
        fclose(fp);
    }

    // write stats

    fp = fopen("stats.json", "w");
    if(fp == nullptr) {
        fprintf(stderr, "Couldn't open stats.json\n");
        perror("main");
    }
    else {
        string s = get_json_dict_template(
            "objective,flatu_size,avg_sigC,avg_heap_ops",
            "   %.10lg,    %.10lg,  %.10lg,      %.10lg");
        fprintf(fp, s.c_str(), obj, double(flatu.size())/n, avg_sigC/n, avg_heap_ops/n);
        fclose(fp);
    }

    putchar('\n');
    return 0;
}

// Assembly:
subq $0x2f8, %rsp            # imm = 0x2F8
movl $0x0, 0x2f4(%rsp)
movl %edi, 0x2f0(%rsp)
movq %rsi, 0x2e8(%rsp)
movl $0x0, 0x2e0(%rsp)
movl $0x0, 0x2dc(%rsp)
movl $0x0, 0x2d8(%rsp)
movl $0x0, 0x2d4(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x2c8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x2c0(%rsp)
movb $0x1, 0x2bf(%rsp)
movq $0x0, 0x2b0(%rsp)
cmpl $0x3, 0x2f0(%rsp)
jl 0x1240d
cmpl $0xa, 0x2f0(%rsp)
jle 0x1243c
movq 0x9bc4(%rip), %rax      # 0x1bfd8
movq (%rax), %rdi
movq 0x9d72(%rip), %rdx      # 0x1c190
leaq 0x1e2a(%rip), %rsi      # 0x1424f
movb $0x0, %al
callq 0x2220
movl $0x2, 0x2f4(%rsp)
jmp 0x13058
movq 0x2e8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x2b0(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x2260
movl %eax, 0x2e4(%rsp)
movl 0x2f0(%rsp), %eax
addl $-0x4, %eax
movl %eax, %ecx
movq %rcx, 0xe0(%rsp)
subl $0x6, %eax
ja 0x12551
movq 0xe0(%rsp), %rax
leaq 0x1d2c(%rip), %rcx      # 0x141c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x2e8(%rsp), %rax
movq 0x48(%rax), %rdi
callq 0x2260
movl %eax, 0x2d4(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x21e0
movsd %xmm0, 0x2c0(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x2260
movl %eax, 0x2d8(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x21e0
movsd %xmm0, 0x2c8(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x2260
movl %eax, 0x2dc(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x2260
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x2bf(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x2260
movl %eax, 0x2e0(%rsp)
cmpl $0x0, 0x2e0(%rsp)
jg 0x12566
movl $0x1, 0x2e0(%rsp)
cmpl $0x0, 0x2dc(%rsp)
jg 0x1257b
movl $0x12c, 0x2dc(%rsp) # imm = 0x12C
xorps %xmm0, %xmm0
ucomisd 0x2c8(%rsp), %xmm0
jb 0x1259a
movsd 0x1bff(%rip), %xmm0     # 0x14190
movsd %xmm0, 0x2c8(%rsp)
cmpl $0x0, 0x2d8(%rsp)
jg 0x125b2
movl 0x2e4(%rsp), %eax
movl %eax, 0x2d8(%rsp)
xorps %xmm0, %xmm0
ucomisd 0x2c0(%rsp), %xmm0
jb 0x125cc
xorps %xmm0, %xmm0
movsd %xmm0, 0x2c0(%rsp)
cmpl $0x0, 0x2d4(%rsp)
jg 0x125e6
xorl %eax, %eax
movl %eax, %edi
callq 0x2130
movl %eax, 0x2d4(%rsp)
jmp 0x125e8
movl 0x2d4(%rsp), %edi
callq 0x2150
movq 0x2b0(%rsp), %rdi
callq 0x2240
cmpl $0x0, %eax
je 0x12642
movq 0x99cb(%rip), %rax      # 0x1bfd8
movq (%rax), %rdi
movq 0x2b0(%rsp), %rdx
leaq 0x1c3b(%rip), %rsi      # 0x1425a
movb $0x0, %al
callq 0x2220
leaq 0x1c43(%rip), %rdi      # 0x14270
callq 0x2110
movl $0x1, 0x2f4(%rsp)
jmp 0x13058
movq $0x0, 0x2a8(%rsp)
leaq 0x1c20(%rip), %rdi      # 0x14275
leaq 0x1ac6(%rip), %rsi      # 0x14122
callq 0x21b0
movq %rax, 0x2a8(%rsp)
cmpq $0x0, 0x2a8(%rsp)
jne 0x1269d
movq 0x995d(%rip), %rax      # 0x1bfd8
movq (%rax), %rdi
leaq 0x1bfa(%rip), %rsi      # 0x1427f
movb $0x0, %al
callq 0x2220
leaq 0x1bdd(%rip), %rdi      # 0x14270
callq 0x2110
jmp 0x12793
leaq 0x1bf4(%rip), %rsi      # 0x14298
leaq 0x1c21(%rip), %rdx      # 0x142cc
leaq 0x288(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x11fc0
movq 0xd0(%rsp), %rdi
movq 0x2a8(%rsp), %rax
movq %rax, 0xd8(%rsp)
callq 0x2080
movq 0xd8(%rsp), %rdi
movq %rax, %rsi
movl 0x2e4(%rsp), %edx
movl 0x2e0(%rsp), %ecx
movb 0x2bf(%rsp), %r9b
leaq 0x1bfb(%rip), %rax      # 0x14300
leaq 0x1bf9(%rip), %r8       # 0x14305
testb $0x1, %r9b
cmovneq %rax, %r8
movl 0x2dc(%rsp), %r9d
movsd 0x2c8(%rsp), %xmm0
movl 0x2d8(%rsp), %r10d
movsd 0x2c0(%rsp), %xmm1
movl 0x2d4(%rsp), %r11d
movq %rsp, %rax
movl %r11d, 0x8(%rax)
movl %r10d, (%rax)
movb $0x2, %al
callq 0x2220
movq 0x2a8(%rsp), %rdi
callq 0x2170
jmp 0x1275e
leaq 0x288(%rsp), %rdi
callq 0x20c0
jmp 0x12793
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x288(%rsp), %rdi
callq 0x20c0
jmp 0x13067
leaq 0x1b71(%rip), %rdi      # 0x1430b
leaq 0x199d(%rip), %rsi      # 0x1413e
callq 0x21b0
movq %rax, 0x2a8(%rsp)
cmpq $0x0, 0x2a8(%rsp)
jne 0x127ed
movq 0x9818(%rip), %rax      # 0x1bfd8
movq (%rax), %rdi
leaq 0x1b4e(%rip), %rsi      # 0x14318
movb $0x0, %al
callq 0x2220
leaq 0x1a98(%rip), %rdi      # 0x14270
callq 0x2110
movl $0x1, 0x2f4(%rsp)
jmp 0x13058
movq 0x2a8(%rsp), %rdi
leaq 0x1b38(%rip), %rsi      # 0x14334
xorl %eax, %eax
movl %eax, 0xc4(%rsp)
leaq 0x278(%rsp), %rdx
leaq 0x274(%rsp), %rcx
callq 0x22c0
movq 0x2a8(%rsp), %rdi
callq 0x2170
movl 0xc4(%rsp), %ecx
movl 0x278(%rsp), %esi
movl 0x274(%rsp), %edx
leaq 0x258(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0x13150
callq 0x20e0
movq 0xc8(%rsp), %rsi
movq %rax, 0x250(%rsp)
leaq 0x1acc(%rip), %rdi      # 0x14339
callq 0xfd60
jmp 0x12874
callq 0x20e0
movq %rax, 0x248(%rsp)
cvtsi2sdq 0x250(%rsp), %xmm0
cvtsi2sdq 0x248(%rsp), %xmm1
callq 0x11da0
movsd %xmm0, 0x240(%rsp)
movsd 0x240(%rsp), %xmm0
leaq 0x1a8d(%rip), %rdi      # 0x14340
movb $0x1, %al
callq 0x2030
jmp 0x128bc
movl 0x2e4(%rsp), %edx
movl 0x2d8(%rsp), %r8d
movsd 0x2c0(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
leaq 0x258(%rsp), %rsi
movl $0x2, %ecx
callq 0x13190
jmp 0x128f0
callq 0x20e0
movq %rax, 0x250(%rsp)
movl 0x2e0(%rsp), %edx
movl 0x2dc(%rsp), %ecx
movsd 0x2c8(%rsp), %xmm0
movq 0x96bd(%rip), %rax      # 0x1bfd8
movq (%rax), %r8
movzbl 0x2bf(%rsp), %esi
movq %rsp, %rax
movl $0x1, (%rax)
andl $0x1, %esi
leaq 0x1a0(%rsp), %rdi
movl $0x1, %r9d
callq 0x3290
movsd %xmm0, 0xb8(%rsp)
jmp 0x12950
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x198(%rsp)
callq 0x20e0
movq %rax, 0x248(%rsp)
movsd 0x198(%rsp), %xmm0
leaq 0x19d9(%rip), %rdi      # 0x14358
movb $0x1, %al
callq 0x2030
jmp 0x12988
cvtsi2sdq 0x250(%rsp), %xmm0
cvtsi2sdq 0x248(%rsp), %xmm1
callq 0x11da0
movsd %xmm0, 0x190(%rsp)
movsd 0x190(%rsp), %xmm0
leaq 0x19ae(%rip), %rdi      # 0x14368
movb $0x1, %al
callq 0x2030
jmp 0x129c3
callq 0x20e0
movq %rax, 0x250(%rsp)
leaq 0x178(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x3e20
movq 0xb0(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x38e0
jmp 0x129fc
leaq 0x160(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x3c50
movq 0xa8(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x3780
jmp 0x12a28
leaq 0x1c8(%rsp), %rsi
leaq 0x1947(%rip), %rdi      # 0x1437e
callq 0xfc60
jmp 0x12a3e
leaq 0x178(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x13370
movq 0xa0(%rsp), %rdi
movq %rax, 0x158(%rsp)
callq 0x133a0
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rsi
movq 0x150(%rsp), %rdx
leaq 0x1905(%rip), %rdi      # 0x1438c
callq 0x132d0
jmp 0x12a8e
leaq 0x160(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0xd520
movq 0x98(%rsp), %rdi
movq %rax, 0x148(%rsp)
callq 0xd550
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rsi
movq 0x140(%rsp), %rdx
leaq 0x18c0(%rip), %rdi      # 0x14397
callq 0x133d0
jmp 0x12ade
leaq 0x160(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x4270
movq 0x58(%rsp), %rdi
movq %rax, 0x88(%rsp)
callq 0x4270
movq 0x58(%rsp), %rdi
movq %rax, %xmm0
movaps 0x168d(%rip), %xmm1     # 0x141a0
movaps %xmm1, 0x60(%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x168c(%rip), %xmm1     # 0x141b0
movaps %xmm1, 0x70(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
cvtsi2sdl 0x278(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
callq 0x4270
movaps 0x60(%rsp), %xmm3
movaps 0x70(%rsp), %xmm2
movq 0x88(%rsp), %rsi
movsd 0x90(%rsp), %xmm0
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
cvtsi2sdl 0x278(%rsp), %xmm2
divsd %xmm2, %xmm1
cvtsi2sdl 0x2e4(%rsp), %xmm2
divsd %xmm2, %xmm1
leaq 0x17fa(%rip), %rdi      # 0x143a1
movb $0x2, %al
callq 0x2030
jmp 0x12bb0
callq 0x20e0
movq %rax, 0x248(%rsp)
movl 0x278(%rsp), %edx
movl 0x2e4(%rsp), %ecx
leaq 0x210(%rsp), %r8
leaq 0x17e2(%rip), %rdi      # 0x143bc
leaq 0x17e4(%rip), %rsi      # 0x143c5
callq 0x11dd0
movsd %xmm0, 0x50(%rsp)
jmp 0x12bee
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x138(%rsp)
movsd 0x138(%rsp), %xmm0
cvtsi2sdl 0x278(%rsp), %xmm2
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
cvtsi2sdl 0x2e4(%rsp), %xmm3
movaps %xmm1, %xmm2
divsd %xmm3, %xmm2
leaq 0x179d(%rip), %rdi      # 0x143ca
leaq 0x1791(%rip), %rsi      # 0x143c5
movb $0x3, %al
callq 0x2030
jmp 0x12c3d
xorps %xmm0, %xmm0
movsd %xmm0, 0x130(%rsp)
testb $0x1, 0x2bf(%rsp)
je 0x12d3d
movl 0x278(%rsp), %edx
movl 0x2e4(%rsp), %ecx
leaq 0x228(%rsp), %r8
leaq 0x1771(%rip), %rdi      # 0x143e5
leaq 0x1827(%rip), %rsi      # 0x144a2
callq 0x11dd0
movsd %xmm0, 0x48(%rsp)
jmp 0x12c88
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x130(%rsp)
movsd 0x130(%rsp), %xmm0
cvtsi2sdl 0x278(%rsp), %xmm2
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
cvtsi2sdl 0x2e4(%rsp), %xmm3
movaps %xmm1, %xmm2
divsd %xmm3, %xmm2
leaq 0x1703(%rip), %rdi      # 0x143ca
leaq 0x17d4(%rip), %rsi      # 0x144a2
movb $0x3, %al
callq 0x2030
jmp 0x12cd7
jmp 0x12d3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x13049
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x1303c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x1302f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x13022
cvtsi2sdq 0x250(%rsp), %xmm0
cvtsi2sdq 0x248(%rsp), %xmm1
callq 0x11da0
movsd %xmm0, 0x128(%rsp)
movsd 0x128(%rsp), %xmm0
leaq 0x1683(%rip), %rdi      # 0x143f2
movb $0x1, %al
callq 0x2030
jmp 0x12d78
leaq 0x1686(%rip), %rdi      # 0x14405
leaq 0x139c(%rip), %rsi      # 0x14122
callq 0x21b0
movq %rax, 0x40(%rsp)
jmp 0x12d92
movq 0x40(%rsp), %rax
movq %rax, 0x2a8(%rsp)
cmpq $0x0, 0x2a8(%rsp)
jne 0x12dd5
movq 0x9227(%rip), %rax      # 0x1bfd8
movq (%rax), %rdi
leaq 0x1655(%rip), %rsi      # 0x14410
xorl %eax, %eax
callq 0x2220
leaq 0x14a7(%rip), %rdi      # 0x14270
callq 0x2110
jmp 0x12dd0
jmp 0x12e7a
leaq 0x164d(%rip), %rsi      # 0x14429
leaq 0x165f(%rip), %rdx      # 0x14442
leaq 0x108(%rsp), %rdi
callq 0x11fc0
jmp 0x12df2
movq 0x2a8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x2080
movq 0x38(%rsp), %rdi
movq %rax, %rsi
movsd 0x240(%rsp), %xmm0
movsd 0x190(%rsp), %xmm1
movsd 0x128(%rsp), %xmm2
movb $0x3, %al
callq 0x2220
movq 0x2a8(%rsp), %rdi
callq 0x2170
jmp 0x12e45
leaq 0x108(%rsp), %rdi
callq 0x20c0
jmp 0x12e7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x20c0
jmp 0x13022
leaq 0x15da(%rip), %rdi      # 0x1445b
leaq 0x129a(%rip), %rsi      # 0x14122
callq 0x21b0
movq %rax, 0x30(%rsp)
jmp 0x12e94
movq 0x30(%rsp), %rax
movq %rax, 0x2a8(%rsp)
cmpq $0x0, 0x2a8(%rsp)
jne 0x12ed7
movq 0x9125(%rip), %rax      # 0x1bfd8
movq (%rax), %rdi
leaq 0x15a9(%rip), %rsi      # 0x14466
xorl %eax, %eax
callq 0x2220
leaq 0x13a5(%rip), %rdi      # 0x14270
callq 0x2110
jmp 0x12ed2
jmp 0x12fd5
leaq 0x15a2(%rip), %rsi      # 0x14480
leaq 0x15c6(%rip), %rdx      # 0x144ab
leaq 0xe8(%rsp), %rdi
callq 0x11fc0
jmp 0x12ef4
movq 0x2a8(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x2080
movq %rax, 0x20(%rsp)
movsd 0x198(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x4270
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movsd 0x28(%rsp), %xmm0
movq %rax, %xmm1
movaps 0x1255(%rip), %xmm2     # 0x141a0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x1259(%rip), %xmm2     # 0x141b0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
cvtsi2sdl 0x278(%rsp), %xmm4
divsd %xmm4, %xmm1
movsd 0x138(%rsp), %xmm2
divsd %xmm4, %xmm2
movsd 0x130(%rsp), %xmm3
divsd %xmm4, %xmm3
movb $0x4, %al
callq 0x2220
movq 0x2a8(%rsp), %rdi
callq 0x2170
jmp 0x12fa3
leaq 0xe8(%rsp), %rdi
callq 0x20c0
jmp 0x12fd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x20c0
jmp 0x13022
movl $0xa, %edi
callq 0x2210
jmp 0x12fe1
movl $0x0, 0x2f4(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x4450
leaq 0x178(%rsp), %rdi
callq 0x43f0
leaq 0x1a0(%rsp), %rdi
callq 0x13470
leaq 0x258(%rsp), %rdi
callq 0x4720
jmp 0x13058
leaq 0x160(%rsp), %rdi
callq 0x4450
leaq 0x178(%rsp), %rdi
callq 0x43f0
leaq 0x1a0(%rsp), %rdi
callq 0x13470
leaq 0x258(%rsp), %rdi
callq 0x4720
jmp 0x13067
movl 0x2f4(%rsp), %eax
addq $0x2f8, %rsp            # imm = 0x2F8
retq
movq 0x280(%rsp), %rdi
callq 0x22a0
nopw %cs:(%rax,%rax)
nop