// File: lmclaramunt[P]AES-Crypto/Cipher.cpp
// Function: Cipher::getMessageLength(unsigned char**, bool, bool)
void Cipher::getMessageLength(unsigned char** s, bool encrypting, bool padding){
    *s = new  unsigned char[16];
    ifstream text(*textPath, ios::binary);
    text.seekg(0, ios::end);
    int length = text.tellg();                     //Get the file's length
    if(encrypting){                                //Length will be the ciphertext length
        length += 32;                              //Add IV and MAC's Tag length
        if(padding) 
            length += (length%16 == 0) ? 16 : (length%16);
    }
    unsigned char bytes[sizeof length];
    std::copy(static_cast<const unsigned char*>(static_cast<const void*>(&length)),
          static_cast<const unsigned char*>(static_cast<const void*>(&length)) + sizeof length,
          bytes);
    for(int i = 0; i < sizeof length; i++)      //First 4 bytes will have length values
        (*s)[i] = bytes[i];
    for(int i = sizeof length; i < 16; i++)     //The remained will be initialzed to zero
        (*s)[i] = 0x00;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %cl
movb %cl, -0x11(%rbp)
andb $0x1, %al
movb %al, -0x12(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
movl $0x10, %edi
callq 0x3030
movq %rax, %rdx
movq -0x260(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rdx, (%rcx)
movq 0x28(%rax), %rsi
leaq -0x220(%rbp), %rdi
movq %rdi, -0x258(%rbp)
movl $0x4, %edx
callq 0x3430
movq -0x258(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x3370
jmp 0x9e3b
leaq -0x220(%rbp), %rdi
callq 0x34b0
movq %rdx, -0x270(%rbp)
movq %rax, -0x268(%rbp)
jmp 0x9e57
movq -0x270(%rbp), %rax
movq -0x268(%rbp), %rcx
movq %rcx, -0x240(%rbp)
movq %rax, -0x238(%rbp)
leaq -0x240(%rbp), %rdi
callq 0xb000
movq %rax, -0x278(%rbp)
jmp 0x9e88
movq -0x278(%rbp), %rax
movl %eax, -0x230(%rbp)
testb $0x1, -0x11(%rbp)
je 0x9f21
movl -0x230(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x230(%rbp)
testb $0x1, -0x12(%rbp)
je 0x9f1f
movl -0x230(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x9ed4
movl $0x10, %edx
movl %edx, -0x27c(%rbp)
jmp 0x9ee8
movl -0x230(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %edx, -0x27c(%rbp)
movl -0x27c(%rbp), %eax
addl -0x230(%rbp), %eax
movl %eax, -0x230(%rbp)
jmp 0x9f1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3060
jmp 0x9fcf
jmp 0x9f21
leaq -0x22c(%rbp), %rsi
leaq -0x230(%rbp), %rdi
leaq -0x244(%rbp), %rdx
callq 0xb6e0
jmp 0x9f3d
movl $0x0, -0x248(%rbp)
movslq -0x248(%rbp), %rax
cmpq $0x4, %rax
jae 0x9f84
movslq -0x248(%rbp), %rax
movb -0x244(%rbp,%rax), %dl
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x248(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x248(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x248(%rbp)
jmp 0x9f47
movl $0x4, -0x24c(%rbp)
cmpl $0x10, -0x24c(%rbp)
jge 0x9fba
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x24c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x24c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24c(%rbp)
jmp 0x9f8e
leaq -0x220(%rbp), %rdi
callq 0x3060
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x228(%rbp), %rdi
callq 0x34d0
nopl (%rax,%rax)