// File: /workspace/github_c_makefile_star2_O0/dubeyalok7[P]crypto-algo/des/des/des.c
// Function: rounds
void rounds(uint64_t *data, uint64_t key)
{
  uint64_t right_block = 0;
  uint64_t right_block_tmp = 0;

  // block expansion
  for(int i=0; i<48; i++)
    addbit(&right_block, *data, (EP[i] + 31), i);

  // xor with key
  right_block = right_block^key;

  // substitution
  int coordx, coordy;
  uint64_t substitued;

  for(int i=0; i<8; i++)
  {
    coordx = ((right_block << 6 * i) & FIRSTBIT) == FIRSTBIT ? 2:0;

    coordy = 0;
    for(int j=1; j<5; j++) {
      if(((right_block<<(6*i + 5)) & FIRSTBIT) == FIRSTBIT)
        coordy += 2^(4-j);
    }

    substitued = sbox[i][coordx][coordy];
    substitued  = substitued << (60 - (4*i));
    right_block_tmp += substitued;
  }

  //Right Block completed
  right_block = right_block_tmp;

  //Permuation
  right_block_tmp = 0;

  for(int i=0; i<32; i++)
    addbit(&right_block_tmp, right_block, PF[i]-1, i);

  right_block = right_block_tmp;

  // xor with left block
  right_block = right_block ^ *data;

  //combine the new block and the right block
  *data = (*data<< 32) + (right_block>>32);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x30, -0x24(%rbp)
jge 0x15e0
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movslq -0x24(%rbp), %rcx
leaq 0xe51(%rip), %rax       # 0x2410
movq (%rax,%rcx,8), %rax
addq $0x1f, %rax
movl %eax, %edx
movl -0x24(%rbp), %ecx
leaq -0x18(%rbp), %rdi
callq 0x11e0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x15a7
movq -0x18(%rbp), %rax
xorq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x8, -0x3c(%rbp)
jge 0x16ee
movq -0x18(%rbp), %rdx
imull $0x6, -0x3c(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
shlq %cl, %rdx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorl %eax, %eax
movl $0x2, %ecx
cmpq %rsi, %rdx
cmovel %ecx, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x1, -0x40(%rbp)
cmpl $0x5, -0x40(%rbp)
jge 0x1691
movq -0x18(%rbp), %rax
imull $0x6, -0x3c(%rbp), %ecx
addl $0x5, %ecx
movl %ecx, %ecx
shlq %cl, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
andq %rcx, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, %rax
jne 0x1684
movl $0x4, %eax
subl -0x40(%rbp), %eax
xorl $0x2, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x1686
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1641
movslq -0x3c(%rbp), %rcx
leaq 0xff4(%rip), %rax       # 0x2690
shlq $0x9, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %edx
shll $0x2, %edx
movl $0x3c, %ecx
subl %edx, %ecx
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x15f3
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x20, -0x44(%rbp)
jge 0x173b
movq -0x18(%rbp), %rsi
movslq -0x44(%rbp), %rcx
leaq 0xe76(%rip), %rax       # 0x2590
movq (%rax,%rcx,8), %rax
subq $0x1, %rax
movl %eax, %edx
movl -0x44(%rbp), %ecx
leaq -0x20(%rbp), %rdi
callq 0x11e0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1705
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
xorq (%rcx), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq -0x18(%rbp), %rax
shrq $0x20, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)