LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: Listen(CSocket*, int)
bool Listen(CSocket *socket, int port)
{
  if (!socket->Socket())
  {
    return false;
  }

  if (!socket->Bind((uint16_t)port))
  {
    return false;
  }

  if (!socket->Listen())
  {
    return false;
  }

  CSocket sock;
  if (!socket->Accept(sock))
  {
    return false;
  }

  socket->AttachFrom(sock);
  sock.Detach();

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
callq 0x3818
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2090
movl %eax, (%rbx)
cmpl $-0x1, %eax
je 0x3a75
leaq 0x18(%rsp), %r15
leaq 0x2993(%rip), %rdx      # 0x63a6
leaq 0x8(%rsp), %r14
movq %r15, -0x10(%r15)
movq %r14, %rdi
movq %rdx, %rsi
callq 0x3940
movzwl %bp, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x52fa
movq 0x8(%rsp), %rdi
movl %eax, %ebp
cmpq %r15, %rdi
je 0x3a46
callq 0x2210
testb %bpl, %bpl
je 0x3a75
movl (%rbx), %edi
movl $0x5, %esi
callq 0x2280
testl %eax, %eax
js 0x3a75
movl (%rbx), %edi
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edx, %edx
callq 0x20c0
cmpl $-0x1, %eax
je 0x3a78
movb $0x1, %r14b
movl %eax, (%rbx)
jmp 0x3a78
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
movq %rax, %rbx
cmpq %r15, %rdi
je 0x3a98
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: Connect(CSocket*, char const*, int)
bool Connect(CSocket *socket, const char *address, int port)
{
  for (auto i = 0; i < 1000; i++)
  {
    if (!socket->Socket())
    {
      return false;
    }
    if (socket->Connect(address, (uint16_t)port, TIMEOUT_MS))
    {
      return true;
    }
    usleep(20);
  }

  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r13d
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
callq 0x3818
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2090
movl %eax, (%r14)
xorl %ebx, %ebx
cmpl $-0x1, %eax
je 0x3b6d
movb $0x1, %bpl
leaq 0x18(%rsp), %r15
movzwl %r13w, %r13d
movq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
movq %r15, %rdi
callq 0x2100
movl $0x2710, %ecx           # imm = 0x2710
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x53b6
movq 0x18(%rsp), %rdi
movl %eax, %r12d
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3b28
callq 0x2210
testb %r12b, %r12b
jne 0x3b71
movl $0x14, %edi
callq 0x2330
cmpl $0x3e7, %ebx            # imm = 0x3E7
setb %bpl
je 0x3b75
movq %r14, %rdi
callq 0x3818
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2090
incl %ebx
movl %eax, (%r14)
cmpl $-0x1, %eax
jne 0x3aec
xorl %eax, %eax
jmp 0x3b75
xorl %ebp, %ebp
jmp 0x3b78
movb $0x1, %al
jmp 0x3b75
andb %al, %bpl
andb $0x1, %bpl
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
movq %rax, %rbx
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3ba4
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: SenderOTCorrelation::ReadFromFile(std::basic_ifstream<char, std::char_traits<char>>&, unsigned char)
void SenderOTCorrelation::ReadFromFile(ifstream &fin, uint8_t bitsPerFSM)
{
  fin.read((char *)&N, sizeof(N));
  fin.read((char *)&K, sizeof(K));

  blindingFactors = new uint8_t[K * N];

  if (store_sOT_as_key == 1){

    uint8_t keyBuf[AESContext::AES_KEY_LEN];
    fin.read((char *)keyBuf, AESContext::AES_KEY_LEN);

    msgKey.Init(keyBuf);

    msgKey.FillBuffer((uint8_t *)blindingFactors, N * K * sizeof(uint8_t), 0);
  }
  else{
    uint64_t packedLength = packLength(N * K, bitsPerFSM);

    uint8_t *packedBlindingFactors = new uint8_t[packedLength];

    fin.read((char *)packedBlindingFactors, sizeof(uint8_t) * packedLength);

    Unpack(bitsPerFSM, N * K, packedBlindingFactors, blindingFactors);
    delete[] packedBlindingFactors;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r15
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
movq %rdi, %r14
movq %r15, %rdi
callq 0x22f0
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x22f0
movzbl (%r14), %r12d
imull 0x4(%r14), %r12d
movq %r12, %rdi
callq 0x2030
movl %ebx, %r13d
imulq %r12, %r13
movq %rax, 0x120(%r14)
addq $0x7, %r13
shrq $0x3, %r13
movq %r13, %rdi
callq 0x2030
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x22f0
movzbl (%r14), %esi
movq 0x120(%r14), %rcx
movl %ebx, %edi
movq %r12, %rdx
imull 0x4(%r14), %esi
callq 0x48b8
movq %r12, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2300
nop
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReceiverOTCorrelation::ReadFromFile(std::basic_ifstream<char, std::char_traits<char>>&, unsigned char)
void ReceiverOTCorrelation::ReadFromFile(ifstream &fin, uint8_t bitsPerFSM)
{

  fin.read((char *)&N, sizeof(N));
  fin.read((char *)&K, sizeof(K));

  uint64_t packedLength = packLength(N, bitsPerFSM);

  uint8_t *packedBlindingFactors = new uint8_t[packedLength];
  blindingFactors = new uint8_t[N];

  fin.read((char *)packedBlindingFactors, sizeof(uint8_t) * packedLength);

  Unpack(bitsPerFSM, N, packedBlindingFactors, blindingFactors);
  delete[] packedBlindingFactors;

  uint8_t keyBuf[AESContext::AES_KEY_LEN];
  fin.read((char *)keyBuf, AESContext::AES_KEY_LEN);  

  choiceKey.Init(keyBuf);


  ComputeChoiceBits();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r14
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
movq %rdi, %rbx
movq %r14, %rdi
callq 0x22f0
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22f0
movl 0x4(%rbx), %r15d
movl %ebp, %r12d
imulq %r15, %r12
addq $0x7, %r12
shrq $0x3, %r12
movq %r12, %rdi
callq 0x2030
movq %r15, %rdi
movq %rax, %r13
callq 0x2030
movq %rax, 0x128(%rbx)
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x22f0
movl 0x4(%rbx), %esi
movq 0x128(%rbx), %rcx
movl %ebp, %edi
movq %r13, %rdx
callq 0x48b8
movq %r13, %rdi
callq 0x2300
movl $0x10, %edx
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x22f0
leaq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x5a48
movq %rbx, %rdi
callq 0x4246
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: CreateOTCorrelation(SenderOTCorrelation&, ReceiverOTCorrelation&, unsigned char, unsigned char)
void CreateOTCorrelation(SenderOTCorrelation &sc,
                         ReceiverOTCorrelation &rc, uint8_t bitsPerFSMROT, uint8_t bitsPerFSMSOT)
{
  if ((sc.N != rc.N) ||
      (sc.K != rc.K))
  {
    throw "sender/receiver correlation type mismatch";
  }

  uint8_t K = rc.K;
  uint32_t N = rc.N;

  AESContext senderKey;
  senderKey.FillBuffer((uint8_t *)sc.blindingFactors, N * K * sizeof(uint8_t), 0);

  for (int i = 0; i < N * K; i++){
    sc.blindingFactors[i] &= (uint8_t)((1 << bitsPerFSMSOT) - 1);
  }
  
  AESContext receiverKey;
  receiverKey.FillBuffer((uint8_t *)rc.choices, N, 0);

  sc.msgKey = senderKey;
  rc.choiceKey = receiverKey;

  for (uint32_t i = 0; i < N; i++)
  {
    rc.choices[i] %= K;
    rc.blindingFactors[i] = sc.blindingFactors[i * K + rc.choices[i]] & ((uint8_t) (1 << bitsPerFSMROT) - 1);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl 0x4(%rdi), %r15d
movl %ecx, 0xc(%rsp)
movl %edx, 0x8(%rsp)
cmpl 0x4(%rsi), %r15d
jne 0x3fff
movb (%rdi), %r12b
movzbl (%rsi), %ebp
movq %rsi, %rbx
movq %rdi, %r14
cmpb %bpl, %r12b
jne 0x3fff
leaq 0x120(%rsp), %rdi
callq 0x581c
movq 0x120(%r14), %rsi
movl %r15d, %r13d
imull %ebp, %r13d
leaq 0x120(%rsp), %rdi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x5d44
testl %r13d, %r13d
je 0x3f32
movl 0xc(%rsp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edx, %edx
shlxl %ecx, %eax, %eax
movl %r13d, %ecx
notb %al
movq 0x120(%r14), %rsi
andb %al, (%rsi,%rdx)
incq %rdx
cmpq %rdx, %rcx
jne 0x3f20
leaq 0x10(%rsp), %rdi
callq 0x581c
movq 0x120(%rbx), %rsi
leaq 0x10(%rsp), %rdi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x5d44
leaq 0x10(%r14), %rdi
leaq 0x120(%rsp), %rsi
movl $0x110, %edx            # imm = 0x110
callq 0x21b0
leaq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %rsi
movl $0x110, %edx            # imm = 0x110
callq 0x21b0
testq %r15, %r15
je 0x3fd6
movl 0x8(%rsp), %ecx
movl $0x1, %eax
xorl %edx, %edx
xorl %esi, %esi
shlxl %ecx, %eax, %ecx
decb %cl
movq 0x120(%rbx), %rdi
movzbl (%rdi,%rsi), %eax
divb %r12b
movzbl %ah, %eax
movb %al, (%rdi,%rsi)
movq 0x120(%rbx), %rdi
movq 0x120(%r14), %rax
movq 0x128(%rbx), %r8
movzbl (%rdi,%rsi), %edi
addl %edx, %edi
addl %ebp, %edx
movb (%rax,%rdi), %al
andb %cl, %al
movb %al, (%r8,%rsi)
incq %rsi
cmpq %rsi, %r15
jne 0x3f94
leaq 0x10(%rsp), %rdi
callq 0x5bea
leaq 0x120(%rsp), %rdi
callq 0x5bea
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2120
movq 0x4fb0(%rip), %rsi      # 0x8fc0
leaq 0x24d2(%rip), %rcx      # 0x64e9
movq %rax, %rdi
xorl %edx, %edx
movq %rcx, (%rax)
callq 0x23d0
leaq 0x10(%rsp), %rdi
movq %rax, %rbx
callq 0x5bea
jmp 0x4038
jmp 0x4035
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x5bea
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ConstructOTReceiverMsg(unsigned char*, ReceiverOTCorrelation const&, unsigned char const*, unsigned int)
void ConstructOTReceiverMsg(uint8_t *receiverMsg, const ReceiverOTCorrelation &rc,
                            const uint8_t *inputArr, uint32_t nOTs)
{
  if (nOTs > rc.N)
  {
    throw "insufficient number of OT correlations";
  }

  for (int i = 0; i < nOTs; i++)
  {
    receiverMsg[i] = (rc.choices[i] - inputArr[i] + rc.K) % rc.K;
  }
}

// Assembly:
pushq %rax
cmpl %ecx, 0x4(%rsi)
jb 0x408d
testl %ecx, %ecx
je 0x408b
movq %rdx, %r8
movl %ecx, %ecx
xorl %r9d, %r9d
movq 0x120(%rsi), %rax
movzbl (%r8,%r9), %edx
movzbl (%rsi), %r10d
movzbl (%rax,%r9), %eax
subl %edx, %eax
addl %r10d, %eax
cwtd
idivw %r10w
movb %dl, (%rdi,%r9)
incq %r9
cmpq %r9, %rcx
jne 0x405f
popq %rax
retq
movl $0x8, %edi
callq 0x2120
movq 0x4f22(%rip), %rsi      # 0x8fc0
leaq 0x246e(%rip), %rcx      # 0x6513
movq %rax, %rdi
xorl %edx, %edx
movq %rcx, (%rax)
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ConstructOTSenderMsg(unsigned char*, SenderOTCorrelation const&, unsigned char const*, unsigned char*, unsigned int, unsigned char)
void ConstructOTSenderMsg(uint8_t *senderMsg, const SenderOTCorrelation &sc,
                          const uint8_t *msgs, uint8_t *receiverArr, uint32_t nOTs, uint8_t bitsPerMsg)
{
  if (nOTs > sc.N)
  {
    throw "insufficient number of OT correlations";
  }

  memcpy(senderMsg, msgs, nOTs * sc.K * sizeof(uint8_t));
  for (int i = 0; i < nOTs; i++)
  {
    for (int j = 0; j < sc.K; j++)
    {
      senderMsg[sc.K * i + j] ^= sc.blindingFactors[sc.K * i + ((j + receiverArr[i]) % sc.K)];
      senderMsg[sc.K * i + j] &= (uint8_t)(1 << bitsPerMsg) - 1;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpl %r8d, 0x4(%rsi)
jb 0x416d
movzbl (%rsi), %eax
movq %rsi, %r14
movl %r9d, %r12d
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdi, %r15
movq %rdx, %rsi
imull %r8d, %eax
movq %rax, %rdx
callq 0x21b0
testl %ebp, %ebp
je 0x4164
movb (%r14), %dl
movl $0x1, %eax
movl %ebp, %esi
xorl %edi, %edi
shlxl %r12d, %eax, %ecx
decb %cl
xorl %r8d, %r8d
testb %dl, %dl
je 0x415a
movzbl %dl, %eax
movq %r15, %r9
movl %eax, %r12d
movl %eax, %r11d
movzbl (%rbx,%rdi), %eax
movq 0x120(%r14), %r10
movzbl %dl, %ebp
imull %edi, %r12d
xorl %edx, %edx
imulq %rdi, %r11
addl %r8d, %eax
divw %bp
incl %r8d
movzwl %dx, %eax
addq %r12, %rax
movb (%r10,%rax), %al
xorb %al, (%r9,%r11)
movzbl (%r14), %eax
imulq %rdi, %rax
andb %cl, (%r9,%rax)
incq %r9
movb (%r14), %dl
movzbl %dl, %eax
cmpl %eax, %r8d
jb 0x4109
jmp 0x415c
xorl %edx, %edx
incq %rdi
cmpq %rsi, %rdi
jne 0x40fc
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2120
movq 0x4e42(%rip), %rsi      # 0x8fc0
leaq 0x238e(%rip), %rcx      # 0x6513
movq %rax, %rdi
xorl %edx, %edx
movq %rcx, (%rax)
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: RecoverReceiverMsg(unsigned char*, ReceiverOTCorrelation const&, unsigned char*, unsigned char*, unsigned int, unsigned char, unsigned char)
void RecoverReceiverMsg(uint8_t *msgs, const ReceiverOTCorrelation &rc,
                        uint8_t *inputArr, uint8_t *senderMsg, uint32_t nOTs, uint8_t bitsPerMsg, uint8_t bitsPerFSM)
{
  if (nOTs > rc.N) {
    throw "insufficient number of OT correlations";
  }

  memcpy(msgs, rc.blindingFactors, nOTs * sizeof(uint8_t));
  for (int i = 0; i < nOTs; i++) {
      msgs[i] ^= (senderMsg[rc.K*i + inputArr[i]] & ((uint8_t) (1 << bitsPerFSM) - 1));
      msgs[i] &= (uint8_t) (1 << bitsPerMsg) - 1;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, 0x4(%rsp)
cmpl %r8d, 0x4(%rsi)
jb 0x4221
movq %rsi, %r15
movq 0x128(%rsi), %rsi
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r14
movl %r8d, %r13d
movq %r13, %rdx
movq %rdi, %r12
callq 0x21b0
testl %ebp, %ebp
je 0x4212
movb 0x40(%rsp), %al
movl 0x4(%rsp), %edx
movl $0x1, %ecx
shlxl %eax, %ecx, %eax
shlxl %edx, %ecx, %ecx
xorl %edx, %edx
decb %al
decb %cl
movzbl (%r15), %esi
movzbl (%r14,%rdx), %edi
imull %edx, %esi
addl %esi, %edi
movb (%rbx,%rdi), %sil
andb %al, %sil
xorb (%r12,%rdx), %sil
andb %cl, %sil
movb %sil, (%r12,%rdx)
incq %rdx
cmpq %rdx, %r13
jne 0x41ea
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2120
movq 0x4d8e(%rip), %rsi      # 0x8fc0
leaq 0x22da(%rip), %rcx      # 0x6513
movq %rax, %rdi
xorl %edx, %edx
movq %rcx, (%rax)
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReceiverOTCorrelation::ComputeChoiceBits()
void ReceiverOTCorrelation::ComputeChoiceBits()
{
  choices = new uint8_t[N];
  
  choiceKey.FillBuffer((uint8_t *)choices, N, 0);

  for (uint32_t i = 0; i < N; i++)
  {
    choices[i] %= K;
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0x4(%rdi), %r14d
movq %rdi, %rbx
movq %r14, %rdi
callq 0x2030
leaq 0x10(%rbx), %rdi
movq %rax, 0x120(%rbx)
movq %rax, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x5d44
cmpl $0x0, 0x4(%rbx)
je 0x4297
xorl %ecx, %ecx
movq 0x120(%rbx), %rdx
movzbl (%rdx,%rcx), %eax
divb (%rbx)
movzbl %ah, %eax
movb %al, (%rdx,%rcx)
incq %rcx
movl 0x4(%rbx), %eax
cmpq %rax, %rcx
jb 0x4279
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: OTSenderProtocol(CSocket*, SenderOTCorrelation const&, unsigned int, unsigned char const*)
void OTSenderProtocol(CSocket *socket, const SenderOTCorrelation &corr,
                      uint32_t nOTs, const uint8_t *msgs)
{
  if (nOTs > corr.N)
  {
    throw "insufficient number of of OT correlations";
  }

  uint8_t *clientMsg = new uint8_t[nOTs];
  socket->ReceiveLarge(clientMsg, nOTs * sizeof(uint8_t));

  cout << "Receiving: " << (uint32_t) clientMsg[0] << endl;

  uint8_t *senderMsg = new uint8_t[corr.K * nOTs];
  ConstructOTSenderMsg(senderMsg, corr, msgs, clientMsg, nOTs, 8);

  socket->SendLarge((uint8_t *)senderMsg, corr.K * nOTs * sizeof(uint8_t));

  cout << "Sending: " << (uint32_t) senderMsg[0] << (uint32_t)senderMsg[1] << (uint32_t)senderMsg[2] <<(uint32_t) senderMsg[3] << endl;

  delete[] clientMsg;
  delete[] senderMsg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, (%rsp)
cmpl %edx, 0x4(%rsi)
jb 0x43f8
movl %edx, %ebp
movq %rsi, %r13
movq %rdi, %r15
movl %edx, %r14d
movq %r14, %rdi
callq 0x2030
movq %rax, %rbx
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x54b8
movq 0x4cf6(%rip), %r12      # 0x8fd8
leaq 0x227b(%rip), %rsi      # 0x6564
movl $0xb, %edx
movq %r12, %rdi
callq 0x22c0
movzbl (%rbx), %esi
movq %r12, %rdi
callq 0x2160
movq %rax, %r14
movq (%rax), %rax
movl $0xa, %esi
movq -0x18(%rax), %rdi
addq %r14, %rdi
callq 0x2230
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movzbl (%r13), %edi
imull %ebp, %edi
callq 0x2030
movq (%rsp), %rdx
movl $0x8, %r9d
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x40b2
movzbl (%r13), %edx
movq %r15, %rdi
movq %r14, %rsi
imull %ebp, %edx
callq 0x556a
leaq 0x2200(%rip), %rsi      # 0x6570
movl $0x9, %edx
movq %r12, %rdi
callq 0x22c0
movzbl (%r14), %esi
movq %r12, %rdi
callq 0x2160
movzbl 0x1(%r14), %esi
movq %rax, %rdi
callq 0x2160
movzbl 0x2(%r14), %esi
movq %rax, %rdi
callq 0x2160
movzbl 0x3(%r14), %esi
movq %rax, %rdi
callq 0x2160
movq %rax, %r15
movq (%rax), %rax
movl $0xa, %esi
movq -0x18(%rax), %rdi
addq %r15, %rdi
callq 0x2230
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x2300
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2300
movl $0x8, %edi
callq 0x2120
movq 0x4bb7(%rip), %rsi      # 0x8fc0
leaq 0x212a(%rip), %rcx      # 0x653a
movq %rax, %rdi
xorl %edx, %edx
movq %rcx, (%rax)
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: CreateAndExportOTCorrelation(std::basic_ofstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&, unsigned int, unsigned char, unsigned char, unsigned char)
void CreateAndExportOTCorrelation(ofstream &out1, ofstream &out2, uint32_t N, uint8_t K, uint8_t bitsPerFSMROT, uint8_t bitsPerFSMSOT)
{
  SenderOTCorrelation senderOTC(N, K);
  ReceiverOTCorrelation receiverOTC(N, K);

  CreateOTCorrelation(senderOTC, receiverOTC, bitsPerFSMROT, bitsPerFSMSOT);

  senderOTC.WriteToFile(out1, bitsPerFSMSOT);
  receiverOTC.WriteToFile(out2, bitsPerFSMROT);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdi, %r14
leaq 0x130(%rsp), %rdi
movq %rsi, %rbx
movl %r9d, %ebp
movl %r8d, %r15d
movl %ecx, %r12d
movl %edx, %r13d
movl %edx, %esi
movl %ecx, %edx
callq 0x3bac
movq %rsp, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x3d04
movzbl %r15b, %r15d
movzbl %bpl, %ebp
leaq 0x130(%rsp), %rdi
movq %rsp, %rsi
movl %r15d, %edx
movl %ebp, %ecx
callq 0x3e9d
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x46de
movq %rsp, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x475c
movq %rsp, %rdi
callq 0x3e6a
leaq 0x130(%rsp), %rdi
callq 0x3ce2
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x46c9
movq %rsp, %rdi
movq %rax, %rbx
callq 0x3e6a
leaq 0x130(%rsp), %rdi
callq 0x3ce2
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: SenderOTCorrelation::WriteToFile(std::basic_ofstream<char, std::char_traits<char>>&, unsigned char) const
void SenderOTCorrelation::WriteToFile(ofstream &fout, uint8_t bitsPerFSM) const
{
  fout.write((char *)&N, sizeof(N));
  fout.write((char *)&K, sizeof(K));

  if (store_sOT_as_key == 1){
    fout.write((char *)msgKey.keyBytes, sizeof(msgKey.keyBytes));
  }
  else{

    uint8_t* packed = Pack(bitsPerFSM, N * K, blindingFactors);
    uint64_t newLength = packLength(N * K, bitsPerFSM);

    fout.write((char *)packed, sizeof(uint8_t) * newLength);

    delete[] packed;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
movq %rdi, %r14
movq %rbx, %rdi
callq 0x2310
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2310
movzbl (%r14), %esi
movq 0x120(%r14), %rdx
movl %ebp, %edi
imull 0x4(%r14), %esi
callq 0x47e7
movq %rax, %r15
movzbl (%r14), %eax
movl %ebp, %edx
movq %rbx, %rdi
movq %r15, %rsi
imull 0x4(%r14), %eax
imulq %rax, %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
callq 0x2310
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2300
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReceiverOTCorrelation::WriteToFile(std::basic_ofstream<char, std::char_traits<char>>&, unsigned char) const
void ReceiverOTCorrelation::WriteToFile(ofstream &fout, uint8_t bitsPerFSM) const
{
  fout.write((char *)&N, sizeof(N));
  fout.write((char *)&K, sizeof(K));

  uint8_t* packed = Pack(bitsPerFSM, N, blindingFactors);
  uint64_t newLength = packLength(N, bitsPerFSM);

  fout.write((char *)packed, sizeof(uint8_t) * newLength);

  delete[] packed;
  
  fout.write((char *)choiceKey.keyBytes, sizeof(choiceKey.keyBytes));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
movq %rdi, %r14
movq %rbx, %rdi
callq 0x2310
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2310
movl 0x4(%r14), %esi
movq 0x128(%r14), %rdx
movl %ebp, %edi
callq 0x47e7
movq %rax, %r15
movl 0x4(%r14), %eax
movl %ebp, %edx
movq %rbx, %rdi
movq %r15, %rsi
imulq %rax, %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
callq 0x2310
movq %r15, %rdi
callq 0x2300
addq $0x110, %r14            # imm = 0x110
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2310
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: Pack(unsigned char, unsigned long, unsigned char*)
uint8_t *Pack(uint8_t bitsPerMsg, uint64_t length, uint8_t* data){
  //Assumes bitsPerMsg <= 8
  uint64_t newLength = packLength(length, bitsPerMsg);
  uint8_t* buffer = new uint8_t[newLength];
  memset(buffer, 0, newLength);
  
  uint8_t bitPointer = 0;
  uint64_t index = 0;

  for (int i = 0; i < length; i++){
    if (bitPointer + bitsPerMsg <= 8){
      buffer[index] += data[i] << bitPointer;
      bitPointer += bitsPerMsg;
      if (bitPointer == 8){
        index += 1;
        bitPointer = 0;
      }
    }
    else{
      uint8_t rightBits = 8 - bitPointer;
      uint8_t mask = (1 << rightBits) - 1;
      buffer[index] += (data[i] & mask) << bitPointer;
      
      index += 1;
      buffer[index] =  data[i] >> rightBits;
      bitPointer = bitsPerMsg - rightBits;
    }
  }
  return buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r12d
imulq %rsi, %r12
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
addq $0x7, %r12
shrq $0x3, %r12
movq %r12, %rdi
callq 0x2030
movq %rax, %r15
xorl %r13d, %r13d
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2140
testq %r14, %r14
je 0x4897
movzbl %bpl, %eax
xorl %ecx, %ecx
xorl %esi, %esi
xorl %edx, %edx
movzbl %sil, %edi
addl %eax, %edi
cmpl $0x8, %edi
ja 0x4860
movzbl (%rbx,%rcx), %r8d
shlxl %esi, %r8d, %esi
addb %sil, (%r15,%rdx)
xorl %esi, %esi
cmpl $0x8, %edi
sete %sil
cmovel %r13d, %edi
addq %rsi, %rdx
movl %edi, %esi
jmp 0x488f
movzbl (%rbx,%rcx), %r8d
movl $0x8, %edi
subl %esi, %edi
movzbl %dil, %edi
bzhil %edi, %r8d, %r9d
shlxl %esi, %r9d, %esi
addb %sil, (%r15,%rdx)
shrxl %edi, %r8d, %esi
movb %sil, 0x1(%r15,%rdx)
movl %eax, %esi
incq %rdx
subl %edi, %esi
incq %rcx
cmpq %rcx, %r14
jne 0x4833
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: Unpack(unsigned char, unsigned long, unsigned char*, unsigned char*)
uint8_t *Unpack(uint8_t bitsPerMsg, uint64_t length, uint8_t* data, uint8_t* out){
  //Assumes bitsPerMsg <= 8
  uint64_t newLength = packLength(length, bitsPerMsg);
  
  uint8_t bitPointer = 0;
  uint64_t index = 0;

  uint8_t mask = (1 << bitsPerMsg) - 1;

  for (int i = 0; i < length; i++){
    if (bitPointer + bitsPerMsg <= 8){
      //REGULAR CASE
      out[i] = (data[index] >> bitPointer) & mask;
      bitPointer += bitsPerMsg;
      if (bitPointer == 8){
        index += 1;
        bitPointer = 0;
      }
    }
    else{
      //OVERLAP CASE
      uint8_t reconstructedValue = 0;

      uint8_t rightBits = 8 - bitPointer;
      reconstructedValue += data[index] >> bitPointer;

      index += 1;
      uint8_t leftBits = bitsPerMsg - rightBits;
      uint8_t newMask = (1 << leftBits) - 1;
      reconstructedValue += (data[index] & newMask) << rightBits;
      out[i] = reconstructedValue;

      bitPointer = leftBits;
    }
  }
  return out;
}

// Assembly:
movq %rcx, %rax
testq %rsi, %rsi
je 0x494d
pushq %rbp
pushq %r14
pushq %rbx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %r11d, %r11d
xorl %r10d, %r10d
shlxl %edi, %ecx, %ecx
notl %ecx
movzbl %r11b, %ebp
addl %edi, %ebp
cmpl $0x8, %ebp
ja 0x490d
movzbl (%rdx,%r10), %ebx
shrxl %r11d, %ebx, %ebx
xorl %r11d, %r11d
andl %ecx, %ebx
cmpl $0x8, %ebp
sete %r11b
cmovel %r8d, %ebp
addq %r11, %r10
movl %ebp, %r11d
jmp 0x493d
movzbl (%rdx,%r10), %ebp
movzbl 0x1(%rdx,%r10), %r14d
movl $0x8, %ebx
incq %r10
subl %r11d, %ebx
movzbl %bl, %ebx
shrxl %r11d, %ebp, %ebp
movl %edi, %r11d
subl %ebx, %r11d
bzhil %r11d, %r14d, %r14d
shlxl %ebx, %r14d, %ebx
addl %ebp, %ebx
movb %bl, (%rax,%r9)
incq %r9
cmpq %r9, %rsi
jne 0x48e0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: WriteProtocolArgs(std::basic_ofstream<char, std::char_traits<char>>&, ProtocolArgs)
void WriteProtocolArgs(ofstream &out1, struct ProtocolArgs args)
{
  out1.write((char *)&args.N, sizeof(args.N));
  out1.write((char *)&args.C, sizeof(args.C));
  out1.write((char *)&args.FSM1_rounds, sizeof(args.FSM1_rounds));
  out1.write((char *)&args.FSM2_rounds, sizeof(args.FSM2_rounds));

  for (int i = 0; i < args.FSM1_rounds; i++){
    out1.write((char *)&args.FSM1_steps[i], sizeof(uint8_t));
  }
  for (int i = 0; i < args.FSM2_rounds; i++){
    out1.write((char *)&args.FSM2_steps[i], sizeof(uint8_t));
  }
  for (int i = 0; i < args.C; i++){
    out1.write((char *)&args.bits_per_component[i], sizeof(uint8_t));
  }
  

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl $0x4, %edx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x2310
leaq 0x4(%rbx), %r15
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2310
leaq 0x8(%rbx), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x2310
leaq 0xc(%rbx), %r12
movl $0x4, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2310
cmpl $0x0, 0x8(%rbx)
je 0x49c8
xorl %r13d, %r13d
movq 0x10(%rbx), %rsi
movl $0x1, %edx
movq %r14, %rdi
addq %r13, %rsi
callq 0x2310
movl 0x8(%rbx), %eax
incq %r13
cmpq %rax, %r13
jb 0x49a9
cmpl $0x0, (%r12)
je 0x49f1
xorl %r12d, %r12d
movq 0x18(%rbx), %rsi
movl $0x1, %edx
movq %r14, %rdi
addq %r12, %rsi
callq 0x2310
movl 0xc(%rbx), %eax
incq %r12
cmpq %rax, %r12
jb 0x49d2
cmpl $0x0, (%r15)
je 0x4a19
xorl %r15d, %r15d
movq 0x20(%rbx), %rsi
movl $0x1, %edx
movq %r14, %rdi
addq %r15, %rsi
callq 0x2310
movl 0x4(%rbx), %eax
incq %r15
cmpq %rax, %r15
jb 0x49fa
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ProtocolArgs::ProtocolArgs(std::basic_ifstream<char, std::char_traits<char>>&)
ProtocolArgs::ProtocolArgs(ifstream &in)
{
  alloc_OT = false;

  in.read((char *)&N, sizeof(N));
  in.read((char *)&C, sizeof(C));
  in.read((char *)&FSM1_rounds, sizeof(FSM1_rounds));
  in.read((char *)&FSM2_rounds, sizeof(FSM2_rounds));

  FSM1_steps = new uint8_t[FSM1_rounds];
  for (int i = 0; i < FSM1_rounds; i++){
    in.read((char *)&FSM1_steps[i], sizeof(uint8_t));
  }

  FSM2_steps = new uint8_t[FSM2_rounds];
  for (int i = 0; i < FSM2_rounds; i++){
    in.read((char *)&FSM2_steps[i], sizeof(uint8_t));
  }
  bits_per_component = new uint8_t[C];
  for (int i = 0; i < C; i++){
    in.read((char *)&bits_per_component[i], sizeof(uint8_t));
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl $0x4, %edx
movq %rsi, %rbx
movq %rdi, %r14
movb $0x0, 0x28(%rdi)
movq %rsi, %rdi
movq %r14, %rsi
callq 0x22f0
leaq 0x4(%r14), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x22f0
leaq 0x8(%r14), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x22f0
leaq 0xc(%r14), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x22f0
movl 0x8(%r14), %r15d
movq %r15, %rdi
callq 0x2030
movq %rax, 0x10(%r14)
testq %r15, %r15
je 0x4aae
xorl %r15d, %r15d
movq 0x10(%r14), %rsi
movl $0x1, %edx
movq %rbx, %rdi
addq %r15, %rsi
callq 0x22f0
movl 0x8(%r14), %eax
incq %r15
cmpq %rax, %r15
jb 0x4a8e
movl 0xc(%r14), %r15d
movq %r15, %rdi
callq 0x2030
movq %rax, 0x18(%r14)
testq %r15, %r15
je 0x4ae6
xorl %r15d, %r15d
movq 0x18(%r14), %rsi
movl $0x1, %edx
movq %rbx, %rdi
addq %r15, %rsi
callq 0x22f0
movl 0xc(%r14), %eax
incq %r15
cmpq %rax, %r15
jb 0x4ac6
movl 0x4(%r14), %r15d
movq %r15, %rdi
callq 0x2030
movq %rax, 0x20(%r14)
testq %r15, %r15
je 0x4b1e
xorl %r15d, %r15d
movq 0x20(%r14), %rsi
movl $0x1, %edx
movq %rbx, %rdi
addq %r15, %rsi
callq 0x22f0
movl 0x4(%r14), %eax
incq %r15
cmpq %rax, %r15
jb 0x4afe
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReadInSenderOTsFSM1(std::basic_ifstream<char, std::char_traits<char>>&, ProtocolArgs)
SenderOTCorrelation** ReadInSenderOTsFSM1(ifstream &in, struct ProtocolArgs args)
{
  SenderOTCorrelation** FSM1 = new SenderOTCorrelation*[args.FSM1_rounds];

  for (int i = 0; i < args.FSM1_rounds; i++)
  {
    FSM1[i] = new SenderOTCorrelation(in, bits_FSM1_SOT);
  }
  return FSM1;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x8(%rsi), %r12d
movq %rdi, %r14
movq %rsi, %rbx
leaq (,%r12,8), %rdi
callq 0x2030
movq %rax, %r15
testq %r12, %r12
je 0x4dfc
xorl %r13d, %r13d
movl $0x130, %edi            # imm = 0x130
callq 0x2250
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3bfe
movq %r12, (%r15,%r13,8)
incq %r13
movl 0x8(%rbx), %eax
cmpq %rax, %r13
jb 0x4dd0
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r12, %rdi
movq %rax, %rbx
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReadInSenderOTsFSM2(std::basic_ifstream<char, std::char_traits<char>>&, ProtocolArgs)
SenderOTCorrelation** ReadInSenderOTsFSM2(ifstream &in, struct ProtocolArgs args)
{
  SenderOTCorrelation** FSM2 = new SenderOTCorrelation*[args.FSM2_rounds];
  for (int i = 0; i < args.FSM2_rounds; i++)
  {
    FSM2[i] = new SenderOTCorrelation(in, bits_FSM2_SOT);
  }
  return FSM2;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0xc(%rsi), %r12d
movq %rdi, %r14
movq %rsi, %rbx
leaq (,%r12,8), %rdi
callq 0x2030
movq %rax, %r15
testq %r12, %r12
je 0x4e73
xorl %r13d, %r13d
movl $0x130, %edi            # imm = 0x130
callq 0x2250
movq %rax, %r12
movl $0x2, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3bfe
movq %r12, (%r15,%r13,8)
incq %r13
movl 0xc(%rbx), %eax
cmpq %rax, %r13
jb 0x4e47
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r12, %rdi
movq %rax, %rbx
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReadInReceiverOTsFSM1(std::basic_ifstream<char, std::char_traits<char>>&, ProtocolArgs)
ReceiverOTCorrelation** ReadInReceiverOTsFSM1(ifstream &in, struct ProtocolArgs args)
{
  args.alloc_OT = true;
  ReceiverOTCorrelation** FSM1 = new ReceiverOTCorrelation *[args.FSM1_rounds];
  for (int i = 0; i < args.FSM1_rounds; i++)
  {
    FSM1[i] = new ReceiverOTCorrelation(in, bits_FSM1);
  }
  return FSM1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movb $0x1, 0x28(%rsi)
movq %rdi, %r14
movq %rsi, %rbx
movl 0x8(%rsi), %r12d
leaq (,%r12,8), %rdi
callq 0x2030
movq %rax, %r15
testq %r12, %r12
je 0x4eee
xorl %r13d, %r13d
movl $0x130, %edi            # imm = 0x130
callq 0x2250
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3d60
movq %r12, (%r15,%r13,8)
incq %r13
movl 0x8(%rbx), %eax
cmpq %rax, %r13
jb 0x4ec2
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r12, %rdi
movq %rax, %rbx
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReadInReceiverOTsFSM2(std::basic_ifstream<char, std::char_traits<char>>&, ProtocolArgs)
ReceiverOTCorrelation** ReadInReceiverOTsFSM2(ifstream &in, struct ProtocolArgs args)
{
  args.alloc_OT = true;
  ReceiverOTCorrelation** FSM2 = new ReceiverOTCorrelation *[args.FSM2_rounds];
  for (int i = 0; i < args.FSM2_rounds; i++)
  {
    FSM2[i] = new ReceiverOTCorrelation(in, bits_FSM2);
  }
  return FSM2;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movb $0x1, 0x28(%rsi)
movq %rdi, %r14
movq %rsi, %rbx
movl 0xc(%rsi), %r12d
leaq (,%r12,8), %rdi
callq 0x2030
movq %rax, %r15
testq %r12, %r12
je 0x4f69
xorl %r13d, %r13d
movl $0x130, %edi            # imm = 0x130
callq 0x2250
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3d60
movq %r12, (%r15,%r13,8)
incq %r13
movl 0xc(%rbx), %eax
cmpq %rax, %r13
jb 0x4f3d
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r12, %rdi
movq %rax, %rbx
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReadInEntry(std::basic_ifstream<char, std::char_traits<char>>&, unsigned int)
uint32_t* ReadInEntry(ifstream& in, uint32_t C){
  string line;
  getline(in, line, '\n');

  istringstream f(line);
  string element;

  uint32_t* entry = new uint32_t[C];
  uint32_t i = 0;

  while (getline(f, element, ',')){
    entry[i] = (uint32_t) atoi(element.c_str());
    i += 1;
  }

  return entry;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
leaq 0x18(%rsp), %r12
movl %esi, %ebx
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x2440
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
callq 0x23b0
leaq 0x38(%rsp), %r13
movl %ebx, %edi
shlq $0x2, %rdi
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
callq 0x2030
leaq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %rax, %rbx
xorl %ebp, %ebp
movl $0x2c, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2440
movq (%rax), %rcx
movq 0x28(%rsp), %rdi
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x504e
callq 0x2370
movl %ebp, %ecx
movl %eax, (%rbx,%rcx,4)
incl %ebp
jmp 0x501d
cmpq %r13, %rdi
je 0x5058
callq 0x2210
movq 0x3f71(%rip), %rsi      # 0x8fd0
leaq 0x48(%rsp), %rdi
callq 0x2340
leaq 0xc0(%rsp), %rdi
callq 0x20e0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x5085
callq 0x2210
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x50b8
jmp 0x50a1
movq %rax, %rbx
jmp 0x50d6
movq 0x28(%rsp), %rdi
movq %rax, %rbx
cmpq %r13, %rdi
je 0x50b8
callq 0x2210
movq 0x3f11(%rip), %rsi      # 0x8fd0
leaq 0x48(%rsp), %rdi
callq 0x2340
leaq 0xc0(%rsp), %rdi
callq 0x20e0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x50e5
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReadInDB(std::basic_ifstream<char, std::char_traits<char>>&, unsigned int, unsigned int)
uint32_t** ReadInDB(ifstream& in, uint32_t N, uint32_t C){
  uint32_t **db = new uint32_t *[N];
  for (int i = 0; i < N; i++)
  {
    db[i] = ReadInEntry(in, C);
  }
  return db;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl %esi, %r12d
leaq (,%r12,8), %rdi
movl %edx, %ebx
movl %esi, %ebp
callq 0x2030
movq %rax, %r15
testl %ebp, %ebp
je 0x512f
xorl %r13d, %r13d
movq %r14, %rdi
movl %ebx, %esi
callq 0x4f9f
movq %rax, (%r15,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0x5119
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: SendLargePacked(CSocket*, unsigned char, unsigned long, unsigned char*)
void SendLargePacked(CSocket* socket, uint8_t bitsPerMsg, uint64_t length, uint8_t* data){
  //Assumes bitsPerMsg <= 8
  uint64_t newLength = packLength(length, bitsPerMsg);
  uint8_t* buffer = new uint8_t[newLength];
  memset(buffer, 0, newLength);
  
  uint8_t bitPointer = 0;
  uint64_t index = 0;

  for (int i = 0; i < length; i++){
    if (bitPointer + bitsPerMsg <= 8){
      buffer[index] += data[i] << bitPointer;
      bitPointer += bitsPerMsg;
      if (bitPointer == 8){
        index += 1;
        bitPointer = 0;
      }
    }
    else{
      uint8_t rightBits = 8 - bitPointer;
      uint8_t mask = (1 << rightBits) - 1;
      buffer[index] += (data[i] & mask) << bitPointer;
      
      index += 1;
      buffer[index] =  data[i] >> rightBits;
      bitPointer = bitsPerMsg - rightBits;
    }
  }

#if LOGGING
  struct timespec start, stop;
  uint64_t duration;
  clock_gettime(CLOCK_REALTIME, &start);
#endif

  socket->SendLarge(buffer, newLength);

#if LOGGING
  clock_gettime(CLOCK_REALTIME, &stop);
  duration = (stop.tv_sec - start.tv_sec) * BILLION + stop.tv_nsec - start.tv_nsec;
  cout << "Time to send: " << duration << " ns with size: " << newLength << endl;
#endif
  
  delete[] buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
imulq %rdx, %rbx
movq %rcx, %r14
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, (%rsp)
addq $0x7, %rbx
shrq $0x3, %rbx
movq %rbx, %rdi
callq 0x2030
movq %rax, %r13
xorl %r15d, %r15d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2140
testq %r12, %r12
je 0x51f6
movzbl %bpl, %eax
xorl %ecx, %ecx
xorl %esi, %esi
xorl %edx, %edx
movzbl %sil, %edi
addl %eax, %edi
cmpl $0x8, %edi
ja 0x51be
movzbl (%r14,%rcx), %r8d
shlxl %esi, %r8d, %esi
addb %sil, (%r13,%rdx)
xorl %esi, %esi
cmpl $0x8, %edi
sete %sil
cmovel %r15d, %edi
addq %rsi, %rdx
movl %edi, %esi
jmp 0x51ee
movzbl (%r14,%rcx), %r8d
movl $0x8, %edi
subl %esi, %edi
movzbl %dil, %edi
bzhil %edi, %r8d, %r9d
shlxl %esi, %r9d, %esi
addb %sil, (%r13,%rdx)
shrxl %edi, %r8d, %esi
movb %sil, 0x1(%r13,%rdx)
movl %eax, %esi
incq %rdx
subl %edi, %esi
incq %rcx
cmpq %rcx, %r12
jne 0x5190
movq (%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x556a
movq %r13, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2300
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/protocol.cpp
// Function: ReceiveLargePacked(CSocket*, unsigned char, unsigned long, unsigned char*)
void ReceiveLargePacked(CSocket* socket, uint8_t bitsPerMsg, uint64_t length, uint8_t* out){
  //Assumes bitsPerMsg <= 8
  uint64_t newLength = packLength(length, bitsPerMsg);
  uint8_t* buffer = new uint8_t[newLength];

#if LOGGING
  struct timespec start, stop;
  uint64_t duration;
  clock_gettime(CLOCK_REALTIME, &start);
#endif

  socket->ReceiveLarge(buffer, newLength);

#if LOGGING
  clock_gettime(CLOCK_REALTIME, &stop);
  duration = (stop.tv_sec - start.tv_sec) * BILLION + stop.tv_nsec - start.tv_nsec;
  cout << "Time to receive: " << duration << " ns with size: " << newLength << endl;
#endif
  
  uint8_t bitPointer = 0;
  uint64_t index = 0;

  uint8_t mask = (1 << bitsPerMsg) - 1;

  for (int i = 0; i < length; i++){
    if (bitPointer + bitsPerMsg <= 8){
      //REGULAR CASE
      out[i] = (buffer[index] >> bitPointer) & mask;
      bitPointer += bitsPerMsg;
      if (bitPointer == 8){
        index += 1;
        bitPointer = 0;
      }
    }
    else{
      //OVERLAP CASE
      uint8_t reconstructedValue = 0;

      uint8_t rightBits = 8 - bitPointer;
      reconstructedValue += buffer[index] >> bitPointer;

      index += 1;
      uint8_t leftBits = bitsPerMsg - rightBits;
      uint8_t newMask = (1 << leftBits) - 1;
      reconstructedValue += (buffer[index] & newMask) << rightBits;
      out[i] = reconstructedValue;

      bitPointer = leftBits;
    }
  }
  delete[] buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r13d
imulq %rdx, %r13
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r12
addq $0x7, %r13
shrq $0x3, %r13
movq %r13, %rdi
callq 0x2030
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x54b8
testq %r14, %r14
je 0x52e4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
xorl %edx, %edx
xorl %edi, %edi
xorl %esi, %esi
shlxl %ebp, %eax, %eax
notl %eax
movzbl %dil, %r9d
addl %ebp, %r9d
cmpl $0x8, %r9d
ja 0x52a6
movzbl (%r15,%rsi), %r8d
shrxl %edi, %r8d, %r8d
xorl %edi, %edi
andl %eax, %r8d
cmpl $0x8, %r9d
sete %dil
cmovel %ecx, %r9d
addq %rdi, %rsi
movl %r9d, %edi
jmp 0x52d8
movzbl (%r15,%rsi), %r9d
movzbl 0x1(%r15,%rsi), %r10d
movl $0x8, %r8d
incq %rsi
subl %edi, %r8d
movzbl %r8b, %r8d
shrxl %edi, %r9d, %r9d
movl %ebp, %edi
subl %r8d, %edi
bzhil %edi, %r10d, %r10d
shlxl %r8d, %r10d, %r8d
addl %r9d, %r8d
movb %r8b, (%rbx,%rdx)
incq %rdx
cmpq %rdx, %r14
jne 0x5276
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2300
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/./socket.h
// Function: CSocket::Bind(unsigned short, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
uint8_t Bind(uint16_t nPort=0, string ip = "") {
    // Bind the socket to its port
    sockaddr_in sockAddr;
    memset(&sockAddr,0,sizeof(sockAddr));
    sockAddr.sin_family = AF_INET;

    if( ip != "" ) {
      int on = 1;
      setsockopt(m_hSock, SOL_SOCKET, SO_REUSEADDR, (const char*) &on, sizeof(on));

      sockAddr.sin_addr.s_addr = inet_addr(ip.c_str());

      if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
        hostent* phost;
        phost = gethostbyname(ip.c_str());
        if (phost != NULL) {
          sockAddr.sin_addr.s_addr = ((in_addr*)phost->h_addr)->s_addr;
        }
        else {
          return 0;
        }
      }
    }
    else {
      sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    }
    
    sockAddr.sin_port = htons(nPort);

    return ::bind(m_hSock, (sockaddr *) &sockAddr, sizeof(sockaddr_in)) >= 0; 
  }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebp
leaq 0x109b(%rip), %rsi      # 0x63a6
movq %rdi, %rbx
movq %rdx, %rdi
movq %rdx, %r14
movl $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movw $0x2, 0xc(%rsp)
callq 0x20b0
testl %eax, %eax
je 0x5384
leaq 0x1c(%rsp), %rcx
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
movl $0x1, (%rcx)
movl (%rbx), %edi
callq 0x2410
movq (%r14), %rdi
callq 0x2260
movl %eax, 0x10(%rsp)
cmpl $-0x1, %eax
jne 0x538c
movq (%r14), %rdi
callq 0x22b0
testq %rax, %rax
je 0x53b1
movq 0x18(%rax), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, 0x10(%rsp)
jmp 0x538c
movl $0x0, 0x10(%rsp)
leaq 0xc(%rsp), %rsi
movl $0x10, %edx
movbew %bp, 0x2(%rsi)
movl (%rbx), %edi
callq 0x2070
testl %eax, %eax
setns %al
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
jmp 0x53a8
nop
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/./socket.h
// Function: CSocket::Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned short, int)
uint8_t Connect(string ip, uint16_t port, int32_t lTOSMilisec = -1) {
    sockaddr_in sockAddr;
    memset(&sockAddr,0,sizeof(sockAddr));
    sockAddr.sin_family = AF_INET;
    sockAddr.sin_addr.s_addr = inet_addr(ip.c_str());

    if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
      hostent* lphost;
      lphost = gethostbyname(ip.c_str());
      if (lphost != NULL) {
        sockAddr.sin_addr.s_addr = ((in_addr*)lphost->h_addr)->s_addr;
      }
      else {
        return 0;
      }
    }

    sockAddr.sin_port = htons(port);
  
    timeval tv;
    socklen_t len;
    
    if (lTOSMilisec > 0) {
      tv.tv_sec = lTOSMilisec/1000;
      tv.tv_usec = (lTOSMilisec%1000)*1000;
  
      setsockopt(m_hSock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
    }

    int ret = connect(m_hSock, (sockaddr*)&sockAddr, sizeof(sockAddr));
    
    if (ret >= 0 && lTOSMilisec > 0) {
      tv.tv_sec = 100000; 
      tv.tv_usec = 0;

      setsockopt(m_hSock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
    }

    return ret >= 0;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq $0x0, 0x10(%rsp)
movw $0x2, 0x8(%rsp)
movq %rdi, %rbx
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq (%rsi), %rdi
callq 0x2260
movl %eax, 0xc(%rsp)
cmpl $-0x1, %eax
jne 0x540a
movq (%r15), %rdi
callq 0x22b0
testq %rax, %rax
je 0x54b4
movq 0x18(%rax), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movbew %r14w, 0xa(%rsp)
testl %ebp, %ebp
jle 0x5456
movl %ebp, %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
leaq 0x18(%rsp), %rcx
movl %ebp, %edx
movl $0x1, %esi
movl $0x10, %r8d
shrq $0x26, %rax
movq %rax, (%rcx)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %edx
imull $0x3e8, %edx, %eax      # imm = 0x3E8
movl $0x14, %edx
movq %rax, 0x8(%rcx)
movl (%rbx), %edi
callq 0x2410
movl (%rbx), %edi
testl %ebp, %ebp
leaq 0x8(%rsp), %rsi
movl $0x10, %edx
setle %r14b
callq 0x21c0
testl %eax, %eax
movl %eax, %ebp
sets %al
orb %r14b, %al
jne 0x54a4
leaq 0x18(%rsp), %rcx
movl $0x1, %esi
movl $0x14, %edx
movl $0x10, %r8d
movq $0x186a0, (%rcx)        # imm = 0x186A0
movq $0x0, 0x8(%rcx)
movl (%rbx), %edi
callq 0x2410
testl %ebp, %ebp
setns %al
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x54a9
// File: /workspace/github_cpp_makefile_star2_O3/jBlinden[P]private-codis/./socket.h
// Function: CSocket::ReceiveLarge(unsigned char*, unsigned long)
void ReceiveLarge(uint8_t* pBuf, uint64_t len) {
    int nBatches = (len + BLK_SIZE - 1) / BLK_SIZE;
    for (int i = 0; i < nBatches; i++) {
      int batchSize = BLK_SIZE;
      if (i == nBatches - 1) {
        batchSize = len % BLK_SIZE;
        if (batchSize == 0) {
          batchSize = BLK_SIZE;
        }
      }
      Receive(pBuf + i * BLK_SIZE, batchSize);
    }
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x7ffffffe(%rdx), %r14
movabsq $0x200000005, %rcx      # imm = 0x200000005
movq %rdx, %rax
movq %r14, %rdx
mulxq %rcx, %rdx, %rdx
subq %rdx, %r14
shrq %r14
addq %rdx, %r14
shrq $0x1e, %r14
testl %r14d, %r14d
jle 0x555a
movq %rax, %rdx
mulxq %rcx, %rcx, %rcx
movq %rax, %r13
leal -0x1(%r14), %r12d
movq %rsi, %rbx
movq %rdi, %r15
subq %rcx, %r13
shrq %r13
addq %rcx, %r13
shrq $0x1e, %r13
movq %r13, %rcx
shlq $0x1f, %rcx
subq %rcx, %r13
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rax, %r13
cmovel %ecx, %r13d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %ebp, %ebp
cmpq %rbp, %r12
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %r15, %rdi
movq %rbx, %rsi
cmovel %r13d, %edx
xorl %ecx, %ecx
callq 0x561c
incq %rbp
addq $0x7fffffff, %rbx       # imm = 0x7FFFFFFF
cmpq %rbp, %r14
jne 0x5532
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop