// File: FFY00[P]uicc/src/program_uicc.c
// Function: authenticate(char*, uicc_vals&)
void authenticate(char *port, struct uicc_vals &values) {
    string key;
    Assert(makeBin(values.key, key) == 16, "can't read a correct key: 16 hexa figures\n");
    string opc;
    Assert(makeBin(values.opc, opc) == 16, "can't read a correct opc: 16 hexa figures\n");
    USIM USIMcard;
    string ATR;
    Assert((ATR=USIMcard.open(port))!="", "Failed to open %s", port);
    //dump_hex("ATR", ATR);
    USIMcard.openUSIM();
    USIMcard.debug=false;
    // We don't make proper values for rand, sqn,
    // we perform first authentication only to get the AUTS from the USIM
    u8 amf[2]= {0};
    u8 sqn[6]= {0};
    u8 rand[16]= {0};
    u8 autn[16]= {0};
    u8 ik[16]= {0};
    u8 ck[16]= {0};
    u8 res[8]= {0};
    Assert(milenage_generate((const uint8_t *)opc.c_str(), amf,
                             (const uint8_t *)key.c_str(), sqn,
                             rand,
                             autn, ik, ck, res),
           "Milenage internal failure\n");
    string srand((char *)rand,sizeof(rand));
    string sautn((char *)autn,sizeof(autn));
    vector<string> returned=USIMcard.authenticate(srand, sautn);

    // We should have one LV value returned, the AUTS
    if (returned.size()!=1) {
        printf("The card didn't accept our challenge: OPc or Ki is wrong\n");
        return;
    }

    u8 SIMsqn[8]= {0};

    if ( ! milenage_auts((const uint8_t *)opc.c_str(),
                         (const uint8_t *)key.c_str(),
                         rand,
                         (const uint8_t *)returned[0].c_str(),
                         SIMsqn+2) ) {
        printf("Can't decode the AUTS returned by the card (wrong Ki or OPc)\n");
        return;
    }

    uint64_t intSqn=be64toh(*(uint64_t *)SIMsqn);
    intSqn+=32; // according to 3GPP TS 33.102 version 11, annex C. 3.2
    uint64_t newSqn=htobe64(intSqn);
    // To make better validation, let's generate a random value in milenage "rand"
    FILE *h=fopen("/dev/random","r");
    fread(rand,sizeof(rand),1,h);
    fclose(h);
    Assert( milenage_generate((const uint8_t *)opc.c_str(), amf,
                              (const uint8_t *)key.c_str(),
                              ((u8 *)&newSqn)+2,
                              rand,
                              autn, ik, ck, res),
            "Milenage internal failure\n");
    // Now, we can test a authentication that should be sucessful
    string new_autn((char *)autn,16);
    string new_rand((char *)rand,16);
    vector<string>  returned_newSQN=USIMcard.authenticate(new_rand, new_autn);

    if ( USIMcard.debug )
        for (size_t i=0; i< returned_newSQN.size(); i++)
            dump_hex("auth answer",returned_newSQN[i]);

    if (returned_newSQN.size() != 4)
        printf("We tried SQN %" PRId64 ", but the card refused!\n",intSqn);
    else {
        string s_ik((char *)ik,sizeof(ik));
        string s_ck((char *)ck,sizeof(ck));
        string s_res((char *)res,sizeof(res));

        if ( s_res != returned_newSQN[0] ||
                s_ck  != returned_newSQN[1] ||
                s_ik  != returned_newSQN[2] )
            printf("The card sent back vectors, but they are not our milenage computation\n");
        else {
            printf("Succeeded to authentify with SQN: %" PRId64 "\n", intSqn);
            printf("set HSS SQN value as: %" PRId64 "\n", intSqn+32 );
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x33f0
movq -0x10(%rbp), %rsi
addq $0xe8, %rsi
leaq -0x50(%rbp), %rdi
callq 0x3120
jmp 0xc252
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xbf90
movl %eax, -0x3c8(%rbp)
jmp 0xc267
movl -0x3c8(%rbp), %eax
cmpl $0x10, %eax
sete %al
xorb $-0x1, %al
movb %al, -0x3c9(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31a0
movb -0x3c9(%rbp), %al
testb $0x1, %al
jne 0xc293
jmp 0xc333
movq 0x22d36(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x3d8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x3d8(%rbp), %rdi
movq %rax, %r9
leaq 0x18c03(%rip), %rsi     # 0x24ec4
leaq 0x18d4d(%rip), %rdx     # 0x25015
leaq 0x170c1(%rip), %rcx     # 0x23390
xorl %eax, %eax
movl $0x140, %r8d            # imm = 0x140
callq 0x3410
movq 0x22cbd(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
jmp 0xc2ed
movq 0x22cdc(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
jmp 0xc2fe
movl $0x1, %edi
callq 0x3370
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd0ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31a0
jmp 0xd0ee
jmp 0xc335
jmp 0xc337
leaq -0x80(%rbp), %rdi
callq 0x33f0
movq -0x10(%rbp), %rsi
addq $0x68, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3120
jmp 0xc356
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xbf90
movl %eax, -0x3dc(%rbp)
jmp 0xc36e
movl -0x3dc(%rbp), %eax
cmpl $0x10, %eax
sete %al
xorb $-0x1, %al
movb %al, -0x3dd(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x31a0
movb -0x3dd(%rbp), %al
testb $0x1, %al
jne 0xc39d
jmp 0xc440
movq 0x22c2c(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x3e8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x3e8(%rbp), %rdi
movq %rax, %r9
leaq 0x18c57(%rip), %rsi     # 0x25022
leaq 0x18c43(%rip), %rdx     # 0x25015
leaq 0x16fb7(%rip), %rcx     # 0x23390
xorl %eax, %eax
movl $0x142, %r8d            # imm = 0x142
callq 0x3410
movq 0x22bb3(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
jmp 0xc3f7
movq 0x22bd2(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
jmp 0xc408
movl $0x1, %edi
callq 0x3370
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd0e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x31a0
jmp 0xd0e5
jmp 0xc442
jmp 0xc444
leaq -0xf0(%rbp), %rdi
callq 0xf870
jmp 0xc452
leaq -0x110(%rbp), %rdi
callq 0x33f0
movq -0x8(%rbp), %rdx
leaq -0x130(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xe9b0
jmp 0xc477
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3390
movq %rax, %rdi
leaq 0x197d0(%rip), %rsi     # 0x25c64
callq 0xe980
movb %al, -0x3e9(%rbp)
jmp 0xc4a1
movb -0x3e9(%rbp), %al
xorb $-0x1, %al
movb %al, -0x3ea(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x31a0
movb -0x3ea(%rbp), %al
testb $0x1, %al
jne 0xc4ca
jmp 0xc577
movq 0x22aff(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x3f8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x3f8(%rbp), %rdi
movq %rax, %r9
movq -0x8(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x16ec5(%rip), %rsi     # 0x233c7
leaq 0x18b0c(%rip), %rdx     # 0x25015
leaq 0x16e80(%rip), %rcx     # 0x23390
xorl %eax, %eax
movl $0x145, %r8d            # imm = 0x145
callq 0x3410
movq 0x22a7c(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
jmp 0xc52e
movq 0x22a9b(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
jmp 0xc53f
movl $0x1, %edi
callq 0x3370
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd0cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x31a0
jmp 0xd0cd
jmp 0xc579
jmp 0xc57b
leaq -0xf0(%rbp), %rdi
callq 0x104a0
jmp 0xc589
movb $0x0, -0xf0(%rbp)
leaq -0x132(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x3160
leaq -0x138(%rbp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x3160
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3160
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3160
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3160
leaq -0x180(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x3160
leaq -0x188(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x3160
leaq -0x80(%rbp), %rdi
callq 0x3110
movq %rax, -0x408(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3110
movq -0x408(%rbp), %rdi
movq %rax, %rdx
movq %rsp, %rax
leaq -0x188(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0x180(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x170(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x132(%rbp), %rsi
leaq -0x138(%rbp), %rcx
leaq -0x150(%rbp), %r8
leaq -0x160(%rbp), %r9
callq 0x3b60
movb %al, -0x3f9(%rbp)
jmp 0xc684
movb -0x3f9(%rbp), %al
testb $0x1, %al
jne 0xc705
jmp 0xc690
movq 0x22939(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x410(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x410(%rbp), %rdi
movq %rax, %r9
leaq 0x18a07(%rip), %rsi     # 0x250c5
leaq 0x18950(%rip), %rdx     # 0x25015
leaq 0x16cc4(%rip), %rcx     # 0x23390
xorl %eax, %eax
movl $0x156, %r8d            # imm = 0x156
callq 0x3410
movq 0x228c0(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
jmp 0xc6ea
movq 0x228df(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
jmp 0xc6fb
movl $0x1, %edi
callq 0x3370
jmp 0xc707
jmp 0xc709
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x34d0
movq -0x418(%rbp), %rcx
leaq -0x1a8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
movl $0x10, %edx
callq 0x3330
jmp 0xc73d
leaq -0x1a9(%rbp), %rdi
callq 0x3300
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x34d0
movq -0x420(%rbp), %rcx
leaq -0x1d0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
movl $0x10, %edx
callq 0x3330
jmp 0xc77d
leaq -0x1d1(%rbp), %rdi
callq 0x3300
leaq -0x210(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x3120
jmp 0xc79e
leaq -0x230(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3120
jmp 0xc7b3
leaq -0x1f0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x210(%rbp), %rdx
leaq -0x230(%rbp), %rcx
callq 0x124e0
jmp 0xc7d6
leaq -0x230(%rbp), %rdi
callq 0x31a0
leaq -0x210(%rbp), %rdi
callq 0x31a0
leaq -0x1f0(%rbp), %rdi
callq 0x12e20
cmpq $0x1, %rax
je 0xc8b6
leaq 0x1899f(%rip), %rdi     # 0x251aa
xorl %eax, %eax
callq 0x3050
jmp 0xc814
movl $0x1, -0x234(%rbp)
jmp 0xd02e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1a9(%rbp), %rdi
callq 0x3300
jmp 0xd0cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1d1(%rbp), %rdi
callq 0x3300
jmp 0xd0c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd0b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc894
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x31a0
leaq -0x210(%rbp), %rdi
callq 0x31a0
jmp 0xd0b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd0a9
movq $0x0, -0x240(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3110
movq %rax, -0x438(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3110
movq %rax, -0x430(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x1f0(%rbp), %rdi
callq 0xf690
movq %rax, %rdi
callq 0x3110
movq -0x438(%rbp), %rdi
movq -0x430(%rbp), %rsi
movq %rax, %rcx
leaq -0x23e(%rbp), %r8
leaq -0x150(%rbp), %rdx
callq 0x3c60
movb %al, -0x421(%rbp)
jmp 0xc925
movb -0x421(%rbp), %al
testb $0x1, %al
jne 0xc950
jmp 0xc931
leaq 0x188ac(%rip), %rdi     # 0x251e4
xorl %eax, %eax
callq 0x3050
jmp 0xc941
movl $0x1, -0x234(%rbp)
jmp 0xd02e
movq -0x240(%rbp), %rdi
callq 0xd100
movq %rax, -0x440(%rbp)
jmp 0xc965
movq -0x440(%rbp), %rax
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
callq 0xd100
movq %rax, -0x448(%rbp)
jmp 0xc99a
movq -0x448(%rbp), %rax
movq %rax, -0x250(%rbp)
leaq 0x18873(%rip), %rdi     # 0x25222
leaq 0x18d0c(%rip), %rsi     # 0x256c2
callq 0x3360
movq %rax, -0x450(%rbp)
jmp 0xc9c4
movq -0x450(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rcx
leaq -0x150(%rbp), %rdi
movl $0x10, %esi
movl $0x1, %edx
callq 0x3450
jmp 0xc9f1
movq -0x258(%rbp), %rdi
callq 0x32a0
jmp 0xc9ff
jmp 0xca01
leaq -0x80(%rbp), %rdi
callq 0x3110
movq %rax, -0x460(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3110
movq -0x460(%rbp), %rdi
movq %rax, %rdx
leaq -0x24e(%rbp), %rcx
movq %rsp, %rax
leaq -0x188(%rbp), %rsi
movq %rsi, 0x10(%rax)
leaq -0x180(%rbp), %rsi
movq %rsi, 0x8(%rax)
leaq -0x170(%rbp), %rsi
movq %rsi, (%rax)
leaq -0x132(%rbp), %rsi
leaq -0x150(%rbp), %r8
leaq -0x160(%rbp), %r9
callq 0x3b60
movb %al, -0x451(%rbp)
jmp 0xca70
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0xcaf1
jmp 0xca7c
movq 0x2254d(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x468(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x468(%rbp), %rdi
movq %rax, %r9
leaq 0x18784(%rip), %rsi     # 0x2522e
leaq 0x18564(%rip), %rdx     # 0x25015
leaq 0x168d8(%rip), %rcx     # 0x23390
xorl %eax, %eax
movl $0x178, %r8d            # imm = 0x178
callq 0x3410
movq 0x224d4(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
jmp 0xcad6
movq 0x224f3(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
jmp 0xcae7
movl $0x1, %edi
callq 0x3370
jmp 0xcaf3
jmp 0xcaf5
leaq -0x279(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0x34d0
movq -0x470(%rbp), %rcx
leaq -0x278(%rbp), %rdi
leaq -0x160(%rbp), %rsi
movl $0x10, %edx
callq 0x3330
jmp 0xcb29
leaq -0x279(%rbp), %rdi
callq 0x3300
leaq -0x2a1(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x34d0
movq -0x478(%rbp), %rcx
leaq -0x2a0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
movl $0x10, %edx
callq 0x3330
jmp 0xcb69
leaq -0x2a1(%rbp), %rdi
callq 0x3300
leaq -0x2e0(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x3120
jmp 0xcb8a
leaq -0x300(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x3120
jmp 0xcb9f
leaq -0x2c0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x2e0(%rbp), %rdx
leaq -0x300(%rbp), %rcx
callq 0x124e0
jmp 0xcbc2
leaq -0x300(%rbp), %rdi
callq 0x31a0
leaq -0x2e0(%rbp), %rdi
callq 0x31a0
testb $0x1, -0xf0(%rbp)
je 0xcd97
movq $0x0, -0x308(%rbp)
movq -0x308(%rbp), %rax
movq %rax, -0x480(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x12e20
movq %rax, %rcx
movq -0x480(%rbp), %rax
cmpq %rcx, %rax
jae 0xcd95
leaq -0x329(%rbp), %rdi
movq %rdi, -0x488(%rbp)
callq 0x34d0
movq -0x488(%rbp), %rdx
leaq 0x186e1(%rip), %rsi     # 0x25321
leaq -0x328(%rbp), %rdi
callq 0x33e0
jmp 0xcc4e
movq -0x308(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0xf690
movq %rax, %rsi
leaq -0x350(%rbp), %rdi
callq 0x3120
jmp 0xcc72
leaq -0x328(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0xd1b0
jmp 0xcc87
leaq -0x350(%rbp), %rdi
callq 0x31a0
leaq -0x328(%rbp), %rdi
callq 0x31a0
leaq -0x329(%rbp), %rdi
callq 0x3300
movq -0x308(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x308(%rbp)
jmp 0xcbf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x279(%rbp), %rdi
callq 0x3300
jmp 0xd0a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x2a1(%rbp), %rdi
callq 0x3300
jmp 0xd09d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd091
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xcd33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x31a0
leaq -0x2e0(%rbp), %rdi
callq 0x31a0
jmp 0xd091
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xcd84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xcd78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x31a0
leaq -0x328(%rbp), %rdi
callq 0x31a0
leaq -0x329(%rbp), %rdi
callq 0x3300
jmp 0xd085
jmp 0xcd97
leaq -0x2c0(%rbp), %rdi
callq 0x12e20
cmpq $0x4, %rax
je 0xcdd6
movq -0x248(%rbp), %rsi
leaq 0x18576(%rip), %rdi     # 0x2532d
xorl %eax, %eax
callq 0x3050
jmp 0xcdc0
jmp 0xd000
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xd085
leaq -0x371(%rbp), %rdi
movq %rdi, -0x490(%rbp)
callq 0x34d0
movq -0x490(%rbp), %rcx
leaq -0x370(%rbp), %rdi
leaq -0x170(%rbp), %rsi
movl $0x10, %edx
callq 0x3330
jmp 0xce0a
leaq -0x371(%rbp), %rdi
callq 0x3300
leaq -0x399(%rbp), %rdi
movq %rdi, -0x498(%rbp)
callq 0x34d0
movq -0x498(%rbp), %rcx
leaq -0x398(%rbp), %rdi
leaq -0x180(%rbp), %rsi
movl $0x10, %edx
callq 0x3330
jmp 0xce4a
leaq -0x399(%rbp), %rdi
callq 0x3300
leaq -0x3c1(%rbp), %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x34d0
movq -0x4a0(%rbp), %rcx
leaq -0x3c0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
movl $0x8, %edx
callq 0x3330
jmp 0xce8a
leaq -0x3c1(%rbp), %rdi
callq 0x3300
leaq -0x2c0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf690
movq %rax, %rsi
leaq -0x3c0(%rbp), %rdi
callq 0x12e40
testb $0x1, %al
jne 0xcf06
leaq -0x2c0(%rbp), %rdi
movl $0x1, %esi
callq 0xf690
movq %rax, %rsi
leaq -0x398(%rbp), %rdi
callq 0x12e40
testb $0x1, %al
jne 0xcf06
leaq -0x2c0(%rbp), %rdi
movl $0x2, %esi
callq 0xf690
movq %rax, %rsi
leaq -0x370(%rbp), %rdi
callq 0x12e40
testb $0x1, %al
jne 0xcf06
jmp 0xcf89
leaq 0x18449(%rip), %rdi     # 0x25356
xorl %eax, %eax
callq 0x3050
jmp 0xcf16
jmp 0xcfbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x371(%rbp), %rdi
callq 0x3300
jmp 0xd085
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x399(%rbp), %rdi
callq 0x3300
jmp 0xcfef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3c1(%rbp), %rdi
callq 0x3300
jmp 0xcfe3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x31a0
jmp 0xcfe3
movq -0x248(%rbp), %rsi
leaq 0x18406(%rip), %rdi     # 0x2539d
xorl %eax, %eax
callq 0x3050
jmp 0xcfa0
movq -0x248(%rbp), %rsi
addq $0x20, %rsi
leaq 0x18412(%rip), %rdi     # 0x253c4
xorl %eax, %eax
callq 0x3050
jmp 0xcfbb
jmp 0xcfbd
leaq -0x3c0(%rbp), %rdi
callq 0x31a0
leaq -0x398(%rbp), %rdi
callq 0x31a0
leaq -0x370(%rbp), %rdi
callq 0x31a0
jmp 0xd000
leaq -0x398(%rbp), %rdi
callq 0x31a0
leaq -0x370(%rbp), %rdi
callq 0x31a0
jmp 0xd085
leaq -0x2c0(%rbp), %rdi
callq 0xf6b0
leaq -0x2a0(%rbp), %rdi
callq 0x31a0
leaq -0x278(%rbp), %rdi
callq 0x31a0
movl $0x0, -0x234(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0xf6b0
leaq -0x1d0(%rbp), %rdi
callq 0x31a0
leaq -0x1a8(%rbp), %rdi
callq 0x31a0
leaq -0x110(%rbp), %rdi
callq 0x31a0
leaq -0xf0(%rbp), %rdi
callq 0x10950
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x30(%rbp), %rdi
callq 0x31a0
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
leaq -0x2c0(%rbp), %rdi
callq 0xf6b0
leaq -0x2a0(%rbp), %rdi
callq 0x31a0
leaq -0x278(%rbp), %rdi
callq 0x31a0
leaq -0x1f0(%rbp), %rdi
callq 0xf6b0
leaq -0x1d0(%rbp), %rdi
callq 0x31a0
leaq -0x1a8(%rbp), %rdi
callq 0x31a0
leaq -0x110(%rbp), %rdi
callq 0x31a0
leaq -0xf0(%rbp), %rdi
callq 0x10950
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x30(%rbp), %rdi
callq 0x31a0
movq -0x58(%rbp), %rdi
callq 0x34b0