// File: /workspace/github_c_makefile_star2_O0/snow1eo[P]IPsec_IKEv2/ike.c
// Function: compute_keys
void compute_keys (void)
{
    encr_key_len = 0;
    prf_key_len = 0;
    integ_key_len = 0;
    acc_prf = 0;
    dh_group = 0;
    for (int i = 0; i < acc_proposal->num_transforms; i++)
    {
        if (acc_proposal->transforms[i].transform_type == ENCR)
        {
            acc_encr = acc_proposal->transforms[i].transform_ID;
            encr_key_len = get_key_len (&acc_proposal->transforms[i]) / 8;
            encr_block_len = get_block_len (acc_encr, encr_key_len) / 8;
            iv_len = get_iv_len (acc_encr, encr_key_len) / 8;
        }
        if (acc_proposal->transforms[i].transform_type == PRF)
        {
            acc_prf = acc_proposal->transforms[i].transform_ID;
            prf_key_len = get_key_len (&acc_proposal->transforms[i]) / 8;
        }
        if (acc_proposal->transforms[i].transform_type == INTEG)
        {
            acc_integ = acc_proposal->transforms[i].transform_ID;
            integ_key_len = get_key_len (&acc_proposal->transforms[i]) / 8;
        }
        if (acc_proposal->transforms[i].transform_type == DH_GR &&
            acc_proposal->transforms[i].transform_ID > dh_group)
            dh_group = acc_proposal->transforms[i].transform_ID;
            modp = get_modp (dh_group);
    }
    uint32_t offset = 0;
    uint32_t S_len = Ni_len + Nr_len;
    uint8_t *S = calloc (1, S_len);
    memcpy (S + offset, Ni.nonce_data, Ni_len);
    offset += Ni_len;
    memcpy (S + offset, Nr.nonce_data, Nr_len);
    offset += Nr_len;

    uint8_t *SKEYSEED = calloc (1, prf_key_len);
    prf_func (S, S_len, K, modp/8, SKEYSEED);

    free (K);

    uint16_t key_seq_len;
    key_seq_len = 2*encr_key_len + 
                  3*prf_key_len + 
                  2*integ_key_len;
    key_seq_len = key_seq_len/prf_key_len+1;
    uint8_t *key_seq = calloc (key_seq_len, prf_key_len);

    S_len = Ni_len + Nr_len + 2*sizeof (uint64_t)+1;
    S = realloc (S, S_len);
    memcpy (S + offset, SPIi, sizeof (uint64_t));
    offset += sizeof (uint64_t);
    memcpy (S + offset, SPIr, sizeof (uint64_t));

    offset = 0;
    S[S_len-1] = 1;
    prf_func (SKEYSEED, prf_key_len,
               S, S_len,
               key_seq + offset);
    S = realloc (S, S_len + prf_key_len);
    memcpy (S + prf_key_len, S, S_len-1);
    memcpy (S, key_seq + offset, prf_key_len);
    offset += prf_key_len;
    for (int i = 1; i < key_seq_len; i++)
    {
        S[prf_key_len + S_len-1] = (uint8_t) (i+1);
        prf_func (SKEYSEED, prf_key_len,
                   S, S_len + prf_key_len,
                   key_seq + offset);
        memcpy (S, key_seq + offset, prf_key_len);
        offset += prf_key_len;
    }

    SK_d =  calloc (1, prf_key_len);
    SK_ai = calloc (1, integ_key_len);
    SK_ar = calloc (1, integ_key_len);
    SK_ei = calloc (1, encr_key_len);
    SK_er = calloc (1, encr_key_len);
    SK_pi = calloc (1, prf_key_len);
    SK_pr = calloc (1, prf_key_len);

    offset = 0;
    memcpy (SK_d,  key_seq + offset, prf_key_len);
    offset += prf_key_len;
    memcpy (SK_ai, key_seq + offset, integ_key_len);
    offset += integ_key_len;
    memcpy (SK_ar, key_seq + offset, integ_key_len);
    offset += integ_key_len;
    memcpy (SK_ei, key_seq + offset, encr_key_len);
    offset += encr_key_len;
    memcpy (SK_er, key_seq + offset, encr_key_len);
    offset += encr_key_len;
    memcpy (SK_pi, key_seq + offset, prf_key_len);
    offset += prf_key_len;
    memcpy (SK_pr, key_seq + offset, prf_key_len);
    offset += prf_key_len;

    // dbg_print ();

    free (S);
    free (key_seq);
    free (SKEYSEED);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movw $0x0, 0xa697(%rip)      # 0x12648
movw $0x0, 0xa690(%rip)      # 0x1264a
movw $0x0, 0xa63d(%rip)      # 0x12600
movw $0x0, 0xa680(%rip)      # 0x1264c
movw $0x0, 0xa5af(%rip)      # 0x12584
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movq 0xa5c2(%rip), %rcx      # 0x125a8
movzbl 0x7(%rcx), %ecx
cmpl %ecx, %eax
jge 0x8203
movq 0xa5af(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
jne 0x80aa
movq 0xa58c(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movw 0x6(%rax), %ax
movw %ax, 0xa618(%rip)       # 0x1264e
movq 0xa56b(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rdi
movslq -0x4(%rbp), %rax
imulq $0x12, %rax, %rax
addq %rax, %rdi
callq 0x30f0
movl $0x8, %ecx
cltd
idivl %ecx
movw %ax, 0xa5e8(%rip)       # 0x12648
movw 0xa5e7(%rip), %ax       # 0x1264e
movzwl %ax, %edi
movzwl 0xa5d7(%rip), %esi      # 0x12648
callq 0x31f0
movl $0x8, %ecx
cltd
idivl %ecx
movw %ax, 0xa58b(%rip)       # 0x12610
movw 0xa5c2(%rip), %ax       # 0x1264e
movzwl %ax, %edi
movzwl 0xa5b2(%rip), %esi      # 0x12648
callq 0x34f0
movl $0x8, %ecx
cltd
idivl %ecx
movw %ax, 0xa568(%rip)       # 0x12612
movq 0xa4f7(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
cmpl $0x2, %eax
jne 0x8114
movq 0xa4d8(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movw 0x6(%rax), %ax
movw %ax, 0xa562(%rip)       # 0x1264c
movq 0xa4b7(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rdi
movslq -0x4(%rbp), %rax
imulq $0x12, %rax, %rax
addq %rax, %rdi
callq 0x30f0
movl $0x8, %ecx
cltd
idivl %ecx
movw %ax, 0xa536(%rip)       # 0x1264a
movq 0xa48d(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
cmpl $0x3, %eax
jne 0x817e
movq 0xa46e(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movw 0x6(%rax), %ax
movw %ax, 0xa4fc(%rip)       # 0x12650
movq 0xa44d(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rdi
movslq -0x4(%rbp), %rax
imulq $0x12, %rax, %rax
addq %rax, %rdi
callq 0x30f0
movl $0x8, %ecx
cltd
idivl %ecx
movw %ax, 0xa482(%rip)       # 0x12600
movq 0xa423(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movzbl 0x4(%rax), %eax
cmpl $0x4, %eax
jne 0x81e3
movq 0xa404(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
movzwl 0xa3c6(%rip), %ecx      # 0x12584
cmpl %ecx, %eax
jle 0x81e3
movq 0xa3df(%rip), %rax      # 0x125a8
movq 0x10(%rax), %rax
movslq -0x4(%rbp), %rcx
imulq $0x12, %rcx, %rcx
addq %rcx, %rax
movw 0x6(%rax), %ax
movw %ax, 0xa3a1(%rip)       # 0x12584
movzwl 0xa39a(%rip), %edi      # 0x12584
callq 0x3210
movl %eax, 0xa393(%rip)      # 0x12588
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x7fdc
movl $0x0, -0x8(%rbp)
movl 0xa37c(%rip), %eax      # 0x1258c
addl 0xa3d6(%rip), %eax      # 0x125ec
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0x8(%rbp), %eax
addq %rax, %rdi
movq 0xa27f(%rip), %rsi      # 0x124bc
movl 0xa349(%rip), %eax      # 0x1258c
movl %eax, %edx
callq 0x32c0
movl 0xa33c(%rip), %eax      # 0x1258c
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq -0x18(%rbp), %rdi
movl -0x8(%rbp), %eax
addq %rax, %rdi
movq 0xa261(%rip), %rsi      # 0x124c8
movl 0xa37f(%rip), %eax      # 0x125ec
movl %eax, %edx
callq 0x32c0
movl 0xa372(%rip), %eax      # 0x125ec
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movzwl 0xa3c3(%rip), %eax      # 0x1264a
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
movq 0xa393(%rip), %rdx      # 0x12638
movl 0xa2dd(%rip), %ecx      # 0x12588
shrl $0x3, %ecx
movq -0x20(%rbp), %r8
callq 0x3420
movq 0xa37a(%rip), %rdi      # 0x12638
callq 0x3060
movzwl 0xa37e(%rip), %eax      # 0x12648
shll %eax
movzwl 0xa377(%rip), %ecx      # 0x1264a
imull $0x3, %ecx, %ecx
addl %ecx, %eax
movzwl 0xa321(%rip), %ecx      # 0x12600
shll %ecx
addl %ecx, %eax
movw %ax, -0x22(%rbp)
movzwl -0x22(%rbp), %eax
movzwl 0xa358(%rip), %ecx      # 0x1264a
cltd
idivl %ecx
addl $0x1, %eax
movw %ax, -0x22(%rbp)
movzwl -0x22(%rbp), %eax
movl %eax, %edi
movzwl 0xa341(%rip), %eax      # 0x1264a
movl %eax, %esi
callq 0x3250
movq %rax, -0x30(%rbp)
movl 0xa272(%rip), %eax      # 0x1258c
addl 0xa2cc(%rip), %eax      # 0x125ec
movl %eax, %eax
addq $0x10, %rax
addq $0x1, %rax
movl %eax, -0xc(%rbp)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x3370
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl -0x8(%rbp), %ecx
movq 0xa0d3(%rip), %rdx      # 0x12420
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx)
movl -0x8(%rbp), %eax
addq $0x8, %rax
movl %eax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movl -0x8(%rbp), %ecx
movq 0xa0bc(%rip), %rdx      # 0x12428
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx)
movl $0x0, -0x8(%rbp)
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movq -0x20(%rbp), %rdi
movzwl 0xa2b5(%rip), %esi      # 0x1264a
movq -0x18(%rbp), %rdx
movl -0xc(%rbp), %ecx
movq -0x30(%rbp), %r8
movl -0x8(%rbp), %eax
addq %rax, %r8
callq 0x3420
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %eax
movzwl 0xa291(%rip), %ecx      # 0x1264a
addl %ecx, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3370
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movzwl 0xa277(%rip), %eax      # 0x1264a
cltq
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x32c0
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa24a(%rip), %eax      # 0x1264a
movl %eax, %edx
callq 0x32c0
movzwl 0xa23c(%rip), %eax      # 0x1264a
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jge 0x84a5
movl -0x34(%rbp), %eax
addl $0x1, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movzwl 0xa211(%rip), %ecx      # 0x1264a
addl -0xc(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rdi
movzwl 0xa1fb(%rip), %esi      # 0x1264a
movq -0x18(%rbp), %rdx
movl -0xc(%rbp), %ecx
movzwl 0xa1ed(%rip), %eax      # 0x1264a
addl %eax, %ecx
movq -0x30(%rbp), %r8
movl -0x8(%rbp), %eax
addq %rax, %r8
callq 0x3420
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa1c7(%rip), %eax      # 0x1264a
movl %eax, %edx
callq 0x32c0
movzwl 0xa1b9(%rip), %eax      # 0x1264a
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x841b
movzwl 0xa19e(%rip), %eax      # 0x1264a
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa199(%rip)      # 0x12658
movzwl 0xa13a(%rip), %eax      # 0x12600
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa147(%rip)      # 0x12620
movzwl 0xa120(%rip), %eax      # 0x12600
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa14d(%rip)      # 0x12640
movzwl 0xa14e(%rip), %eax      # 0x12648
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa10b(%rip)      # 0x12618
movzwl 0xa134(%rip), %eax      # 0x12648
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa109(%rip)      # 0x12630
movzwl 0xa11c(%rip), %eax      # 0x1264a
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa0c7(%rip)      # 0x12608
movzwl 0xa102(%rip), %eax      # 0x1264a
movl %eax, %esi
movl $0x1, %edi
callq 0x3250
movq %rax, 0xa0cd(%rip)      # 0x12628
movl $0x0, -0x8(%rbp)
movq 0xa0ef(%rip), %rdi      # 0x12658
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa0d0(%rip), %eax      # 0x1264a
movl %eax, %edx
callq 0x32c0
movzwl 0xa0c2(%rip), %eax      # 0x1264a
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq 0xa08b(%rip), %rdi      # 0x12620
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa05a(%rip), %eax      # 0x12600
movl %eax, %edx
callq 0x32c0
movzwl 0xa04c(%rip), %eax      # 0x12600
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq 0xa07f(%rip), %rdi      # 0x12640
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa02e(%rip), %eax      # 0x12600
movl %eax, %edx
callq 0x32c0
movzwl 0xa020(%rip), %eax      # 0x12600
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq 0xa02b(%rip), %rdi      # 0x12618
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa04a(%rip), %eax      # 0x12648
movl %eax, %edx
callq 0x32c0
movzwl 0xa03c(%rip), %eax      # 0x12648
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq 0xa017(%rip), %rdi      # 0x12630
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0xa01e(%rip), %eax      # 0x12648
movl %eax, %edx
callq 0x32c0
movzwl 0xa010(%rip), %eax      # 0x12648
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq 0x9fc3(%rip), %rdi      # 0x12608
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0x9ff4(%rip), %eax      # 0x1264a
movl %eax, %edx
callq 0x32c0
movzwl 0x9fe6(%rip), %eax      # 0x1264a
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq 0x9fb7(%rip), %rdi      # 0x12628
movq -0x30(%rbp), %rsi
movl -0x8(%rbp), %eax
addq %rax, %rsi
movzwl 0x9fc8(%rip), %eax      # 0x1264a
movl %eax, %edx
callq 0x32c0
movzwl 0x9fba(%rip), %eax      # 0x1264a
addl -0x8(%rbp), %eax
movl %eax, -0x8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3060
movq -0x30(%rbp), %rdi
callq 0x3060
movq -0x20(%rbp), %rdi
callq 0x3060
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)