// File: sharmaeklavya2[P]ddos-on-anycast/src/simulate.cpp
// Function: main
int main(int argc, char* argv[]) {

    if(argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) {
        print_usage(stdout, argv[0]);
        printf("\n");
        print_help(stdout);
        return 0;
    }
    else if(argc != n_arg_list+1) {
        print_usage(stderr, argv[0]);
        return 2;
    }
    else {
        for(int i=0; i<n_arg_list; ++i) {
            arg_list[i].set_from_string(argv[i+1]);
            arg_name_to_index[arg_list[i].name] = i;
        }
    }

    GrowParams grow_params;

    int n_top = get_arg_i("n_top");
    int n_expand = get_arg_i("n_expand");
    double expand_degree = get_arg_f("expand_degree");
    double n_expand_sigma = get_arg_f("n_expand_sigma");
    grow_params.num_children = get_arg_i("n_down");
    grow_params.num_children_sigma = get_arg_f("n_down_sigma");
    grow_params.prob_multi_upstream = get_arg_f("p_upstream");
    grow_params.prob_self_multi_upstream = get_arg_f("p_self_upstream");
    grow_params.prob_side_peering = get_arg_f("p_peering");
    grow_params.prob_self_side_peering = get_arg_f("p_local_peering");
    int top_side_conns = get_arg_i("top_side_conns");
    int n_layers = get_arg_i("n_layers");
    ivec n_victims_list;
    strcpy(buffer, get_arg_s("n_victims").c_str());
    fill_ivec_from_str(buffer, n_victims_list, ",");
    int smart_distr = get_arg_i("smart_distr");
    int tries = get_arg_i("tries");
    int reps = get_arg_i("reps");
    int seed = get_arg_i("seed");
    if(seed == 0) {
        seed = int(time(NULL));
    }
    int prog_reps = get_arg_i("prog_reps");
    bool csvout = get_arg_i("csvout");

    CompleteGraphGen complete_gen(n_top);
    RandomConnectedGraphGen rcgen(n_expand, expand_degree);
    NormalOrderGraphGen explode_graph_gen(n_expand_sigma, rcgen);

    rng_t rng(seed);

    int n_n_victims = n_victims_list.size();
    vector<vector<double> > relcatches(n_n_victims), misdisfacts(n_n_victims);
    for(int i=0; i<n_n_victims; ++i) {
        relcatches[i].resize(reps, 0.0);
        misdisfacts[i].resize(reps, 0.0);
    }
    bool single_simulation = (reps == 1 && n_n_victims == 1 && (!csvout));

    for(int repi=0; repi < reps; ++repi) {
        if(reps > 1 && prog_reps > 0 && repi % prog_reps == 0) {
            fprintf(stderr, "reps: %d\r", repi);
        }
        Network network(complete_gen, rng(), false, top_side_conns);
        if(!network.long_sanity_check()) {
            puts("Network has inconsistencies!");
            return 1;
        }

        network.hgrow(explode_graph_gen, rng());

        for(int i=1; i<n_layers; ++i) {
            network.vgrow(grow_params, rng());
            network.hgrow(explode_graph_gen, rng());
        }

        int leaves = 0;
        for(int u: network.depthwise.back()) {
            if(!network.is_virtual(u)) {
                leaves++;
            }
        }
        if(single_simulation) {
            printf("Vertices: %d\n", network.num_vertices());
            printf("Edges: %d\n", network.num_edges());
            printf("Leaves: %d\n", leaves);
        }

        if(!network.long_sanity_check()) {
            puts("Network has inconsistencies!");
            network.print(stdout, false);
            return 1;
        }

        for(int i=0; i<n_n_victims; ++i) {
            int n_victims = n_victims_list[i];

            ivec victims, targets;
            if(smart_distr) {
                place_victims_using_toposort(network, n_victims, victims, seed, tries, 0.01);
            }
            else {
                place_victims_randomly(network, n_victims, victims, seed);
            }
            if(single_simulation) {
                printf("victims: %d\n\n", int(victims.size()));
            }
            attack(network, victims, targets, 1, 100);

            std::map<int, int> freq;
            for(int v: victims) {
                freq[v] = 0;
            }
            for(int u: network.depthwise.back()) {
                if(network.netsize[u] == 0) {
                    freq[targets[u]]++;
                }
            }
            vector<iipair> freq2(freq.begin(), freq.end());
            std::sort(freq2.begin(), freq2.end(), iipair_second_rcmp);
            double relcatch = double(freq2[0].second) / leaves;
            double misdisfact = double(freq2[0].second * victims.size()) / leaves;
            if(single_simulation) {
                if(victims.size() <= MAX_VICTIMS_TO_DISPLAY) {
                    printf("freqs (victim_id, attackers, relcatch, misdisfact):\n");
                    for(const iipair& p: freq2) {
                        double relcatch = double(p.second) / leaves;
                        double misdisfact = double(lli(p.second) * victims.size()) / leaves;
                        printf("  %5d: %4d: %lf: %lf\n", p.first, p.second, relcatch, misdisfact);
                    }
                }
                else {
                    printf("victim_id=%d, attackers=%d, relcatch=%lf, misdisfact=%lf\n",
                        freq2[0].first, freq2[0].second, relcatch, misdisfact);
                }
            }
            relcatches[i][repi] = relcatch;
            misdisfacts[i][repi] = misdisfact;
        }
    }

    if(!single_simulation) {
        if(reps > 1) {
            fprintf(stderr, "reps: %d\n", reps);
        }
        if(csvout) {
            printf("n_victims,r_mean,r_max,r_90p,r_75p,r_50p,r_stddev,r_iqd\n");
        }
        for(int i=0; i<n_n_victims; ++i) {
            int n_victims = n_victims_list[i];
            print_stats("relcatches", n_victims, relcatches[i], csvout);
        }
        if(!csvout) {
            for(int i=0; i<n_n_victims; ++i) {
                int n_victims = n_victims_list[i];
                print_stats("misdisfacts", n_victims, misdisfacts[i], csvout);
            }
        }
    }
    return 0;
}

// Assembly:
subq $0x4a8, %rsp            # imm = 0x4A8
movl $0x0, 0x4a4(%rsp)
movl %edi, 0x4a0(%rsp)
movq %rsi, 0x498(%rsp)
cmpl $0x2, 0x4a0(%rsp)
jne 0x215f0
movq 0x498(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x8557(%rip), %rsi      # 0x29ad9
callq 0x2210
cmpl $0x0, %eax
je 0x215a9
movq 0x498(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x853d(%rip), %rsi      # 0x29adc
callq 0x2210
cmpl $0x0, %eax
jne 0x215f0
movq 0x169f8(%rip), %rax     # 0x37fa8
movq (%rax), %rdi
movq 0x498(%rsp), %rax
movq (%rax), %rsi
callq 0x228f0
leaq 0x8573(%rip), %rdi      # 0x29b3d
movb $0x0, %al
callq 0x2040
movq 0x169d0(%rip), %rax     # 0x37fa8
movq (%rax), %rdi
callq 0x229b0
movl $0x0, 0x4a4(%rsp)
jmp 0x228ca
cmpl $0x14, 0x4a0(%rsp)
je 0x21624
movq 0x169c7(%rip), %rax     # 0x37fc8
movq (%rax), %rdi
movq 0x498(%rsp), %rax
movq (%rax), %rsi
callq 0x228f0
movl $0x2, 0x4a4(%rsp)
jmp 0x228ca
movl $0x0, 0x494(%rsp)
cmpl $0x13, 0x494(%rsp)
jge 0x216c6
movslq 0x494(%rsp), %rax
leaq 0x16b74(%rip), %rdi     # 0x381c0
imulq $0xa0, %rax, %rax
addq %rax, %rdi
movq 0x498(%rsp), %rax
movl 0x494(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x23010
movl 0x494(%rsp), %eax
movl %eax, 0x104(%rsp)
movslq 0x494(%rsp), %rax
leaq 0x16b2f(%rip), %rsi     # 0x381c0
imulq $0xa0, %rax, %rax
addq %rax, %rsi
leaq 0x176fe(%rip), %rdi     # 0x38da0
callq 0x230b0
movl 0x104(%rsp), %ecx
movl %ecx, (%rax)
movl 0x494(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x494(%rsp)
jmp 0x2162f
jmp 0x216c8
jmp 0x216ca
leaq 0x801f(%rip), %rdi      # 0x296f0
callq 0x21490
movl %eax, 0x45c(%rsp)
leaq 0x802e(%rip), %rdi      # 0x29712
callq 0x21490
movl %eax, 0x458(%rsp)
leaq 0x8046(%rip), %rdi      # 0x2973d
callq 0x214c0
movsd %xmm0, 0x450(%rsp)
leaq 0x8064(%rip), %rdi      # 0x29770
callq 0x214c0
movsd %xmm0, 0x448(%rsp)
leaq 0x8062(%rip), %rdi      # 0x29783
callq 0x21490
movl %eax, 0x460(%rsp)
leaq 0x8069(%rip), %rdi      # 0x2979d
callq 0x214c0
movsd %xmm0, 0x468(%rsp)
leaq 0x8061(%rip), %rdi      # 0x297aa
callq 0x214c0
movsd %xmm0, 0x470(%rsp)
leaq 0x808e(%rip), %rdi      # 0x297ec
callq 0x214c0
movsd %xmm0, 0x478(%rsp)
leaq 0x80d2(%rip), %rdi      # 0x29845
callq 0x214c0
movsd %xmm0, 0x480(%rsp)
leaq 0x80de(%rip), %rdi      # 0x29866
callq 0x214c0
movsd %xmm0, 0x488(%rsp)
leaq 0x8103(%rip), %rdi      # 0x298a0
callq 0x21490
movl %eax, 0x444(%rsp)
leaq 0x8136(%rip), %rdi      # 0x298e6
callq 0x21490
movl %eax, 0x440(%rsp)
leaq 0x428(%rsp), %rdi
callq 0x6ee0
leaq 0x813b(%rip), %rsi      # 0x2990b
leaq 0x408(%rsp), %rdi
callq 0x214f0
jmp 0x217df
leaq 0x408(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x2090
movq %rax, %rsi
leaq 0x175d2(%rip), %rdi     # 0x38dd0
movq %rdi, 0xf8(%rsp)
callq 0x2170
movq 0xf0(%rsp), %rdi
callq 0x20e0
movq 0xf8(%rsp), %rdi
leaq 0x82bc(%rip), %rdx      # 0x29ae3
leaq 0x428(%rsp), %rsi
callq 0x22a70
jmp 0x21836
leaq 0x80f4(%rip), %rdi      # 0x29931
callq 0x21490
movl %eax, 0xec(%rsp)
jmp 0x2184b
movl 0xec(%rsp), %eax
movl %eax, 0x3f8(%rsp)
leaq 0x8109(%rip), %rdi      # 0x29969
callq 0x21490
movl %eax, 0xe8(%rsp)
jmp 0x2186e
movl 0xe8(%rsp), %eax
movl %eax, 0x3f4(%rsp)
leaq 0x8185(%rip), %rdi      # 0x29a08
callq 0x21490
movl %eax, 0xe4(%rsp)
jmp 0x21891
movl 0xe4(%rsp), %eax
movl %eax, 0x3f0(%rsp)
leaq 0x8137(%rip), %rdi      # 0x299dd
callq 0x21490
movl %eax, 0xe0(%rsp)
jmp 0x218b4
movl 0xe0(%rsp), %eax
movl %eax, 0x3ec(%rsp)
cmpl $0x0, 0x3ec(%rsp)
jne 0x218f7
xorl %eax, %eax
movl %eax, %edi
callq 0x2160
movl %eax, 0x3ec(%rsp)
jmp 0x218f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
jmp 0x228bb
leaq 0x8105(%rip), %rdi      # 0x29a03
callq 0x21490
movl %eax, 0xdc(%rsp)
jmp 0x2190c
movl 0xdc(%rsp), %eax
movl %eax, 0x3e8(%rsp)
leaq 0x811b(%rip), %rdi      # 0x29a3c
callq 0x21490
movl %eax, 0xd8(%rsp)
jmp 0x2192f
movl 0xd8(%rsp), %eax
testl %eax, %eax
setne 0x3e7(%rsp)
movl 0x45c(%rsp), %esi
leaq 0x3d0(%rsp), %rdi
callq 0x231a0
jmp 0x21956
movl 0x458(%rsp), %esi
movsd 0x450(%rsp), %xmm0
leaq 0x3b8(%rsp), %rdi
callq 0x231e0
jmp 0x21975
movsd 0x448(%rsp), %xmm0
leaq 0x398(%rsp), %rdi
leaq 0x3b8(%rsp), %rsi
callq 0x23230
jmp 0x21995
movslq 0x3ec(%rsp), %rsi
leaq 0x390(%rsp), %rdi
callq 0xa4a0
jmp 0x219ac
leaq 0x428(%rsp), %rdi
callq 0x5490
movl %eax, 0x38c(%rsp)
movslq 0x38c(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x36f(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x23290
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0x370(%rsp), %rdi
callq 0x232a0
jmp 0x21a04
leaq 0x36f(%rsp), %rdi
callq 0x23320
movslq 0x38c(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x34f(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x23290
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
leaq 0x350(%rsp), %rdi
callq 0x232a0
jmp 0x21a55
leaq 0x34f(%rsp), %rdi
callq 0x23320
movl $0x0, 0x348(%rsp)
movl 0x348(%rsp), %eax
cmpl 0x38c(%rsp), %eax
jge 0x21b74
movslq 0x348(%rsp), %rsi
leaq 0x370(%rsp), %rdi
callq 0x23330
movq %rax, %rdi
movslq 0x3f0(%rsp), %rsi
movq $0x0, 0x340(%rsp)
leaq 0x340(%rsp), %rdx
callq 0x23350
jmp 0x21abc
movslq 0x348(%rsp), %rsi
leaq 0x350(%rsp), %rdi
callq 0x23330
movq %rax, %rdi
movslq 0x3f0(%rsp), %rsi
movq $0x0, 0x338(%rsp)
leaq 0x338(%rsp), %rdx
callq 0x23350
jmp 0x21af7
jmp 0x21af9
movl 0x348(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x348(%rsp)
jmp 0x21a6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
leaq 0x36f(%rsp), %rdi
callq 0x23320
jmp 0x228bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
leaq 0x34f(%rsp), %rdi
callq 0x23320
jmp 0x228ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
jmp 0x228a1
xorl %eax, %eax
cmpl $0x1, 0x3f0(%rsp)
movb %al, 0xb7(%rsp)
jne 0x21baa
xorl %eax, %eax
cmpl $0x1, 0x38c(%rsp)
movb %al, 0xb7(%rsp)
jne 0x21baa
movb 0x3e7(%rsp), %al
xorb $-0x1, %al
movb %al, 0xb7(%rsp)
movb 0xb7(%rsp), %al
andb $0x1, %al
movb %al, 0x337(%rsp)
movl $0x0, 0x330(%rsp)
movl 0x330(%rsp), %eax
cmpl 0x3f0(%rsp), %eax
jge 0x226dd
cmpl $0x1, 0x3f0(%rsp)
jle 0x21c20
cmpl $0x0, 0x3e8(%rsp)
jle 0x21c20
movl 0x330(%rsp), %eax
cltd
idivl 0x3e8(%rsp)
cmpl $0x0, %edx
jne 0x21c20
movq 0x163c0(%rip), %rax     # 0x37fc8
movq (%rax), %rdi
movl 0x330(%rsp), %edx
leaq 0x7ecc(%rip), %rsi      # 0x29ae5
movb $0x0, %al
callq 0x2220
leaq 0x390(%rsp), %rdi
callq 0xa4d0
movq %rax, 0xa8(%rsp)
jmp 0x21c37
movq 0xa8(%rsp), %rax
movl %eax, %edx
movl 0x444(%rsp), %r8d
leaq 0x270(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
xorl %ecx, %ecx
callq 0x23410
jmp 0x21c62
leaq 0x270(%rsp), %rdi
callq 0x3b80
movb %al, 0xa7(%rsp)
jmp 0x21c78
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0x21cc7
jmp 0x21c85
leaq 0x7e63(%rip), %rdi      # 0x29aef
callq 0x2250
jmp 0x21c93
movl $0x1, 0x4a4(%rsp)
movl $0x1, 0x26c(%rsp)
jmp 0x22695
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
jmp 0x226cb
leaq 0x390(%rsp), %rdi
callq 0xa4d0
movq %rax, 0x98(%rsp)
jmp 0x21cde
movq 0x98(%rsp), %rax
movl %eax, %edx
leaq 0x270(%rsp), %rdi
leaq 0x398(%rsp), %rsi
callq 0x98b0
jmp 0x21cff
movl $0x1, 0x268(%rsp)
movl 0x268(%rsp), %eax
cmpl 0x440(%rsp), %eax
jge 0x21da6
leaq 0x390(%rsp), %rdi
callq 0xa4d0
movq %rax, 0x90(%rsp)
jmp 0x21d35
movq 0x90(%rsp), %rax
movl %eax, %edx
leaq 0x270(%rsp), %rdi
leaq 0x460(%rsp), %rsi
callq 0x9a90
jmp 0x21d56
leaq 0x390(%rsp), %rdi
callq 0xa4d0
movq %rax, 0x88(%rsp)
jmp 0x21d6d
movq 0x88(%rsp), %rax
movl %eax, %edx
leaq 0x270(%rsp), %rdi
leaq 0x398(%rsp), %rsi
callq 0x98b0
jmp 0x21d8e
jmp 0x21d90
movl 0x268(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x268(%rsp)
jmp 0x21d0a
movl $0x0, 0x264(%rsp)
leaq 0x270(%rsp), %rdi
addq $0xa8, %rdi
callq 0xa660
movq %rax, 0x258(%rsp)
movq 0x258(%rsp), %rdi
callq 0x6180
movq %rax, 0x250(%rsp)
movq 0x258(%rsp), %rdi
callq 0x6000
movq %rax, 0x248(%rsp)
leaq 0x250(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0xa570
testb $0x1, %al
jne 0x21e12
jmp 0x21e74
leaq 0x250(%rsp), %rdi
callq 0xa5b0
movl (%rax), %eax
movl %eax, 0x244(%rsp)
movl 0x244(%rsp), %esi
leaq 0x270(%rsp), %rdi
callq 0x4dc0
movb %al, 0x87(%rsp)
jmp 0x21e45
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x21e63
jmp 0x21e52
movl 0x264(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x264(%rsp)
jmp 0x21e65
leaq 0x250(%rsp), %rdi
callq 0xa640
jmp 0x21df7
testb $0x1, 0x337(%rsp)
je 0x21eeb
leaq 0x270(%rsp), %rdi
callq 0x3030
movl %eax, 0x80(%rsp)
jmp 0x21e94
movl 0x80(%rsp), %esi
leaq 0x7c6a(%rip), %rdi      # 0x29b0c
xorl %eax, %eax
callq 0x2040
jmp 0x21eab
leaq 0x270(%rsp), %rdi
callq 0x30c0
movl %eax, 0x7c(%rsp)
jmp 0x21ebe
movl 0x7c(%rsp), %esi
leaq 0x7c51(%rip), %rdi      # 0x29b1a
xorl %eax, %eax
callq 0x2040
jmp 0x21ed2
movl 0x264(%rsp), %esi
leaq 0x7c45(%rip), %rdi      # 0x29b25
xorl %eax, %eax
callq 0x2040
jmp 0x21ee9
jmp 0x21eeb
leaq 0x270(%rsp), %rdi
callq 0x3b80
movb %al, 0x7b(%rsp)
jmp 0x21efe
movb 0x7b(%rsp), %al
testb $0x1, %al
jne 0x21f4c
jmp 0x21f08
leaq 0x7be0(%rip), %rdi      # 0x29aef
callq 0x2250
jmp 0x21f16
movq 0x1608b(%rip), %rax     # 0x37fa8
movq (%rax), %rsi
leaq 0x270(%rsp), %rdi
xorl %edx, %edx
callq 0x36a0
jmp 0x21f31
movl $0x1, 0x4a4(%rsp)
movl $0x1, 0x26c(%rsp)
jmp 0x22695
movl $0x0, 0x240(%rsp)
movl 0x240(%rsp), %eax
cmpl 0x38c(%rsp), %eax
jge 0x2268a
movslq 0x240(%rsp), %rsi
leaq 0x428(%rsp), %rdi
callq 0x4df0
movl (%rax), %eax
movl %eax, 0x23c(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x6ee0
leaq 0x208(%rsp), %rdi
callq 0x6ee0
cmpl $0x0, 0x3f8(%rsp)
je 0x21ffd
movl 0x23c(%rsp), %esi
movl 0x3ec(%rsp), %ecx
movl 0x3f4(%rsp), %r8d
leaq 0x270(%rsp), %rdi
leaq 0x220(%rsp), %rdx
movsd 0x7705(%rip), %xmm0     # 0x296e0
callq 0x18c30
jmp 0x21fe2
jmp 0x22024
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
jmp 0x2266e
movl 0x23c(%rsp), %esi
movl 0x3ec(%rsp), %ecx
leaq 0x270(%rsp), %rdi
leaq 0x220(%rsp), %rdx
callq 0x17fe0
jmp 0x22022
jmp 0x22024
testb $0x1, 0x337(%rsp)
je 0x2204f
leaq 0x220(%rsp), %rdi
callq 0x5490
movl %eax, %esi
leaq 0x7aed(%rip), %rdi      # 0x29b31
xorl %eax, %eax
callq 0x2040
jmp 0x2204d
jmp 0x2204f
leaq 0x270(%rsp), %rdi
leaq 0x220(%rsp), %rsi
leaq 0x208(%rsp), %rdx
movl $0x1, %ecx
movl $0x64, %r8d
callq 0x12da0
jmp 0x22079
leaq 0x1d8(%rsp), %rdi
callq 0x1b0a0
leaq 0x220(%rsp), %rax
movq %rax, 0x1d0(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x6180
movq %rax, 0x1c8(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x6000
movq %rax, 0x1c0(%rsp)
leaq 0x1c8(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0xa570
testb $0x1, %al
jne 0x220db
jmp 0x22140
leaq 0x1c8(%rsp), %rdi
callq 0xa5b0
movl (%rax), %eax
movl %eax, 0x1bc(%rsp)
leaq 0x1d8(%rsp), %rdi
leaq 0x1bc(%rsp), %rsi
callq 0x1b0b0
movq %rax, 0x70(%rsp)
jmp 0x2210d
movq 0x70(%rsp), %rax
movl $0x0, (%rax)
leaq 0x1c8(%rsp), %rdi
callq 0xa640
jmp 0x220c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
jmp 0x22661
leaq 0x270(%rsp), %rdi
addq $0xa8, %rdi
callq 0xa660
movq %rax, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rdi
callq 0x6180
movq %rax, 0x1a8(%rsp)
movq 0x1b0(%rsp), %rdi
callq 0x6000
movq %rax, 0x1a0(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0xa570
testb $0x1, %al
jne 0x221a4
jmp 0x22224
leaq 0x1a8(%rsp), %rdi
callq 0xa5b0
movl (%rax), %eax
movl %eax, 0x19c(%rsp)
leaq 0x270(%rsp), %rdi
addq $0x18, %rdi
movslq 0x19c(%rsp), %rsi
callq 0x4df0
cmpl $0x0, (%rax)
jne 0x22210
movslq 0x19c(%rsp), %rsi
leaq 0x208(%rsp), %rdi
callq 0x4df0
movq %rax, %rsi
leaq 0x1d8(%rsp), %rdi
callq 0x1b0b0
movq %rax, 0x68(%rsp)
jmp 0x22204
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x22212
leaq 0x1a8(%rsp), %rdi
callq 0xa640
jmp 0x22186
leaq 0x1d8(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x235d0
movq 0x58(%rsp), %rdi
movq %rax, 0x178(%rsp)
callq 0x1efc0
movq %rax, 0x170(%rsp)
leaq 0x16f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x5650
movq 0x60(%rsp), %rcx
movq 0x178(%rsp), %rsi
movq 0x170(%rsp), %rdx
leaq 0x180(%rsp), %rdi
callq 0x23600
jmp 0x22286
leaq 0x16f(%rsp), %rdi
callq 0x5df0
leaq 0x180(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x7810
movq 0x50(%rsp), %rdi
movq %rax, 0x160(%rsp)
callq 0x7690
movq %rax, 0x158(%rsp)
movq 0x160(%rsp), %rdi
movq 0x158(%rsp), %rsi
leaq 0x80a(%rip), %rdx       # 0x22ae0
callq 0x23690
jmp 0x222dd
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0x40(%rsp)
leaq 0x180(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xdde0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
cvtsi2sdl 0x4(%rax), %xmm0
cvtsi2sdl 0x264(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x150(%rsp)
callq 0xdde0
movslq 0x4(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x5490
movq %rax, %rcx
movq 0x48(%rsp), %rax
imulq %rcx, %rax
movq %rax, %xmm0
movaps 0x7160(%rip), %xmm1     # 0x294b0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x7164(%rip), %xmm1     # 0x294c0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
cvtsi2sdl 0x264(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x148(%rsp)
testb $0x1, 0x337(%rsp)
je 0x2259b
leaq 0x220(%rsp), %rdi
callq 0x5490
cmpq $0x64, %rax
ja 0x2253e
leaq 0x7792(%rip), %rdi      # 0x29b3f
xorl %eax, %eax
callq 0x2040
jmp 0x223b6
leaq 0x180(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rdi
callq 0x7810
movq %rax, 0x138(%rsp)
movq 0x140(%rsp), %rdi
callq 0x7690
movq %rax, 0x130(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0xa500
testb $0x1, %al
jne 0x2240e
jmp 0x2253c
leaq 0x138(%rsp), %rdi
callq 0xa540
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rax
cvtsi2sdl 0x4(%rax), %xmm0
cvtsi2sdl 0x264(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x120(%rsp)
movq 0x128(%rsp), %rax
movslq 0x4(%rax), %rax
movq %rax, 0x30(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x5490
movq %rax, %rcx
movq 0x30(%rsp), %rax
imulq %rcx, %rax
movq %rax, %xmm0
movaps 0x7034(%rip), %xmm1     # 0x294b0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x7038(%rip), %xmm1     # 0x294c0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
cvtsi2sdl 0x264(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x118(%rsp)
movq 0x128(%rsp), %rax
movl (%rax), %esi
movl 0x4(%rax), %edx
movsd 0x120(%rsp), %xmm0
movsd 0x118(%rsp), %xmm1
leaq 0x76a1(%rip), %rdi      # 0x29b74
movb $0x2, %al
callq 0x2040
jmp 0x224dc
jmp 0x224de
leaq 0x138(%rsp), %rdi
callq 0xa550
jmp 0x223f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
leaq 0x16f(%rsp), %rdi
callq 0x5df0
jmp 0x22661
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x400(%rsp)
movl %eax, 0x3fc(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x5070
jmp 0x22661
jmp 0x22599
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0x20(%rsp)
leaq 0x180(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xdde0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
callq 0xdde0
movl 0x2c(%rsp), %esi
movl 0x4(%rax), %edx
movsd 0x150(%rsp), %xmm0
movsd 0x148(%rsp), %xmm1
leaq 0x75fc(%rip), %rdi      # 0x29b8a
movb $0x2, %al
callq 0x2040
jmp 0x22597
jmp 0x22599
jmp 0x2259b
movsd 0x150(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movslq 0x240(%rsp), %rsi
leaq 0x370(%rsp), %rdi
callq 0x23330
movq %rax, %rdi
movslq 0x330(%rsp), %rsi
callq 0xd540
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x148(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movslq 0x240(%rsp), %rsi
leaq 0x350(%rsp), %rdi
callq 0x23330
movq %rax, %rdi
movslq 0x330(%rsp), %rsi
callq 0xd540
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x180(%rsp), %rdi
callq 0x5070
leaq 0x1d8(%rsp), %rdi
callq 0x1b2e0
leaq 0x208(%rsp), %rdi
callq 0x55b0
leaq 0x220(%rsp), %rdi
callq 0x55b0
movl 0x240(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x240(%rsp)
jmp 0x21f57
leaq 0x1d8(%rsp), %rdi
callq 0x1b2e0
leaq 0x208(%rsp), %rdi
callq 0x55b0
leaq 0x220(%rsp), %rdi
callq 0x55b0
jmp 0x226cb
movl $0x0, 0x26c(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x236e0
movl 0x26c(%rsp), %eax
testl %eax, %eax
jne 0x22878
jmp 0x226b3
jmp 0x226b5
movl 0x330(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x330(%rsp)
jmp 0x21bc5
leaq 0x270(%rsp), %rdi
callq 0x236e0
jmp 0x228a1
testb $0x1, 0x337(%rsp)
jne 0x22862
cmpl $0x1, 0x3f0(%rsp)
jle 0x22714
movq 0x158cc(%rip), %rax     # 0x37fc8
movq (%rax), %rdi
movl 0x3f0(%rsp), %edx
leaq 0x74b7(%rip), %rsi      # 0x29bc4
movb $0x0, %al
callq 0x2220
testb $0x1, 0x3e7(%rsp)
je 0x22730
leaq 0x74a9(%rip), %rdi      # 0x29bce
xorl %eax, %eax
callq 0x2040
jmp 0x2272e
jmp 0x22730
movl $0x0, 0x114(%rsp)
movl 0x114(%rsp), %eax
cmpl 0x38c(%rsp), %eax
jge 0x227c1
movslq 0x114(%rsp), %rsi
leaq 0x428(%rsp), %rdi
callq 0x4df0
movl (%rax), %eax
movl %eax, 0x110(%rsp)
movl 0x110(%rsp), %eax
movl %eax, 0x4(%rsp)
movslq 0x114(%rsp), %rsi
leaq 0x370(%rsp), %rdi
callq 0x23330
movl 0x4(%rsp), %esi
movq %rax, %rdx
movzbl 0x3e7(%rsp), %ecx
andl $0x1, %ecx
leaq 0x7465(%rip), %rdi      # 0x29c07
callq 0x20f80
jmp 0x227a9
jmp 0x227ab
movl 0x114(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x114(%rsp)
jmp 0x2273b
testb $0x1, 0x3e7(%rsp)
jne 0x22860
movl $0x0, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
cmpl 0x38c(%rsp), %eax
jge 0x2285e
movslq 0x10c(%rsp), %rsi
leaq 0x428(%rsp), %rdi
callq 0x4df0
movl (%rax), %eax
movl %eax, 0x108(%rsp)
movl 0x108(%rsp), %eax
movl %eax, (%rsp)
movslq 0x10c(%rsp), %rsi
leaq 0x350(%rsp), %rdi
callq 0x23330
movl (%rsp), %esi
movq %rax, %rdx
movzbl 0x3e7(%rsp), %ecx
andl $0x1, %ecx
leaq 0x73d3(%rip), %rdi      # 0x29c12
callq 0x20f80
jmp 0x22846
jmp 0x22848
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0x227da
jmp 0x22860
jmp 0x22862
movl $0x0, 0x4a4(%rsp)
movl $0x1, 0x26c(%rsp)
leaq 0x350(%rsp), %rdi
callq 0x23770
leaq 0x370(%rsp), %rdi
callq 0x23770
leaq 0x428(%rsp), %rdi
callq 0x55b0
jmp 0x228ca
leaq 0x350(%rsp), %rdi
callq 0x23770
leaq 0x370(%rsp), %rdi
callq 0x23770
leaq 0x428(%rsp), %rdi
callq 0x55b0
jmp 0x228d9
movl 0x4a4(%rsp), %eax
addq $0x4a8, %rsp            # imm = 0x4A8
retq
movq 0x400(%rsp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)