LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::table_position cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::cuckoo_find<unsigned int>(unsigned int const&, unsigned char, unsigned long, unsigned long) const
table_position cuckoo_find(const K &key, const partial_t partial,
                             const size_type i1, const size_type i2) const {
    int slot = try_read_from_bucket(buckets_[i1], partial, key);
    if (slot != -1) {
      return table_position{i1, static_cast<size_type>(slot), ok};
    }
    slot = try_read_from_bucket(buckets_[i2], partial, key);
    if (slot != -1) {
      return table_position{i2, static_cast<size_type>(slot), ok};
    }
    return table_position{0, 0, failure_key_not_found};
  }

// Assembly:
movq %rdi, %rax
movq 0x18(%rsi), %rsi
leaq (%r8,%r8,4), %rcx
leaq (%rsi,%rcx,8), %rdi
movl (%rdx), %ecx
xorl %edx, %edx
cmpb $0x1, 0x24(%rdi,%rdx)
jne 0x365b
cmpl %ecx, (%rdi,%rdx,8)
je 0x3669
incq %rdx
cmpq $0x4, %rdx
jne 0x364f
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $-0x1, %edx
je 0x3673
movq %r8, (%rax)
jmp 0x369f
leaq (%r9,%r9,4), %rdx
leaq (%rsi,%rdx,8), %rsi
xorl %edx, %edx
cmpb $0x1, 0x24(%rsi,%rdx)
jne 0x3689
cmpl %ecx, (%rsi,%rdx,8)
je 0x3697
incq %rdx
cmpq $0x4, %rdx
jne 0x367d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $-0x1, %edx
je 0x36ac
movq %r9, (%rax)
movslq %edx, %rcx
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movl %ecx, 0x10(%rax)
retq
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x2, %ecx
jmp 0x36a8
nop
// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::lock_one(unsigned long, unsigned long, std::integral_constant<bool, false>) const
LockManager lock_one(size_type hp, size_type i, normal_mode) const {
    locks_t &locks = get_current_locks();
    spinlock &lock = locks[lock_ind(i)];
    lock.lock();
    check_hashpower(hp, lock);
    return LockManager(&lock);
  }

// Assembly:
pushq %rax
movq 0x28(%rsi), %r8
movzwl %cx, %eax
shll $0x6, %eax
addq 0x10(%r8), %rax
movb $0x1, %cl
xchgb %cl, (%rax)
testb %cl, %cl
jne 0x3e93
movq 0x10(%rsi), %rcx
cmpq %rdx, %rcx
jne 0x3eac
movq %rax, (%rdi)
movq %rdi, %rax
popq %rcx
retq
movb $0x0, (%rax)
movl $0x1, %edi
callq 0x20b0
leaq 0x4e18(%rip), %rsi      # 0x8cd8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2200
// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::b_queue::dequeue()
b_slot dequeue() {
      assert(!empty());
      assert(first_ < last_);
      b_slot &x = slots_[first_++];
      return x;
    }

