// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/aegis128l/ref/ecrypt.c
// Function: aegis128L_initialization
void aegis128L_initialization(const unsigned char *key, const unsigned char *iv, unsigned char *state)
{
       int i;
       unsigned char tmp[16];
       unsigned char constant[32] = {0x0,0x1,0x01,0x02,0x03,0x05,0x08,0x0d,0x15,0x22,0x37,0x59,0x90,0xe9,0x79,0x62,0xdb,0x3d,0x18,0x55,0x6d,0xc2,0x2f,0xf1,0x20,0x11,0x31,0x42,0x73,0xb5,0x28,0xdd};

       XOR128(state,  key,  iv);
       memcpy(state+16, constant+16, 16);
       memcpy(state+32, constant,    16);
       memcpy(state+48, constant+16, 16);
       XOR128(state+64, key, iv);
       XOR128(state+80, key, constant);
       XOR128(state+96, key, constant+16);
       XOR128(state+112,key, constant);

       for (i = 0; i < 10; i++)  {
             //state update function;
             memcpy(tmp, state+112, 16);

             AESROUND(state+112,state+96, state+112);
             AESROUND(state+96, state+80, state+96);
             AESROUND(state+80, state+64, state+80);
             AESROUND(state+64, state+48, state+64);
             AESROUND(state+48, state+32, state+48);
             AESROUND(state+32, state+16, state+32);
             AESROUND(state+16, state+0,  state+16);
             AESROUND(state+0,  tmp,      state+0);

             //message is used to update the state.
             XOR128(state, state, iv);
             XOR128(state+64, state+64, key);
       }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq 0x1c96(%rip), %rax      # 0x3000
movq %rax, (%rsp)
movq 0x1c93(%rip), %rax      # 0x3008
movq %rax, 0x8(%rsp)
movq 0x1c8f(%rip), %rax      # 0x3010
movq %rax, 0x10(%rsp)
movq 0x1c8b(%rip), %rax      # 0x3018
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rcx
movq 0x48(%rsp), %rax
xorq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x48(%rsp), %rax
xorq 0x8(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x40(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, 0x20(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x28(%rax)
movq 0x40(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x30(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x38(%rax)
movq 0x50(%rsp), %rax
movq (%rax), %rcx
movq 0x48(%rsp), %rax
xorq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x48(%rsp), %rax
xorq 0x8(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x50(%rsp), %rax
movq (%rax), %rcx
xorq (%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rcx
xorq 0x8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x50(%rsp), %rax
movq (%rax), %rcx
xorq 0x10(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rcx
xorq 0x18(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0x50(%rsp), %rax
movq (%rax), %rcx
xorq (%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rcx
xorq 0x8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x78(%rax)
movl $0x0, 0x3c(%rsp)
cmpl $0xa, 0x3c(%rsp)
jge 0x1654
movq 0x40(%rsp), %rax
movq 0x70(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x78(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x40(%rsp), %rdi
addq $0x70, %rdi
movq 0x40(%rsp), %rsi
addq $0x60, %rsi
movq 0x40(%rsp), %rdx
addq $0x70, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
addq $0x60, %rdi
movq 0x40(%rsp), %rsi
addq $0x50, %rsi
movq 0x40(%rsp), %rdx
addq $0x60, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
addq $0x50, %rdi
movq 0x40(%rsp), %rsi
addq $0x40, %rsi
movq 0x40(%rsp), %rdx
addq $0x50, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
addq $0x40, %rdi
movq 0x40(%rsp), %rsi
addq $0x30, %rsi
movq 0x40(%rsp), %rdx
addq $0x40, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
addq $0x30, %rdi
movq 0x40(%rsp), %rsi
addq $0x20, %rsi
movq 0x40(%rsp), %rdx
addq $0x30, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
addq $0x20, %rdi
movq 0x40(%rsp), %rsi
addq $0x10, %rsi
movq 0x40(%rsp), %rdx
addq $0x20, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
addq $0x10, %rdi
movq 0x40(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq $0x10, %rdx
callq 0x1050
movq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x1050
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movq 0x48(%rsp), %rax
xorq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x48(%rsp), %rax
xorq 0x8(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x40(%rax), %rcx
movq 0x50(%rsp), %rax
xorq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x40(%rsp), %rax
movq 0x48(%rax), %rcx
movq 0x50(%rsp), %rax
xorq 0x8(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x48(%rax)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x14ca
addq $0x58, %rsp
retq
nopl (%rax)