// Assembly:
pushq %rax
movq 0x2aa0(%rdi), %rcx
cmpq 0x2aa8(%rdi), %rcx
je 0x3ef7
jae 0x3f16
leaq 0x1(%rcx), %rax
movq %rax, 0x2aa0(%rdi)
shlq $0x4, %rcx
movq (%rdi,%rcx), %rax
movq 0x8(%rdi,%rcx), %rdx
popq %rcx
retq
leaq 0x20b9(%rip), %rdi      # 0x5fb7
leaq 0x1379(%rip), %rsi      # 0x527e
leaq 0x20b4(%rip), %rcx      # 0x5fc0
movl $0x5c1, %edx            # imm = 0x5C1
callq 0x20f0
leaq 0x21ad(%rip), %rdi      # 0x60ca
leaq 0x135a(%rip), %rsi      # 0x527e
leaq 0x2095(%rip), %rcx      # 0x5fc0
movl $0x5c2, %edx            # imm = 0x5C2
callq 0x20f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::lock_three(unsigned long, unsigned long, unsigned long, unsigned long, std::integral_constant<bool, false>) const
std::pair<TwoBuckets, LockManager> lock_three(size_type hp, size_type i1,
                                                size_type i2, size_type i3,
                                                normal_mode) const {
    std::array<size_type, 3> l{{lock_ind(i1), lock_ind(i2), lock_ind(i3)}};
    // Lock in order.
    if (l[2] < l[1])
      std::swap(l[2], l[1]);
    if (l[2] < l[0])
      std::swap(l[2], l[0]);
    if (l[1] < l[0])
      std::swap(l[1], l[0]);
    locks_t &locks = get_current_locks();
    locks[l[0]].lock();
    check_hashpower(hp, locks[l[0]]);
    if (l[1] != l[0]) {
      locks[l[1]].lock();
    }
    if (l[2] != l[1]) {
      locks[l[2]].lock();
    }
    return std::make_pair(TwoBuckets(locks, i1, i2, normal_mode()),
                          LockManager((lock_ind(i3) == lock_ind(i1) ||
                                       lock_ind(i3) == lock_ind(i2))
                                          ? nullptr
                                          : &locks[lock_ind(i3)]));
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0xffff, %r11d          # imm = 0xFFFF
movq %rcx, %rax
andq %r11, %rax
movq %r8, %r10
andq %r11, %r10
andq %r11, %r9
cmpq %r10, %r9
movq %r10, %r14
cmovbq %r9, %r14
movq %r10, %r11
cmovaq %r9, %r11
cmpq %rax, %r11
movq %rax, %r15
cmovbq %r11, %r15
cmpq %r15, %r14
movq %r15, %r12
cmovbq %r14, %r12
movq 0x28(%rsi), %rbx
movl %r12d, %r13d
shll $0x6, %r13d
addq 0x10(%rbx), %r13
movb $0x1, %bpl
xchgb %bpl, (%r13)
testb %bpl, %bpl
jne 0x3f8a
cmpq %rax, %r11
cmovbeq %rax, %r11
cmpq %r15, %r14
movq %r15, %r13
cmovaq %r14, %r13
movq 0x10(%rbx), %rbp
movq 0x10(%rsi), %rsi
cmpq %rdx, %rsi
jne 0x4043
cmpl %r15d, %r14d
je 0x3fd2
movl %r13d, %edx
shll $0x6, %edx
addq 0x10(%rbx), %rdx
movb $0x1, %sil
xchgb %sil, (%rdx)
testb %sil, %sil
jne 0x3fc7
cmpl %r13d, %r11d
je 0x3fe8
shll $0x6, %r11d
addq 0x10(%rbx), %r11
movb $0x1, %dl
xchgb %dl, (%r11)
testb %dl, %dl
jne 0x3fdf
movq 0x10(%rbx), %rdx
movl %eax, %esi
shll $0x6, %esi
addq %rdx, %rsi
movl %r10d, %r11d
shll $0x6, %r11d
addq %rdx, %r11
movl %r9d, %ebx
shll $0x6, %ebx
addq %rdx, %rbx
xorl %edx, %edx
cmpq %r10, %rax
cmoveq %rdx, %r11
cmpq %r10, %r9
cmoveq %rdx, %rbx
cmpq %rax, %r9
movq %rcx, (%rdi)
movq %r8, 0x8(%rdi)
movq %rsi, 0x10(%rdi)
movq %r11, 0x18(%rdi)
cmoveq %rdx, %rbx
movq %rbx, 0x20(%rdi)
movq %rdi, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shll $0x6, %r12d
movb $0x0, (%rbp,%r12)
movl $0x1, %edi
callq 0x20b0
leaq 0x4c7a(%rip), %rsi      # 0x8cd8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2200
// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::snapshot_and_lock_all(std::integral_constant<bool, false>)
AllLocksManager snapshot_and_lock_all(normal_mode) {
    // all_locks_ should never decrease in size, so if it is non-empty now, it
    // will remain non-empty
    assert(!all_locks_.empty());
    auto first_locked = all_locks_.end();
    --first_locked;
    auto current_locks = first_locked;
    while (current_locks != all_locks_.end()) {
      locks_t &locks = *current_locks;
      for (spinlock &lock : locks) {
        lock.lock();
      }
      ++current_locks;
    }
    // Once we have taken all the locks of the "current" container, nobody
    // else can do locking operations on the table.
    return AllLocksManager(this, AllUnlocker{first_locked});
  }

// Assembly:
pushq %rax
leaq 0x20(%rsi), %rax
cmpq %rax, 0x20(%rsi)
je 0x40b1
movq 0x28(%rsi), %rcx
cmpq %rax, %rcx
je 0x40a5
movq %rcx, %rdx
movq 0x10(%rdx), %r8
movq 0x18(%rdx), %r9
cmpq %r9, %r8
je 0x409d
movb $0x1, %r10b
xchgb %r10b, (%r8)
testb %r10b, %r10b
jne 0x408c
addq $0x40, %r8
jmp 0x4087
movq (%rdx), %rdx
cmpq %rax, %rdx
jne 0x407f
movq %rcx, (%rdi)
movq %rsi, 0x8(%rdi)
movq %rdi, %rax
popq %rcx
retq
leaq 0x2352(%rip), %rdi      # 0x640a
leaq 0x11bf(%rip), %rsi      # 0x527e
leaq 0x2358(%rip), %rcx      # 0x641e
movl $0x3d2, %edx            # imm = 0x3D2
callq 0x20f0
// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/libcuckoo/./cuckoohash_map.hh
// Function: cuckoohash_map<unsigned int, unsigned int, Hash32, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int>>, 4ul>::maybe_resize_locks(unsigned long)
void maybe_resize_locks(size_type new_bucket_count) {
    locks_t &current_locks = get_current_locks();
    if (!(current_locks.size() < kMaxNumLocks &&
          current_locks.size() < new_bucket_count)) {
      return;
    }

    locks_t new_locks(std::min(size_type(kMaxNumLocks), new_bucket_count),
                      spinlock(), get_allocator());
    for (spinlock &lock : new_locks) {
      lock.lock();
    }
    assert(new_locks.size() > current_locks.size());
    std::copy(current_locks.begin(), current_locks.end(), new_locks.begin());
    all_locks_.emplace_back(std::move(new_locks));
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
andq $-0x40, %rsp
subq $0xc0, %rsp
movq 0x28(%rdi), %r15
movq 0x18(%r15), %rax
subq 0x10(%r15), %rax
sarq $0x6, %rax
cmpq $0x10000, %rax          # imm = 0x10000
setae %cl
cmpq %rsi, %rax
setae %al
orb %cl, %al
jne 0x44c7
movq %rdi, %rbx
movl $0x10000, %eax          # imm = 0x10000
cmpq %rax, %rsi
cmovbq %rsi, %rax
leaq 0x40(%rsp), %rdx
movq $0x0, 0x8(%rdx)
xorl %ecx, %ecx
xchgb %cl, (%rdx)
leaq 0x20(%rsp), %r14
leaq 0x1f(%rsp), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2c90
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpq %rcx, %rax
je 0x4438
movb $0x1, %dl
xchgb %dl, (%rax)
testb %dl, %dl
jne 0x442a
addq $0x40, %rax
jmp 0x4425
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rsi
subq %rax, %rsi
movq 0x10(%r15), %rcx
movq 0x18(%r15), %rdx
subq %rcx, %rdx
cmpq %rdx, %rsi
jbe 0x44d2
sarq $0x6, %rdx
testq %rdx, %rdx
jle 0x447b
incq %rdx
movl $0x8, %esi
movq (%rcx,%rsi), %rdi
movq %rdi, (%rax,%rsi)
decq %rdx
addq $0x40, %rsi
cmpq $0x1, %rdx
jg 0x4466
movl $0x28, %edi
callq 0x2150
leaq 0x20(%rbx), %rsi
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x10(%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq %rax, %rdi
callq 0x2040
incq 0x30(%rbx)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x44c7
callq 0x2140
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22ae(%rip), %rdi      # 0x6787
leaq 0xd9e(%rip), %rsi       # 0x527e
leaq 0x22c8(%rip), %rcx      # 0x67af
movl $0x6a3, %edx            # imm = 0x6A3
callq 0x20f0
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x4503
callq 0x2140
movq %rbx, %rdi
callq 0x2210
nop
// File: /workspace/github_cpp_makefile_star2_O1/zengfenfei[P]codility/src/TapeEquilibrium.cpp
// Function: solution(std::vector<int, std::allocator<int>>&)
int solution(vector<int> &A) {
	int n = A.size();
	vector<int> leftSums(n), rightSums(n);
	leftSums[0] = A[0];
	for (int i = 1; i < n; i++) {
		leftSums[i] = leftSums[i - 1] + A[i];
	}

	rightSums[n - 1] = A[n - 1];
	int minDiff = abs(leftSums[n - 2] - rightSums[n - 1]);
	for (int i = n - 2; i > 0; i--) {
		rightSums[i] = rightSums[i + 1] + A[i];
		int diff = abs(leftSums[i - 1] - rightSums[i]);
		if (diff < minDiff) {
			minDiff = diff;
		}
	}
	return minDiff;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %r14
movq 0x8(%rdi), %r12
subq (%rdi), %r12
movq %r12, %r15
shrq $0x2, %r15
movslq %r15d, %rbx
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rdx
movq %rbx, %rsi
callq 0x134c
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %rbx, %rsi
callq 0x134c
shlq $0x1e, %r12
movq (%r14), %rax
movl (%rax), %edx
movq -0x40(%rbp), %rcx
movl %edx, (%rcx)
cmpl $0x2, %r15d
jl 0x1282
movl %r15d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rcx), %esi
movl $0x1, %edi
addl (%rax,%rdi,4), %esi
movl %esi, (%rcx,%rdi,4)
incq %rdi
cmpq %rdi, %rdx
jne 0x1274
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
addq %rdx, %r12
sarq $0x1e, %r12
movl (%rax,%r12), %edx
movq -0x58(%rbp), %rdi
movl %edx, (%rdi,%r12)
movl -0x8(%rcx,%rbx,4), %esi
subl %edx, %esi
movl %esi, %edx
negl %edx
cmovsl %esi, %edx
cmpl $0x3, %r15d
jl 0x12ed
leal -0x2(%r15), %esi
movl %esi, %esi
movl 0x4(%rdi,%rsi,4), %r8d
incq %rsi
addl -0x4(%rax,%rsi,4), %r8d
movl %r8d, -0x4(%rdi,%rsi,4)
movl -0x8(%rcx,%rsi,4), %r9d
subl %r8d, %r9d
movl %r9d, %ebx
negl %ebx
cmovsl %r9d, %ebx
cmpl %edx, %ebx
cmovgel %edx, %ebx
decq %rsi
movl %ebx, %edx
cmpq $0x1, %rsi
jg 0x12c0
jmp 0x12ef
movl %edx, %ebx
testq %rdi, %rdi
je 0x1300
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x1090
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1315
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x1090
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x133c
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x1090
movq %rbx, %rdi
callq 0x10b0
// File: /workspace/github_cpp_makefile_star2_O1/conp-solutions[P]cnfmiter/AtLeastTwoSolutions.cc
// Function: generate_equivalence(CNFMITER::Formula&, CNFMITER::Lit, CNFMITER::Lit, CNFMITER::Lit)
void generate_equivalence(Formula &f, Lit a, Lit b, Lit c)
{
    static std::vector<Lit> C(3, a);

    C[0] = a;
    C[1] = b;
    C[2] = c;
    f.addClause_(C);

    C[0] = ~a;
    C[1] = ~b;
    C[2] = c;
    f.addClause_(C);

    C[0] = a;
    C[1] = ~b;
    C[2] = ~c;
    f.addClause_(C);

    C[0] = ~a;
    C[1] = b;
    C[2] = ~c;
    f.addClause_(C);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %r13
movb 0x4ced(%rip), %al       # 0x7198
testb %al, %al
je 0x2558
leaq 0x4cc6(%rip), %rsi      # 0x7180
movq 0x4cbf(%rip), %rax      # 0x7180
movl %r12d, (%rax)
movl %r14d, 0x4(%rax)
movl %ebx, 0x8(%rax)
addq $0x8, %r13
movq %r13, %rdi
callq 0x3c62
movl %r12d, %r15d
xorl $0x1, %r12d
movq 0x4c9b(%rip), %rax      # 0x7180
movl %r12d, (%rax)
movl %r14d, -0x2c(%rbp)
xorl $0x1, %r14d
movl %r14d, 0x4(%rax)
movl %ebx, 0x8(%rax)
movq %r13, %rdi
leaq 0x4c7f(%rip), %rsi      # 0x7180
callq 0x3c62
movq 0x4c73(%rip), %rax      # 0x7180
movl %r15d, (%rax)
movl %r14d, 0x4(%rax)
xorl $0x1, %ebx
movl %ebx, 0x8(%rax)
movq %r13, %rdi
leaq 0x4c5c(%rip), %r14      # 0x7180
movq %r14, %rsi
callq 0x3c62
movq 0x4c4d(%rip), %rax      # 0x7180
movl %r12d, (%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl %ebx, 0x8(%rax)
movq %r13, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c62
leaq 0x4c39(%rip), %rdi      # 0x7198
callq 0x2280
testl %eax, %eax
je 0x24b3
xorps %xmm0, %xmm0
movups %xmm0, 0x4c0a(%rip)     # 0x7180
movq $0x0, 0x4c0f(%rip) # 0x7190
movl $0xc, %edi
callq 0x2180
movq %rax, 0x4bee(%rip)      # 0x7180
movq %rax, 0x4bef(%rip)      # 0x7188
movq %rax, %rcx
addq $0xc, %rcx
movq %rcx, 0x4be9(%rip)      # 0x7190
xorl %edx, %edx
movl %r12d, (%rax,%rdx)
addq $0x4, %rdx
cmpq $0xc, %rdx
jne 0x25a9
movq %rcx, 0x4bca(%rip)      # 0x7188
leaq 0x4bbb(%rip), %rsi      # 0x7180
leaq 0x1602(%rip), %rdi      # 0x3bce
leaq 0x4b8d(%rip), %rdx      # 0x7160
callq 0x2140
leaq 0x4bb9(%rip), %rdi      # 0x7198
callq 0x20e0
jmp 0x24b3
movq %rax, %rbx
leaq 0x4ba5(%rip), %rdi      # 0x7198
callq 0x20d0
movq %rbx, %rdi
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/conp-solutions[P]cnfmiter/./ParseUtils.h
// Function: int CNFMITER::parseInt<CNFMITER::StreamBuffer>(CNFMITER::StreamBuffer&)
static int parseInt(B &in)
{
    int val = 0;
    bool neg = false;
    skipWhitespace(in);
    if (*in == '-')
        neg = true, ++in;
    else if (*in == '+')
        ++in;
    if (*in < '0' || *in > '9') fprintf(stderr, "PARSE ERROR! Unexpected char: %c\n", *in), exit(3);
    while (*in >= '0' && *in <= '9') val = val * 10 + (*in - '0'), ++in;
    return neg ? -val : val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x3a77
movslq 0x100008(%rbx), %rax
movl 0x10000c(%rbx), %ecx
cmpl %ecx, %eax
jge 0x3aff
cmpb $0x2d, 0x8(%rbx,%rax)
sete %r14b
jmp 0x3b02
xorl %r14d, %r14d
testb %r14b, %r14b
je 0x3b11
movq %rbx, %rdi
callq 0x3f0c
jmp 0x3b1c
cmpl %ecx, %eax
jge 0x3b1c
cmpb $0x2b, 0x8(%rbx,%rax)
je 0x3b07
movslq 0x100008(%rbx), %rdx
movl 0x10000c(%rbx), %eax
cmpl %eax, %edx
jge 0x3bbe
cmpb $0x30, 0x8(%rbx,%rdx)
jb 0x3bbe
cmpl %eax, %edx
jge 0x3b47
cmpb $0x3a, 0x8(%rbx,%rdx)
jae 0x3bbe
movl 0x100008(%rbx), %ecx
xorl %r15d, %r15d
cmpl 0x10000c(%rbx), %ecx
setl %al
jge 0x3ba7
xorl %r15d, %r15d
movslq %ecx, %rcx
cmpb $0x30, 0x8(%rbx,%rcx)
jb 0x3ba7
testb $0x1, %al
je 0x3b73
cmpb $0x39, 0x8(%rbx,%rcx)
ja 0x3ba7
movl $0xffffffcf, %edx       # imm = 0xFFFFFFCF
testb $0x1, %al
je 0x3b84
movzbl 0x8(%rbx,%rcx), %edx
addl $-0x30, %edx
addl %r15d, %r15d
leal (%r15,%r15,4), %r15d
addl %edx, %r15d
movq %rbx, %rdi
callq 0x3f0c
movl 0x100008(%rbx), %ecx
cmpl 0x10000c(%rbx), %ecx
setl %al
jl 0x3b5e
movl %r15d, %eax
negl %eax
testb %r14b, %r14b
cmovel %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
cmpl %eax, %edx
setl %dil
movq %rbx, %rsi
callq 0x2335
// File: /workspace/github_cpp_makefile_star2_O1/m1c0l[P]http-client-server/HttpMessage.cpp
// Function: HttpMessage::decodeHeaderLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int HttpMessage::decodeHeaderLine(string line)
{
	string key, value;
	size_t i = 0;
	i = line.find(":");

	if (i == string::npos || i == 0 || i == line.size() - 1) {
		return 400;
	}

	key = line.substr(0, i);
	i++;
	while(line[i] == ' ')
		i++;
	value = line.substr(i, line.size());
	setHeader(key, value);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
xorl %eax, %eax
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x473e(%rip), %rsi      # 0x9004
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4530
movq %rax, %r15
incq %rax
movl $0x190, %ebp            # imm = 0x190
cmpq $0x2, %rax
jb 0x4a2c
movq 0x8(%r14), %rax
decq %rax
cmpq %rax, %r15
je 0x4a2c
movq %r12, %rbp
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x43a0
leaq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %r12
movq %r12, %rsi
callq 0x4420
movq (%r12), %rdi
leaq 0x98(%rsp), %r12
cmpq %r12, %rdi
je 0x4948
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x4370
movq (%r14), %rax
cmpb $0x20, 0x1(%rax,%r15)
leaq 0x1(%r15), %r15
je 0x494b
movq 0x8(%r14), %rcx
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x43a0
leaq 0x8(%rsp), %rdi
leaq 0x88(%rsp), %r14
movq %r14, %rsi
callq 0x4420
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x499b
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x4370
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
movq %rbp, %r12
callq 0x5100
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x5100
addq $0x28, %rbx
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x5190
leaq 0x48(%rsp), %rsi
movq %rax, %rdi
callq 0x41c0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a13
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x68(%rsp), %rdi
xorl %ebp, %ebp
cmpq %r14, %rdi
je 0x4a2c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x4a43
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x4a5a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4370
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4a96
jmp 0x4a77
jmp 0x4a77
movq %rax, %rbx
jmp 0x4aad
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a96
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4aad
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x4ac4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4370
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x4adb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4370
movq %rbx, %rdi
callq 0x4550
nop
// File: /workspace/github_cpp_makefile_star2_O1/m1c0l[P]http-client-server/web-server.cpp
// Function: codeToDescription[abi:cxx11](int)
string codeToDescription (int code)
{
	switch (code) {
		case 200:
			return "OK";
		case 400:
			return "Bad request";
		case 404:
			return "Not found";
		case 408:
			return "Request timeout";
		case 501:
			return "Not implemented";
		case 505:
			return "HTTP version not supported";
		default:
			perror("code number");
			return "";
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x197, %esi            # imm = 0x197
jg 0x657e
cmpl $0xc8, %esi
je 0x65ad
cmpl $0x190, %esi            # imm = 0x190
je 0x65db
cmpl $0x194, %esi            # imm = 0x194
jne 0x6614
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2b17(%rip), %rsi      # 0x9089
leaq 0x2b19(%rip), %rdx      # 0x9092
jmp 0x6607
cmpl $0x198, %esi            # imm = 0x198
je 0x65c4
cmpl $0x1f5, %esi            # imm = 0x1F5
je 0x65f2
cmpl $0x1f9, %esi            # imm = 0x1F9
jne 0x6614
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2b0f(%rip), %rsi      # 0x90b3
leaq 0x2b22(%rip), %rdx      # 0x90cd
jmp 0x6607
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2abf(%rip), %rsi      # 0x907a
leaq 0x2aba(%rip), %rdx      # 0x907c
jmp 0x6607
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2ac1(%rip), %rsi      # 0x9093
leaq 0x2ac9(%rip), %rdx      # 0x90a2
jmp 0x6607
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2a94(%rip), %rsi      # 0x907d
leaq 0x2a98(%rip), %rdx      # 0x9088
jmp 0x6607
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2aa3(%rip), %rsi      # 0x90a3
leaq 0x2aab(%rip), %rdx      # 0x90b2
movq %rbx, %rdi
callq 0x561a
movq %rbx, %rax
popq %rbx
retq
movq %rbx, %rdi
callq 0x45f4
jmp 0x660f
// File: /workspace/github_cpp_makefile_star2_O1/m1c0l[P]http-client-server/web-server.cpp
// Function: int waitFor<long>(std::future<long>&)
int waitFor(future<T>& promise) {
  chrono::seconds timer(timeout);

  if (promise.wait_for(timer) == future_status::timeout) {
    cerr << "Connection timed out.\n"; 
    return -1;
  }
  return 0;
}

// Assembly:
pushq %rax
movq %rsp, %rsi
movq $0xa, (%rsi)
callq 0x8b12
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0x78d1
movq 0x5735(%rip), %rdi      # 0xcff0
leaq 0x18f6(%rip), %rsi      # 0x91b8
movl $0x16, %edx
callq 0x4400
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rcx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/jBlinden[P]private-codis/ProtocolClient.cpp
// Function: main
int main(int argc, const char **argv)
{
  if (argc < 5)
  {
    cout << "usage: ./ProtocolClient ProtocolArgsFile clientDataDir addr port" << endl;
    return 1;
  }

  srand(time(NULL));

  int port = atoi(argv[4]);

  string pArgsFile(argv[1]);
  string clientDataDir(argv[2]);

  StartClient(argv[3], port, pArgsFile, clientDataDir);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
cmpl $0x4, %edi
jg 0x35b2
movq 0x5a6b(%rip), %rbx      # 0x8fd8
leaq 0x2bb7(%rip), %rsi      # 0x612b
movl $0x40, %edx
movq %rbx, %rdi
callq 0x22c0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0x1, %eax
jmp 0x3693
movq %rsi, %r14
xorl %edi, %edi
callq 0x2200
movl %eax, %edi
callq 0x2220
movq 0x20(%r14), %rdi
callq 0x2370
movl %eax, %ebx
movq 0x8(%r14), %rsi
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2100
movq 0x10(%r14), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x2100
movq 0x18(%r14), %r14
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x3792
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x3792
leaq 0x48(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x313d
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x365c
callq 0x2210
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x366b
callq 0x2210
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x367e
callq 0x2210
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3691
callq 0x2210
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x36b9
callq 0x2210
jmp 0x36b9
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x36cd
callq 0x2210
jmp 0x36cd
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36e5
callq 0x2210
jmp 0x36e5
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36f8
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O1/jBlinden[P]private-codis/./socket.h
// Function: CSocket::Close()
void Close() {
    if (m_hSock == INVALID_SOCKET) {
      return;
    }
    
    shutdown(m_hSock, SHUT_WR);
    close(m_hSock);
  
    m_hSock = INVALID_SOCKET; 
  }

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
cmpl $-0x1, %edi
je 0x3722
movl $0x1, %esi
callq 0x2320
movl (%rbx), %edi
callq 0x2460
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x3700
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2090
movl %eax, (%rbx)
cmpl $-0x1, %eax
je 0x3950
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2837(%rip), %rdx      # 0x612a
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x3822
movzwl %bp, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x51bc
movl %eax, %ebp
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3922
callq 0x2210
testb %bpl, %bpl
je 0x3950
movl (%rbx), %edi
movl $0x5, %esi
callq 0x2280
testl %eax, %eax
js 0x3950
movl (%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x20c0
movl %eax, %ecx
cmpl $-0x1, %eax
setne %al
je 0x3952
movl %ecx, (%rbx)
jmp 0x3952
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x396f
callq 0x2210
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O1/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 0x3700
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2090
movl %eax, (%r14)
xorl %ebx, %ebx
cmpl $-0x1, %eax
je 0x3a44
movb $0x1, %bpl
leaq 0x18(%rsp), %r15
movzwl %r13w, %r13d
movq %r15, %rdi
movq 0x10(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x2100
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %edx
movl $0x2710, %ecx           # imm = 0x2710
callq 0x526c
movl %eax, %r12d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x39ff
callq 0x2210
testb %r12b, %r12b
jne 0x3a48
movl $0x14, %edi
callq 0x2330
cmpl $0x3e7, %ebx            # imm = 0x3E7
setb %bpl
je 0x3a4c
movq %r14, %rdi
callq 0x3700
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2090
movl %eax, (%r14)
incl %ebx
cmpl $-0x1, %eax
jne 0x39c3
xorl %eax, %eax
jmp 0x3a4c
xorl %ebp, %ebp
jmp 0x3a4f
movb $0x1, %al
jmp 0x3a4c
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 %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x3a7b
callq 0x2210
movq %rbx, %rdi
callq 0x2400
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %r14
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
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
movq %rax, 0x120(%r14)
movl %ebx, %r13d
imulq %r12, %r13
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
imull 0x4(%r14), %esi
movq 0x120(%r14), %rcx
movl %ebx, %edi
movq %r12, %rdx
callq 0x477c
movq %r12, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2300
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %rbx
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
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 %rax, %r13
movq %r15, %rdi
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 0x477c
movq %r13, %rdi
callq 0x2300
movq %rsp, %r15
movl $0x10, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x22f0
leaq 0x10(%rbx), %rdi
movq %r15, %rsi
callq 0x5928
movq %rbx, %rdi
callq 0x410a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %ecx, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movl 0x4(%rsi), %r15d
cmpl %r15d, 0x4(%rdi)
jne 0x3ed4
movq %rsi, %rbx
movq %rdi, %r14
movzbl (%rsi), %r12d
cmpb %r12b, (%rdi)
jne 0x3ed4
leaq 0x120(%rsp), %rbp
movq %rbp, %rdi
callq 0x56fc
movq 0x120(%r14), %rsi
movl %r15d, %r13d
imull %r12d, %r13d
movq %rbp, %rdi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x5c1a
testl %r13d, %r13d
je 0x3e06
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl 0xc(%rsp), %ecx
shlxl %ecx, %eax, %eax
notb %al
movl %r13d, %ecx
xorl %edx, %edx
movq 0x120(%r14), %rsi
andb %al, (%rsi,%rdx)
incq %rdx
cmpq %rdx, %rcx
jne 0x3df4
leaq 0x10(%rsp), %rdi
callq 0x56fc
movq 0x120(%rbx), %rsi
leaq 0x10(%rsp), %rdi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x5c1a
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 0x3eab
movl $0x1, %eax
movl 0x8(%rsp), %ecx
shlxl %ecx, %eax, %ecx
decb %cl
xorl %edx, %edx
xorl %esi, %esi
movq 0x120(%rbx), %rdi
movzbl (%rdi,%rsi), %eax
divb %r12b
movzbl %ah, %eax
movb %al, (%rdi,%rsi)
movq 0x120(%r14), %rax
movq 0x120(%rbx), %rdi
movq 0x128(%rbx), %r8
movzbl (%rdi,%rsi), %edi
addl %edx, %edi
movb (%rax,%rdi), %al
andb %cl, %al
movb %al, (%r8,%rsi)
incq %rsi
addl %r12d, %edx
cmpq %rsi, %r15
jne 0x3e68
leaq 0x10(%rsp), %rdi
callq 0x5aca
leaq 0x120(%rsp), %rdi
callq 0x5aca
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2120
leaq 0x2394(%rip), %rcx      # 0x6279
movq %rcx, (%rax)
movq 0x50d1(%rip), %rsi      # 0x8fc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x23d0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5aca
jmp 0x3f0d
jmp 0x3f0a
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x5aca
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O1/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 0x3f60
testl %ecx, %ecx
je 0x3f5e
movq %rdx, %r8
movl %ecx, %ecx
xorl %r9d, %r9d
movq 0x120(%rsi), %rax
movzbl (%rax,%r9), %eax
movzbl (%r8,%r9), %edx
subl %edx, %eax
movzbl (%rsi), %r10d
addl %r10d, %eax
cltd
idivl %r10d
movb %dl, (%rdi,%r9)
incq %r9
cmpq %r9, %rcx
jne 0x3f34
popq %rax
retq
movl $0x8, %edi
callq 0x2120
leaq 0x2332(%rip), %rcx      # 0x62a3
movq %rcx, (%rax)
movq 0x5045(%rip), %rsi      # 0x8fc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O1/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 0x4030
movl %r9d, %r12d
movl %r8d, %ebp
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movzbl (%rsi), %eax
imull %r8d, %eax
movq %rdx, %rsi
movq %rax, %rdx
callq 0x21b0
testl %ebp, %ebp
je 0x4027
movl $0x1, %eax
shlxl %r12d, %eax, %ecx
decb %cl
movl %ebp, %esi
xorl %edi, %edi
movzbl (%r14), %r10d
testl %r10d, %r10d
je 0x401f
xorl %r8d, %r8d
movq %r15, %r9
movq 0x120(%r14), %r11
movzbl (%rbx,%rdi), %eax
addl %r8d, %eax
xorl %edx, %edx
divl %r10d
movl %r10d, %eax
imull %edi, %r10d
addq %rdx, %r10
movb (%r11,%r10), %dl
imulq %rdi, %rax
xorb %dl, (%r9,%rax)
movzbl (%r14), %eax
imulq %rdi, %rax
andb %cl, (%r9,%rax)
incl %r8d
movzbl (%r14), %r10d
incq %r9
cmpl %r10d, %r8d
jb 0x3fdb
incq %rdi
cmpq %rsi, %rdi
jne 0x3fcc
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2120
leaq 0x2262(%rip), %rcx      # 0x62a3
movq %rcx, (%rax)
movq 0x4f75(%rip), %rsi      # 0x8fc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O1/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 0x40e4
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x128(%rsi), %rsi
movl %r8d, %r13d
movq %r13, %rdx
callq 0x21b0
testl %ebp, %ebp
je 0x40d5
movb 0x40(%rsp), %al
movl $0x1, %ecx
shlxl %eax, %ecx, %eax
decb %al
movl 0x4(%rsp), %edx
shlxl %edx, %ecx, %ecx
decb %cl
xorl %edx, %edx
movzbl (%r15), %esi
imull %edx, %esi
movzbl (%r14,%rdx), %edi
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 0x40ad
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2120
leaq 0x21ae(%rip), %rcx      # 0x62a3
movq %rcx, (%rax)
movq 0x4ec1(%rip), %rsi      # 0x8fc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x23d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %rbx
movl 0x4(%rdi), %r14d
movq %r14, %rdi
callq 0x2030
movq %rax, 0x120(%rbx)
leaq 0x10(%rbx), %rdi
movq %rax, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x5c1a
cmpl $0x0, 0x4(%rbx)
je 0x415b
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 0x413d
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x42bc
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 0x536c
movq 0x4e32(%rip), %r12      # 0x8fd8
leaq 0x2147(%rip), %rsi      # 0x62f4
movl $0xb, %edx
movq %r12, %rdi
callq 0x22c0
movzbl (%rbx), %esi
movq %r12, %rdi
callq 0x2160
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2230
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movzbl (%r13), %edi
imull %ebp, %edi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
movl %ebp, %r8d
movl $0x8, %r9d
callq 0x3f85
movzbl (%r13), %edx
imull %ebp, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x541e
leaq 0x20cc(%rip), %rsi      # 0x6300
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
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
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
leaq 0x1ffd(%rip), %rcx      # 0x62ca
movq %rcx, (%rax)
movq 0x4ce9(%rip), %rsi      # 0x8fc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x23d0
// File: /workspace/github_cpp_makefile_star2_O1/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
movl %r9d, %ebp
movl %r8d, %r15d
movl %ecx, %r12d
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x130(%rsp), %rdi
movl %edx, %esi
movl %ecx, %edx
callq 0x3a84
movq %rsp, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x3bdc
movzbl %r15b, %r15d
movzbl %bpl, %ebp
leaq 0x130(%rsp), %rdi
movq %rsp, %rsi
movl %r15d, %edx
movl %ebp, %ecx
callq 0x3d75
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x45a2
movq %rsp, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x4620
movq %rsp, %rdi
callq 0x3d42
leaq 0x130(%rsp), %rdi
callq 0x3bba
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x458d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3d42
leaq 0x130(%rsp), %rdi
callq 0x3bba
movq %rbx, %rdi
callq 0x2400
// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %r14
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2310
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2310
movzbl (%r14), %esi
imull 0x4(%r14), %esi
movq 0x120(%r14), %rdx
movl %ebp, %edi
callq 0x46ab
movq %rax, %r15
movzbl (%r14), %eax
imull 0x4(%r14), %eax
movl %ebp, %edx
imulq %rax, %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2310
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2300
// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %r14
leaq 0x4(%rdi), %rsi
movl $0x4, %edx
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 0x46ab
movq %rax, %r15
movl 0x4(%r14), %eax
movl %ebp, %edx
imulq %rax, %rdx
addq $0x7, %rdx
shrq $0x3, %rdx
movq %rbx, %rdi
movq %r15, %rsi
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