LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::print_test[abi:cxx11]()
string Matrix::print_test(){
  std::stringstream ss;
  for( uint i = 0; i < _m; i++ ){
    for( uint j = 0; j < _n; j++ ){
      ss << _data[i][j] << " ";  
    }
  }
  string s = ss.str();
  return s.substr(0, s.size()-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x20c0
cmpl $0x0, 0x18(%r14)
je 0x2bcb
leaq 0x40(%rsp), %r15
xorl %r13d, %r13d
leaq 0x65ff(%rip), %r12      # 0x917a
cmpl $0x0, 0x1c(%r14)
je 0x2bbf
leaq (,%r13,2), %rbp
addq %r13, %rbp
xorl %ebx, %ebx
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r15, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2170
incq %rbx
movl 0x1c(%r14), %eax
cmpq %rax, %rbx
jb 0x2b8f
incq %r13
movl 0x18(%r14), %eax
cmpq %rax, %r13
jb 0x2b7b
leaq 0x48(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x21a0
leaq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rcx
decq %rcx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2160
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c10
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2140
movq 0xa3a9(%rip), %rsi      # 0xcfc0
leaq 0x30(%rsp), %rdi
callq 0x20e0
leaq 0xb0(%rsp), %rdi
callq 0x2060
movq %rbx, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c68
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x2c68
jmp 0x2c65
movq %rax, %rbx
movq 0xa351(%rip), %rsi      # 0xcfc0
leaq 0x30(%rsp), %rdi
callq 0x20e0
leaq 0xb0(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::addToRow(Matrix const&, unsigned int)
Matrix Matrix::addToRow( const Matrix& rhs, const uint row ){
  if( (row > 0 && row <= _m) || rhs._m != 1 ){
    Matrix result = *this;
    for( uint i = 0; i < _n; i++ ){
      result._data[row-1][i] = result._data[row-1][i] + rhs._data[0][i];
    }
    return result;
  }
  else {
    _error = 1;
    return *this;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
decl %r15d
cmpl 0x18(%rsi), %r15d
jb 0x2d2f
cmpl $0x1, 0x18(%r14)
jne 0x2d2f
movb $0x1, 0x31(%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2870
jmp 0x2d6e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2870
movl 0x1c(%r12), %eax
testq %rax, %rax
je 0x2d6e
movq (%rbx), %rcx
leaq (%r15,%r15,2), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%r14), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
addsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x2d57
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::ADDToRow(Matrix const&, unsigned int)
Matrix& Matrix::ADDToRow( const Matrix& rhs, const uint row ){
  if( (row > 0 && row <= _m) || rhs._m != 1 ){
    for( uint i = 0; i < _n; i++ ){
      _data[row-1][i] = _data[row-1][i] + rhs._data[0][i];
    }
  }
  else {
    _error = 1;
  }
  return *this;
}

// Assembly:
movq %rdi, %rax
decl %edx
cmpl 0x18(%rdi), %edx
jb 0x2d93
cmpl $0x1, 0x18(%rsi)
jne 0x2d93
movb $0x1, 0x31(%rax)
retq
movl 0x1c(%rax), %ecx
testq %rcx, %rcx
je 0x2dc5
movq (%rax), %rdi
leaq (%rdx,%rdx,2), %rdx
movq (%rdi,%rdx,8), %rdx
movq (%rsi), %rsi
movq (%rsi), %rsi
xorl %edi, %edi
movsd (%rdx,%rdi,8), %xmm0
addsd (%rsi,%rdi,8), %xmm0
movsd %xmm0, (%rdx,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x2dae
retq
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::switchRows(unsigned int, unsigned int)
Matrix Matrix::switchRows( const uint row1, const uint row2 ){
  Matrix result = *this;
  vector<double> temp = result._data[row1-1];
  result._data[row1-1] = result._data[row2-1];
  result._data[row2-1] = temp;
  return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %ecx, %r14d
movl %edx, %r15d
movq %rdi, %rbx
callq 0x2870
decl %r15d
leaq (%r15,%r15,2), %r15
leaq (,%r15,8), %rsi
addq (%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x446e
decl %r14d
movq (%rbx), %rax
leaq (%r14,%r14,2), %r14
leaq (%rax,%r14,8), %rsi
leaq (%rax,%r15,8), %rdi
callq 0x42cc
shlq $0x3, %r14
addq (%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x42cc
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2e3b
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r14
jmp 0x2e67
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2e67
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x4106
movq %r14, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::SWITCHRows(unsigned int, unsigned int)
Matrix& Matrix::SWITCHRows( const uint row1, const uint row2 ){
  vector<double> temp = _data[row1-1];
  _data[row1-1] = _data[row2-1];
  _data[row2-1] = temp;
  return *this;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %edx, %r14d
movq %rdi, %rbx
decl %esi
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %r15
movq (%rdi), %rsi
addq %r15, %rsi
leaq 0x8(%rsp), %rdi
callq 0x446e
decl %r14d
movq (%rbx), %rdi
leaq (%r14,%r14,2), %r14
leaq (%rdi,%r14,8), %rsi
addq %r15, %rdi
callq 0x42cc
shlq $0x3, %r14
addq (%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x42cc
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2ee2
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2f09
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::multiplyRow(double, unsigned int)
Matrix Matrix::multiplyRow( const double d, const uint row ){
  if( row > 0 && row <= _m ){
    Matrix result = *this;
    for( uint i = 0; i < _n; i++ ){
      result._data[row-1][i] = result._data[row-1][i] * d;
    }
    return result;
  }
  else {
    _error = 1;
    return *this;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
decl %r14d
cmpl 0x18(%rsi), %r14d
jae 0x2f72
movq %rbx, %rdi
movq %r15, %rsi
movsd %xmm0, 0x8(%rsp)
callq 0x2870
movsd 0x8(%rsp), %xmm1
movl 0x1c(%r15), %eax
testq %rax, %rax
je 0x2f82
movq (%rbx), %rcx
leaq (%r14,%r14,2), %rdx
movq (%rcx,%rdx,8), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x2f5a
jmp 0x2f82
movb $0x1, 0x31(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2870
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::MULTIPLYRow(double, unsigned int)
Matrix& Matrix::MULTIPLYRow( const double d, const uint row ){
  if( row > 0 && row <= _m ){
    for( uint i = 0; i < _n; i++ ){
      _data[row-1][i] = _data[row-1][i] * d;
    }
  }
  else {
    _error = 1;
  }
  return *this;
}

// Assembly:
movq %rdi, %rax
decl %esi
cmpl 0x18(%rdi), %esi
jae 0x2fc6
movl 0x1c(%rax), %ecx
testq %rcx, %rcx
je 0x2fc5
movq (%rax), %rdx
leaq (%rsi,%rsi,2), %rsi
movq (%rdx,%rsi,8), %rdx
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x2faf
retq
movb $0x1, 0x31(%rax)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::submatrix(unsigned int, unsigned int, unsigned int, unsigned int)
Matrix Matrix::submatrix( uint row, uint col, uint rows, uint cols ){
  if( row + rows - 1 <= _m && col + cols - 1 <= _n && rows != 0 && cols != 0 ){
    Matrix result( rows, cols );
    for( uint i = 0; i < rows; i++ ){
      for( uint j = 0; j < cols; j++ ){
	result._data[i][j] = _data[i+row-1][j+col-1];
      }
    }
    return result;
  }
  else {
    _error = 1;
    return *this;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r13d
movl %edx, %r15d
movq %rsi, %rbp
movq %rdi, %rbx
leal (%r15,%r13), %eax
decl %eax
cmpl 0x18(%rsi), %eax
jbe 0x3313
movb $0x1, 0x31(%rbp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2870
jmp 0x3388
movl %r9d, %r12d
testl %r9d, %r9d
je 0x3302
testl %r13d, %r13d
je 0x3302
movl %ecx, %r14d
leal (%r14,%r12), %eax
decl %eax
cmpl 0x1c(%rbp), %eax
ja 0x3302
movq %rbx, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x2704
decl %r15d
movq (%rbp), %rax
decl %r14d
movq (%rbx), %rcx
movl %r13d, %edx
movl %r12d, %esi
xorl %edi, %edi
leal (%r15,%rdi), %r8d
leaq (%r8,%r8,2), %r8
movq (%rax,%r8,8), %r8
leaq (%rdi,%rdi,2), %r9
movq (%rcx,%r9,8), %r9
xorl %r10d, %r10d
leal (%r14,%r10), %r11d
movsd (%r8,%r11,8), %xmm0
movsd %xmm0, (%r9,%r10,8)
incq %r10
cmpq %r10, %rsi
jne 0x3368
incq %rdi
cmpq %rdx, %rdi
jne 0x3351
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::add(Matrix const&)
Matrix Matrix::add( const Matrix& rhs ){
  if( _m == rhs._m && _n == rhs._n ){
    Matrix result = *this;
    for( uint i = 0; i < _m; i++ ){
      for( uint j = 0; j < _n; j++ ){
	result._data[i][j] = result._data[i][j] + rhs._data[i][j];
      }
    }
    return result;
  }
  else {
    _error = 1;
    return *this;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0x18(%rsi), %eax
cmpl 0x18(%rdx), %eax
jne 0x3489
movq %rdx, %r15
movl 0x1c(%r14), %eax
cmpl 0x1c(%rdx), %eax
jne 0x3489
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2870
movl 0x18(%r14), %eax
testq %rax, %rax
je 0x3499
movl 0x1c(%r14), %ecx
movq (%rbx), %rdx
movq (%r15), %rsi
xorl %edi, %edi
testq %rcx, %rcx
je 0x347f
leaq (,%rdi,8), %r8
leaq (%r8,%r8,2), %r9
movq (%rdx,%r9), %r8
movq (%rsi,%r9), %r9
xorl %r10d, %r10d
movsd (%r8,%r10,8), %xmm0
addsd (%r9,%r10,8), %xmm0
movsd %xmm0, (%r8,%r10,8)
incq %r10
cmpq %r10, %rcx
jne 0x3465
incq %rdi
cmpq %rax, %rdi
jne 0x3449
jmp 0x3499
movb $0x1, 0x31(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2870
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::mul(Matrix const&)
Matrix Matrix::mul( const Matrix& rhs ){
  if( _n == rhs._m ){
    Matrix result( _m, rhs._n );
    for( uint i = 0; i < _m; i++ ){
      for( uint j = 0; j < rhs._n; j++ ){
	int sum = 0;
	for( uint k = 0; k < _n; k++ ){
	  sum = sum + ( _data[i][k] * rhs._data[k][j] );
	}
	result._data[i][j] = sum;
      }
    }
    return result;
  }
  else {
    _error = 1;
    return *this;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl 0x1c(%rsi), %eax
cmpl 0x18(%rdx), %eax
jne 0x36d2
movq %rdx, %r15
movl 0x18(%r14), %esi
movl 0x1c(%rdx), %edx
movq %rdi, (%rsp)
callq 0x2704
movl 0x18(%r14), %eax
testq %rax, %rax
je 0x36cc
movl 0x1c(%r15), %ecx
movl 0x1c(%r14), %edx
movq (%rsp), %rsi
movq (%rsi), %rsi
xorl %edi, %edi
testq %rcx, %rcx
je 0x36c4
leaq (,%rdi,8), %r8
leaq (%r8,%r8,2), %r10
movq (%r14), %r8
addq %r10, %r8
movq (%r15), %r9
movq (%rsi,%r10), %r10
xorl %r11d, %r11d
testq %rdx, %rdx
je 0x36b2
movq (%r8), %r12
xorl %r13d, %r13d
movq %r9, %rbp
xorl %ebx, %ebx
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movsd (%r12,%r13,8), %xmm1
movq (%rbp), %rbx
mulsd (%rbx,%r11,8), %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebx
incq %r13
addq $0x18, %rbp
cmpq %r13, %rdx
jne 0x367e
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
jmp 0x36b6
xorpd %xmm0, %xmm0
movsd %xmm0, (%r10,%r11,8)
incq %r11
cmpq %rcx, %r11
jne 0x366e
incq %rdi
cmpq %rax, %rdi
jne 0x364d
movq (%rsp), %rax
jmp 0x36e5
movb $0x1, 0x31(%r14)
movq %rdi, %rbx
movq %r14, %rsi
callq 0x2870
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::mul(double const&)
Matrix Matrix::mul( const double& in ){
  Matrix result = *this;
  for( uint i = 0; i < _m; i++ ){
    for( uint j = 0; j < _n; j++ ){
      result._data[i][j] = result._data[i][j] * in;
    }
  }
  return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
callq 0x2870
movl 0x18(%r15), %eax
testq %rax, %rax
je 0x3757
movl 0x1c(%r15), %ecx
movq (%r14), %rdx
xorl %esi, %esi
testq %rcx, %rcx
je 0x374f
leaq (%rsi,%rsi,2), %rdi
movq (%rdx,%rdi,8), %rdi
xorl %r8d, %r8d
movsd (%rdi,%r8,8), %xmm0
mulsd (%rbx), %xmm0
movsd %xmm0, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rcx
jne 0x3737
incq %rsi
cmpq %rax, %rsi
jne 0x3727
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::exp(int)
Matrix Matrix::exp( const int power ){
  if( _m == _n && power > 0){
    Matrix result = *this;
    for( int i = 1; i < power; i++ ){
      result *= *this;
    }
    return result;
  }
  else {
    if( power == -1 ){ //Special case: Return the inverse.
      //return ~*this;
      return *this;
    }
    else {
      _error = 1;
      return *this;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
jle 0x38c9
movl 0x1c(%r14), %eax
cmpl %eax, 0x18(%r14)
jne 0x38c9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2870
cmpl $0x2, %ebp
jl 0x38de
decl %ebp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3760
decl %ebp
jne 0x38b8
jmp 0x38de
cmpl $-0x1, %ebp
je 0x38d3
movb $0x1, 0x31(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2870
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x4106
movq %r14, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::EXP(int)
Matrix& Matrix::EXP( const int power ){
  if( _m == _n && power > 0){
    Matrix result = *this;
    for( int i = 1; i < power; i++ ){
      *this *= result;
    }
    return *this;
  }
  else {
    if( power == -1 ){ //Special case: Return the inverse.
      //return !*this;
      return *this;
    }
    else {
      _error = 1;
      return *this;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movl %esi, %ebp
movq %rdi, %rbx
testl %esi, %esi
jle 0x394f
movl 0x1c(%rbx), %eax
cmpl %eax, 0x18(%rbx)
jne 0x394f
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x2870
cmpl $0x2, %ebp
jl 0x3945
decl %ebp
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3760
decl %ebp
jne 0x3936
movq %rsp, %rdi
callq 0x4106
jmp 0x3958
cmpl $-0x1, %ebp
je 0x3958
movb $0x1, 0x31(%rbx)
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x4106
movq %rbx, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::trans()
Matrix Matrix::trans(){
  Matrix result( _n, _m );
  for( uint i = 0; i < _m; i++ ){
    for( uint j = 0; j < _n; j++ ){
      result._data[j][i] = _data[i][j];
    }
  }
  return result;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl 0x18(%rsi), %edx
movl 0x1c(%rsi), %esi
callq 0x2704
movl 0x18(%r14), %eax
testq %rax, %rax
je 0x3e62
movl 0x1c(%r14), %ecx
movq (%r14), %rdx
movq (%rbx), %rsi
xorl %edi, %edi
testq %rcx, %rcx
je 0x3e5a
leaq (%rdi,%rdi,2), %r8
movq (%rdx,%r8,8), %r8
movq %rsi, %r9
xorl %r10d, %r10d
movsd (%r8,%r10,8), %xmm0
movq (%r9), %r11
movsd %xmm0, (%r11,%rdi,8)
incq %r10
addq $0x18, %r9
cmpq %r10, %rcx
jne 0x3e3f
incq %rdi
cmpq %rax, %rdi
jne 0x3e2c
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::det()
double Matrix::det(){
  if( _det_up_to_date )
    return _determinant;
  else {
    if( _m != _n ){
      return 0;
    }
    _det_up_to_date = true;
    _determinant = _det( *this );
    return _determinant;
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x38(%rdi)
je 0x3f34
movl 0x18(%rbx), %eax
xorpd %xmm0, %xmm0
cmpl 0x1c(%rbx), %eax
jne 0x3f3c
movb $0x1, 0x38(%rbx)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2870
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f5a
cvttsd2si %xmm0, %eax
movl %eax, 0x34(%rbx)
leaq 0x8(%rsp), %rdi
callq 0x4106
xorps %xmm0, %xmm0
cvtsi2sdl 0x34(%rbx), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4106
movq %rbx, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/matrix.cpp
// Function: Matrix::_det(Matrix)
double Matrix::_det( Matrix in ){  
  uint rows = in._m;
  uint cols = in._n;
  if( rows == 2 ){
    return in._data[0][0]*in._data[1][1] - in._data[1][0]*in._data[0][1];
  }
  if( rows == 1 ){
    return in._data[0][0];
  }
  double sum = 0.0;
  int sign = 1;
  for( uint iter = 0; iter < in._m; iter++ ){
    Matrix out( rows - 1, cols - 1 );
    for( uint i = 1; i < in._m; i++ ){
      for( uint j = 0; j < in._n; j++ ){
	if( j != iter ){
	  out << in._data[i][j];
	}
      }
    }
    sum = sum + in._data[0][iter] * sign * _det( out );
    sign = sign * -1;
  }
  return sum;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
movl 0x18(%rsi), %esi
cmpl $0x1, %esi
je 0x3fa5
cmpl $0x2, %esi
jne 0x3fb4
movq (%rbx), %rax
movq (%rax), %rcx
movq 0x18(%rax), %rax
movsd (%rcx), %xmm0
movsd 0x8(%rcx), %xmm1
mulsd (%rax), %xmm1
mulsd 0x8(%rax), %xmm0
subsd %xmm1, %xmm0
jmp 0x40c9
movq (%rbx), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
jmp 0x40bf
cmpl $0x0, 0x18(%rbx)
je 0x40bb
movl 0x1c(%rbx), %eax
decl %esi
decl %eax
movl %eax, 0x10(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movl $0x1, %ebp
xorl %r15d, %r15d
leaq 0x68(%rsp), %r12
movl %esi, 0xc(%rsp)
movl %ebp, 0x14(%rsp)
movq %r12, %rdi
movl 0x10(%rsp), %edx
callq 0x2704
cmpl $0x2, 0x18(%rbx)
jb 0x4042
movl $0x1, %ebp
cmpl $0x0, 0x1c(%rbx)
je 0x4037
leaq (,%rbp,2), %r13
addq %rbp, %r13
xorl %r14d, %r14d
cmpq %r14, %r15
je 0x402c
movq (%rbx), %rax
movq (%rax,%r13,8), %rax
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
callq 0x2950
incq %r14
movl 0x1c(%rbx), %eax
cmpq %rax, %r14
jb 0x4012
incq %rbp
movl 0x18(%rbx), %eax
cmpq %rax, %rbp
jb 0x3ffe
movq (%rbx), %rax
movq (%rax), %rax
movl 0x14(%rsp), %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x2870
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x3f5a
movsd 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x4106
negl %ebp
movq %r12, %rdi
callq 0x4106
incq %r15
movl 0x18(%rbx), %eax
cmpq %rax, %r15
movl 0xc(%rsp), %esi
jb 0x3fe3
jmp 0x40c4
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x4106
jmp 0x40ef
jmp 0x40ec
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4106
movq %rbx, %rdi
callq 0x21f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/hitc8494[P]Matrix/test.cpp
// Function: test(bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void test( bool pass, std::string message ){
  string s; s.assign( spaces, ' ' );
  cout << s;
  if( pass ){
    cout << "Passed - "; passed++;
  }
  else {
    cout << "FAILED - "; failed++;
  }
  cout << message << endl;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
movslq 0x8332(%rip), %rcx      # 0xd130
movq %rsp, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x20, %r8d
callq 0x2210
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x81b8(%rip), %rdi      # 0xcfd8
callq 0x2170
testb %bpl, %bpl
je 0x4e4b
movq 0x81a7(%rip), %rdi      # 0xcfd8
leaq 0x4330(%rip), %rsi      # 0x9168
movl $0x9, %edx
callq 0x2170
leaq 0x82eb(%rip), %rax      # 0xd134
jmp 0x4e6a
movq 0x8186(%rip), %rdi      # 0xcfd8
leaq 0x4319(%rip), %rsi      # 0x9172
movl $0x9, %edx
callq 0x2170
leaq 0x82ce(%rip), %rax      # 0xd138
incl (%rax)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x815e(%rip), %rdi      # 0xcfd8
callq 0x2170
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x4ebf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x4ee1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x21f0
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: logLineStart(char const*)
static void logLineStart(const char *prefix)
{
    time_t errTime;
    char buf[MY_TMP_BUF_LEN];
    char *lf;

    errTime = time(NULL);

    //ctime() adds '\n' to line end, change that to space
    strlcpy(buf, ((errTime != -1) ? ctime(&errTime) : ""), MY_TMP_BUF_LEN);
    lf = strchr(buf, '\n');
    if (NULL != lf)
        *lf = ' ';

    fprintf(stderr, "%s %s> ", prefix, buf);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
xorl %edi, %edi
callq 0x21c0
movq %rax, 0x8(%rsp)
cmpq $-0x1, %rax
jne 0x23a8
leaq 0x6234(%rip), %rsi      # 0x85da
jmp 0x23b5
leaq 0x8(%rsp), %rdi
callq 0x20c0
movq %rax, %rsi
leaq 0x10(%rsp), %r14
movl $0xff, %edx
movq %r14, %rdi
callq 0x5844
pushq $0xa
popq %rsi
movq %r14, %rdi
callq 0x20b0
testq %rax, %rax
je 0x23da
movb $0x20, (%rax)
movq 0x9bff(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
leaq 0x502e(%rip), %rsi      # 0x7419
leaq 0x10(%rsp), %rcx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22c0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: fatal(char const*, ...)
void fatal(const char *fmt, ...)
{
    va_list args;

    logLineStart("UltraVnc FATAL");
    
    va_start(args, fmt);
   
    vfprintf(stderr, fmt, args);
    va_end(args);
 
    //Close program down cleanly (as if user just pressed ctrl+c, of course 
    //log file will show FATAL message in case program shuts down)
    stopped = true;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %r14
movq %rsi, 0x8(%r14)
movq %rdx, 0x10(%r14)
movq %rcx, 0x18(%r14)
movq %r8, 0x20(%r14)
movq %r9, 0x28(%r14)
testb %al, %al
je 0x2466
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
leaq 0x4ba0(%rip), %rdi      # 0x700d
callq 0x2380
movq %rsp, %rdx
movq %r14, 0x10(%rdx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rdx)
movq 0x9b47(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x2290
movb $0x1, 0xa6c5(%rip)      # 0xcb70
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: debug(int, char const*, ...)
void debug(int msgLevel, const char *fmt, ...)
{
    va_list args;

    if (msgLevel <= loggingLevel) {
        logLineStart("UltraVnc");

        va_start(args, fmt);
    
        vfprintf(stderr, fmt, args);
        va_end(args);
    }
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x35b3
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
leaq 0x948a(%rip), %rax      # 0xca44
cmpl %edi, (%rax)
jge 0x35c7
addq $0xd0, %rsp
popq %rbx
retq
movq %rsi, %rbx
leaq 0x3a33(%rip), %rdi      # 0x7004
callq 0x2380
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
movq 0x89de(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x2290
jmp 0x35be
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: openConnectionToEventListener(char const*, unsigned short, char*, int)
int openConnectionToEventListener(const char *host, unsigned short port, char *listenerIp, int listenerIpSize)
{
    int s;
    struct sockaddr_in saddr;
    struct hostent *h;
        
    h = gethostbyname(host);
    if (NULL == h) {
        debug(LEVEL_2, "openConnectionToEventListener(): can't resolve hostname: %s\n", host);
        return -1;
    }
    saddr.sin_family = AF_INET;
    saddr.sin_port = htons(port);
    
    //Interesting;-) typecast / indirection thing copied from "Beej's Guide to network programming". 
    //See http://beej.us/guide/bgnet/ for more info
    saddr.sin_addr = *((struct in_addr *)h->h_addr);

    memset(&(saddr.sin_zero), '\0', 8); // zero the rest of the struct
    
    strlcpy(listenerIp, inet_ntoa(saddr.sin_addr), listenerIpSize);
    
    debug(LEVEL_3, "openConnectionToEventListener(): connecting to %s:%u\n", listenerIp, port);

    s = socket(AF_INET, SOCK_STREAM, 0);
    
    //Trying to connect with timeout
    if (connectWithTimeout(s, (struct sockaddr *) &saddr, sizeof(saddr), TIMEOUT_10SECS) != 0) {
        debug(LEVEL_2, "openConnectionToEventListener(): connectWithTimeout() failed.\n");
        close(s);
        strlcpy(listenerIp, "", listenerIpSize);
        return -1;
    }
    else
        return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
callq 0x2220
testq %rax, %rax
je 0x36db
leaq 0x8(%rsp), %r15
movw $0x2, (%r15)
movl %ebp, %ecx
rolw $0x8, %cx
movw %cx, 0x2(%r15)
movq 0x18(%rax), %rax
movq (%rax), %rax
movl (%rax), %edi
movl %edi, 0x4(%r15)
movq $0x0, 0x8(%r15)
callq 0x20e0
movslq %r14d, %r14
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5844
movzwl %bp, %ecx
leaq 0x39dc(%rip), %rsi      # 0x7059
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x355c
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2060
movl %eax, %ebp
movl %eax, %edi
movq %r15, %rsi
callq 0x3703
testl %eax, %eax
je 0x36f6
leaq 0x39db(%rip), %rsi      # 0x708f
movl $0x2, %edi
xorl %eax, %eax
callq 0x355c
movl %ebp, %edi
callq 0x2360
leaq 0x4f0c(%rip), %rsi      # 0x85da
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5844
jmp 0x36f1
leaq 0x393a(%rip), %rsi      # 0x701c
movl $0x2, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x355c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: writeExact(int, char*, int, int)
int writeExact(int sock, char *buf, int len, int timeOutSecs)
{
    int n;
    int timeOutCtr;

    debug(LEVEL_3, "writeExact(): start\n");
    timeOutCtr=0;
    while ((len > 0) && (timeOutCtr < timeOutSecs)) {
        n = send(sock, buf, len, MSG_DONTWAIT);

        if (n > 0) {
            buf += n;
            len -= n;
        }
        else if (n == 0) {
            debug(LEVEL_3, "writeExact(): send returned 0\n");
            return -1;
        }
        else {
            //send() returned -1 to indicate some error
            //Because we use non-blocking in send(), we have to 
            //handle EAGAIN by incrementing timeout counter
            if (errno == EAGAIN) {
                debug(LEVEL_3, "writeExact(): EAGAIN detected\n");
                sleep(1);
                timeOutCtr++;
            }
            else {
                debug(LEVEL_3, "writeExact(): send() returned error, errno = %d (%s)\n", errno, strerror(errno));
                return -1;
            }
        }
    }

    if (timeOutCtr <  timeOutSecs) {
        debug(LEVEL_3, "writeExact(): returning normally\n");
        return 1;
    }
    else {
        debug(LEVEL_3, "writeExact(): timeout error\n");
        return -2;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, %r14
movl %edi, %r15d
leaq 0x3741(%rip), %rsi      # 0x70ce
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
testl %ebp, %ebp
setle %cl
testl %ebx, %ebx
setg %al
setle %dl
orb %cl, %dl
jne 0x3a11
xorl %r12d, %r12d
movl %ebp, %edx
movl %r15d, %edi
movq %r14, %rsi
movl $0x40, %ecx
callq 0x2100
testl %eax, %eax
jle 0x39d2
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %r14
subl %eax, %ebp
jmp 0x3a02
je 0x3a49
callq 0x2030
movl (%rax), %r13d
cmpl $0xb, %r13d
jne 0x3a5e
movl $0x3, %edi
leaq 0x3714(%rip), %rsi      # 0x7102
xorl %eax, %eax
callq 0x355c
movl $0x1, %edi
callq 0x2160
incl %r12d
cmpl %ebx, %r12d
setl %al
testl %ebp, %ebp
jle 0x3a11
cmpl %ebx, %r12d
jl 0x39ad
testb %al, %al
je 0x3a2f
leaq 0x373b(%rip), %rsi      # 0x7157
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
movl $0x1, %eax
jmp 0x3a84
leaq 0x3743(%rip), %rsi      # 0x7179
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x3a84
leaq 0x3693(%rip), %rsi      # 0x70e3
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
jmp 0x3a7f
movl %r13d, %edi
callq 0x20a0
leaq 0x36b4(%rip), %rsi      # 0x7121
movl $0x3, %edi
movl %r13d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x355c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: isPeerDisconnected(int, int)
bool isPeerDisconnected(int socket, int connectionFrom)
{
    ssize_t n;

    char buf[SIZE_RFBPROTOCOLVERSIONMSG+1];
    buf[SIZE_RFBPROTOCOLVERSIONMSG] = '\0';
    
    n = recv(socket, buf, SIZE_RFBPROTOCOLVERSIONMSG, MSG_DONTWAIT);

    if (n == 0) {
        debug(LEVEL_3, "isPeerDisconnected: recv() returned 0 (peer has disconnected orderly)\n");
        return true;    //peer has disconnected orderly
    }
    else if (n == -1) {
        //recv() returned -1 to indicate some error
        if (errno == EAGAIN) {
            //Because we use non-blocking in recv(), EAGAIN is ok
            return false;
        }
        else {
            debug(LEVEL_2, "isPeerDisconnected: recv() returned error, errno = %d (%s)\n", errno, strerror(errno));
            return true;
        }
    }
    else if (n >= 1) {
        //peer has sent data OK
        debug(LEVEL_3, "isPeerDisconnected: recv() returned: %s\n", buf);
        return false;  
    }
    else {
        //unknown error
        debug(LEVEL_2, "isPeerDisconnected: recv() returned error, errno = %d (%s)\n", errno, strerror(errno));
        return true;
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0x3(%rsp), %rsi
movb $0x0, 0xc(%rsi)
movl $0xc, %edx
movl $0x40, %ecx
callq 0x2090
cmpq $-0x1, %rax
je 0x3af1
testq %rax, %rax
jne 0x3b01
leaq 0x36b3(%rip), %rsi      # 0x7196
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
jmp 0x3b45
callq 0x2030
movl (%rax), %ebx
cmpl $0xb, %ebx
jne 0x3b26
xorl %ebx, %ebx
jmp 0x3b47
jle 0x3b1f
leaq 0x370f(%rip), %rsi      # 0x7219
xorl %ebx, %ebx
leaq 0x3(%rsp), %rdx
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
jmp 0x3b47
callq 0x2030
movl (%rax), %ebx
movl %ebx, %edi
callq 0x20a0
leaq 0x36a9(%rip), %rsi      # 0x71dd
movl $0x2, %edi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x355c
movb $0x1, %bl
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: readPeerHandShake(int, int)
void readPeerHandShake(int socket, int index)
{
    int len;
    
    //Make sure handshake is null-terminated
    handShakes[index] -> handShake[MAX_HANDSHAKE_LEN-1] ='\0';
    
    len = nonBlockingRead(socket, handShakes[index] -> handShake, MAX_HANDSHAKE_LEN - 1, TIMEOUT_5SECS);
    if (len < 0) {
       strlcpy(handShakes[index] -> handShake, "", MAX_HANDSHAKE_LEN);
       handShakes[index] -> handShakeLength = 0;
    }
    else {
        debug(LEVEL_3, "readPeerHandShake(): len = %d\n", len);
        handShakes[index] -> handShakeLength = len;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movslq %esi, %r14
leaq 0x9022(%rip), %r15      # 0xcb80
movq (%r15,%r14,8), %rsi
movb $0x0, 0x63(%rsi)
movl $0x63, %edx
callq 0x3bb1
testl %eax, %eax
js 0x3b8d
movl %eax, %ebx
leaq 0x36c5(%rip), %rsi      # 0x7242
movl $0x3, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x355c
jmp 0x3ba4
movq (%r15,%r14,8), %rdi
leaq 0x4a42(%rip), %rsi      # 0x85da
movl $0x64, %edx
callq 0x5844
xorl %ebx, %ebx
movq (%r15,%r14,8), %rax
movl %ebx, 0x64(%rax)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: nonBlockingAccept(int, sockaddr*, unsigned int*)
int nonBlockingAccept(int socket, struct sockaddr *sa, socklen_t *sockLen)
{
    long arg; 
    int socketToReturn;
    
    //First, set socket non-blocking 
    arg = fcntl(socket, F_GETFL, NULL);
    if (arg < 0) { 
        debug(LEVEL_2, "nonBlockingAccept(): error in fcntl(..., F_GETFL) (%s)\n", strerror(errno)); 
        return -1; 
    } 
    arg |= O_NONBLOCK; 
    if (fcntl(socket, F_SETFL, arg) < 0) { 
        debug(LEVEL_2, "nonBlockingAccept(): error in fcntl(..., F_SETFL) (%s)\n", strerror(errno)); 
        return -1; 
    }     
    
    //Accept connection 
    socketToReturn = accept(socket, sa, sockLen);

    //Set to blocking mode again... 
    if ((arg = fcntl(socket, F_GETFL, NULL)) < 0) { 
        debug(LEVEL_2, "nonBlockingAccept(): Error fcntl(..., F_GETFL) (%s)\n", strerror(errno)); 
        if (socketToReturn != -1)
            close(socketToReturn);
        return -1; 
    } 
    arg &= (~O_NONBLOCK); 
    if (fcntl(socket, F_SETFL, arg) < 0) { 
        debug(LEVEL_2, "nonBlockingAccept(): Error fcntl(..., F_SETFL) (%s)\n", strerror(errno)); 
        if (socketToReturn != -1)
            close(socketToReturn);
        return -1; 
    } 

    //At last, we are ready to return accept():ed socket ;-)
    return socketToReturn;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2120
testl %eax, %eax
js 0x3d61
orl $0x800, %eax            # imm = 0x800
movl %ebp, %edi
movl $0x4, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2120
testl %eax, %eax
js 0x3d76
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2080
movl %eax, %ebx
movl %ebp, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2120
testl %eax, %eax
js 0x3da4
andl $0x7ffff7ff, %eax       # imm = 0x7FFFF7FF
movl %ebp, %edi
movl $0x4, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2120
testl %eax, %eax
js 0x3db9
movl %ebx, %ebp
jmp 0x3d9d
callq 0x2030
movl (%rax), %edi
callq 0x20a0
leaq 0x34ed(%rip), %rsi      # 0x7261
jmp 0x3d89
callq 0x2030
movl (%rax), %edi
callq 0x20a0
leaq 0x3510(%rip), %rsi      # 0x7299
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x355c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
callq 0x2030
movl (%rax), %edi
callq 0x20a0
leaq 0x351a(%rip), %rsi      # 0x72d1
jmp 0x3dcc
callq 0x2030
movl (%rax), %edi
callq 0x20a0
leaq 0x353a(%rip), %rsi      # 0x7306
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x355c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %ebx
je 0x3d9d
movl %ebx, %edi
callq 0x2360
jmp 0x3d9d
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: startListeningOnPort(_listenPortInfo*)
static void startListeningOnPort(listenPortInfo * pInfo)
{
    int yes = 1;
    struct sockaddr_in name;
    
    pInfo->socket = socket(PF_INET, SOCK_STREAM, 0);

    if (pInfo->socket < 0)
        fatal("startListeningOnPort(): socket() failed, errno=%d (%s)\n", errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): socket() initialized\n");

    if (setsockopt(pInfo->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
        fatal("startListeningOnPort(): setsockopt() failed, errno=%d (%s)\n", errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): setsockopt() success\n");

    name.sin_family = AF_INET;

    name.sin_port = htons(pInfo->port);

    name.sin_addr.s_addr = inet_addr(ownIpAddress);

    if (bind(pInfo->socket, (struct sockaddr *) &name, sizeof(name)) < 0)
        fatal("startListeningOnPort(): bind() to (ip: %s, port: %d) failed, errno=%d (%s)\n", 
            ownIpAddress, pInfo -> port, errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): bind() to (ip: %s, port: %d) succeeded\n", ownIpAddress, pInfo->port);

    if (listen(pInfo->socket, LISTEN_BACKLOG) < 0)
        fatal("startListeningOnPort(): listen() failed, errno=%d (%s)\n", errno, strerror(errno));
    else
        debug(LEVEL_3, "startListeningOnPort(): listen() succeeded\n");

}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x1, 0x4(%rsp)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2060
movl %eax, (%rbx)
testl %eax, %eax
js 0x3ef1
leaq 0x3d71(%rip), %rsi      # 0x7b9b
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
movl (%rbx), %edi
leaq 0x4(%rsp), %rcx
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x2330
cmpl $-0x1, %eax
je 0x3efb
leaq 0x3da3(%rip), %rsi      # 0x7c05
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
leaq 0x8(%rsp), %r14
movw $0x2, (%r14)
movzwl 0x4(%rbx), %eax
rolw $0x8, %ax
movw %ax, 0x2(%r14)
leaq 0x8473(%rip), %rdi      # 0xc300
callq 0x2200
movl %eax, 0x4(%r14)
movl (%rbx), %edi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2050
movl 0x4(%rbx), %ecx
testl %eax, %eax
js 0x3f05
leaq 0x3dcc(%rip), %rsi      # 0x7c7f
leaq 0x8446(%rip), %rdx      # 0xc300
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
movl (%rbx), %edi
movl $0x5, %esi
callq 0x2210
testl %eax, %eax
js 0x3f0e
leaq 0x3e1a(%rip), %rsi      # 0x7cf7
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
addq $0x18, %rsp
popq %rbx
popq %r14
retq
callq 0x33c1
jmp 0x3e36
callq 0x33e4
jmp 0x3e6e
movl %ecx, %edi
callq 0x3408
jmp 0x3ec6
callq 0x343e
jmp 0x3ee9
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: isCodeInIdList(long)
static bool isCodeInIdList(long code)
{
    int ii;
    
    for(ii = 0; ii < ID_LIST_SIZE; ii++) {
        if (code == idList[ii]) {
            debug(LEVEL_3, "isCodeInIdList(): ID code match found (%ld)\n", code);
            return true;
        }
    }

    return false;
}

// Assembly:
pushq %rbx
movq %rdi, %rdx
leaq 0x10715(%rip), %rax     # 0x15130
movslq (%rax), %rcx
movb $0x1, %bl
cmpq %rdi, %rcx
je 0x4a44
xorl %ecx, %ecx
cmpq $0x63, %rcx
je 0x4a59
movslq 0x4(%rax,%rcx,4), %rsi
incq %rcx
cmpq %rdx, %rsi
jne 0x4a27
decq %rcx
cmpq $0x63, %rcx
setb %bl
leaq 0x3cbf(%rip), %rsi      # 0x870a
movl $0x3, %edi
xorl %eax, %eax
callq 0x355c
jmp 0x4a5c
setb %bl
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: addViewerList(int, long, char*)
static int addViewerList(int socket, long code, char *peerIp)
{
    int i;

    for (i = 0; i < maxSessions; i++) {
        if (viewers[i] -> code == 0) {
            debug(LEVEL_3, "addViewerList(): Viewer added to list: code = %ld, index = %d\n", code, i);
            viewers[i] -> code = code;
            viewers[i] -> socket = socket;
            viewers[i] -> peerIp = getAddrPartsFromString(peerIp);
            viewers[i] -> timeStamp = time(NULL);
            viewers[i] -> active = false;
            return i;
        }
    }

    debug(LEVEL_2, "addViewerList(): Warning, no table slots available\n");
    return -1;  //Not added
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x7c97(%rip), %rax      # 0xca40
movslq (%rax), %rax
testq %rax, %rax
jle 0x4dd9
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
leaq 0xdc00(%rip), %r12      # 0x129c0
xorl %ebx, %ebx
movq (%r12), %rcx
cmpq $0x0, 0x8(%rcx)
je 0x4df3
incq %rbx
addq $0x8, %r12
cmpq %rbx, %rax
jne 0x4dc2
leaq 0x3b93(%rip), %rsi      # 0x8973
movl $0x2, %edi
xorl %eax, %eax
callq 0x355c
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4e3c
leaq 0x3b3a(%rip), %rsi      # 0x8934
movl $0x3, %edi
movq %r15, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x355c
movq (%r12), %rax
movq %r15, 0x8(%rax)
movl %ebp, (%rax)
movq %r14, %rdi
callq 0x6754
movq (%r12), %rcx
movq %rax, 0x18(%rcx)
movq %rdx, 0x20(%rcx)
xorl %edi, %edi
callq 0x21c0
movq (%r12), %rcx
movq %rax, 0x10(%rcx)
movb $0x0, 0x28(%rcx)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: setViewerActive(long)
static void setViewerActive(long code)
{
    int i;

    for (i = 0; i < maxSessions; i++) {
        if (viewers[i] -> code == code) {
            viewers[i] -> active = true;
            debug(LEVEL_3, "setViewerActive(): activated viewer at index %d, code = %ld\n", i, viewers[i] -> code);
            return;
        }
    }

    debug(LEVEL_2, "setViewerActive(): Warning, viewer not found (code = %ld)\n", code);
}

// Assembly:
movq %rdi, %rax
leaq 0x7bef(%rip), %rcx      # 0xca40
movslq (%rcx), %rsi
testq %rsi, %rsi
jle 0x4e7a
leaq 0xdb60(%rip), %rdi      # 0x129c0
xorl %edx, %edx
movq (%rdi), %r8
movq 0x8(%r8), %rcx
cmpq %rax, %rcx
je 0x4e90
incq %rdx
addq $0x8, %rdi
cmpq %rdx, %rsi
jne 0x4e62
leaq 0x3b63(%rip), %rsi      # 0x89e4
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
jmp 0x355c
movb $0x1, 0x28(%r8)
leaq 0x3b0b(%rip), %rsi      # 0x89a7
movl $0x3, %edi
xorl %eax, %eax
jmp 0x355c
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: addServerList(int, long, char*)
static int addServerList(int socket, long code, char *peerIp)
{
    int i;

    for (i = 0; i < maxSessions; i++) {
        if (servers[i] -> code == 0) {
            debug(LEVEL_3, "addServerList(): Server added to list: code = %ld, index = %d\n", code, i);
            servers[i] -> code = code;
            servers[i] -> socket = socket;
            servers[i] -> peerIp = getAddrPartsFromString(peerIp);
            servers[i] -> timeStamp = time(NULL);  /* 1 second accuracy is enough ? */
            servers[i] -> active = false;
            return i;
        }
    }
    
    debug(LEVEL_2, "addServerList(): Warning, no table slots available\n"); 
    return -1;  //Not added
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x7b89(%rip), %rax      # 0xca40
movslq (%rax), %rax
testq %rax, %rax
jle 0x4ee7
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
leaq 0xbbb2(%rip), %r12      # 0x10a80
xorl %ebx, %ebx
movq (%r12), %rcx
cmpq $0x0, 0x8(%rcx)
je 0x4f01
incq %rbx
addq $0x8, %r12
cmpq %rbx, %rax
jne 0x4ed0
leaq 0x3b70(%rip), %rsi      # 0x8a5e
movl $0x2, %edi
xorl %eax, %eax
callq 0x355c
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4f4a
leaq 0x3b17(%rip), %rsi      # 0x8a1f
movl $0x3, %edi
movq %r15, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x355c
movq (%r12), %rax
movq %r15, 0x8(%rax)
movl %ebp, (%rax)
movq %r14, %rdi
callq 0x6754
movq (%r12), %rcx
movq %rax, 0x18(%rcx)
movq %rdx, 0x20(%rcx)
xorl %edi, %edi
callq 0x21c0
movq (%r12), %rcx
movq %rax, 0x10(%rcx)
movb $0x0, 0x28(%rcx)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: setServerActive(long)
static void setServerActive(long code)
{
    int i;

    for (i = 0; i < maxSessions; i++) {
        if (servers[i] -> code == code) {
            servers[i] -> active = true;
            debug(LEVEL_3, "setServerActive(): activated server at index = %d, code = %ld\n", i, servers[i] -> code);
            return;
        }
    }
    debug(LEVEL_2, "setServerActive(): server not found (code = %ld)\n", code);
}

// Assembly:
movq %rdi, %rax
leaq 0x7ae1(%rip), %rcx      # 0xca40
movslq (%rcx), %rsi
testq %rsi, %rsi
jle 0x4f88
leaq 0xbb12(%rip), %rdi      # 0x10a80
xorl %edx, %edx
movq (%rdi), %r8
movq 0x8(%r8), %rcx
cmpq %rax, %rcx
je 0x4f9e
incq %rdx
addq $0x8, %rdi
cmpq %rdx, %rsi
jne 0x4f70
leaq 0x3b42(%rip), %rsi      # 0x8ad1
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
jmp 0x355c
movb $0x1, 0x28(%r8)
leaq 0x3ae8(%rip), %rsi      # 0x8a92
movl $0x3, %edi
xorl %eax, %eax
jmp 0x355c
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: forkRepeater(int, int, long)
static void forkRepeater(int serverSocket, int viewerSocket, long idCode)
{
    pid_t pid;

    //fork repeater
    pid = fork();
    if (-1 == pid) {
        //fork failed. This is so unfair. Exit and blame Linus ;-)
        fatal(LEVEL_0, "forkRepeater(): fork() failed. Linus, this is *so* unfair.\n");
    }
    else if (0 == pid) {
        //child code
        debug(LEVEL_3, "forkRepeater(): in child process, starting doRepeater(%d, %d)\n", serverSocket, viewerSocket);
        exit(doRepeater(serverSocket, viewerSocket));
    }
    else {
        //parent code
        //Add necessary information of child to repeaterProcs list so we can
        //properly clean up after child has exited
        addRepeaterProcList(idCode, pid);
        
        //Close (parents copies of) repeater sockets right away here,
        //so we don't need to close them in cleanUpAfterRepeaterProcExit()
        close(serverSocket);
        close(viewerSocket);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movl %esi, %ebx
movl %edi, %ebp
callq 0x2070
cmpl $-0x1, %eax
je 0x505b
movl %eax, %r15d
testl %eax, %eax
je 0x5073
leaq 0x7a5b(%rip), %rax      # 0xca40
movslq (%rax), %rax
testq %rax, %rax
jle 0x500c
leaq 0x9b4c(%rip), %r12      # 0xeb40
xorl %edx, %edx
movq (%r12), %rcx
cmpq $0x0, (%rcx)
je 0x5021
incq %rdx
addq $0x8, %r12
cmpq %rdx, %rax
jne 0x4ff6
leaq 0x3bac(%rip), %rsi      # 0x8bbf
movl $0x2, %edi
xorl %eax, %eax
callq 0x355c
jmp 0x5045
leaq 0x3b56(%rip), %rsi      # 0x8b7e
movl $0x3, %edi
movl %r15d, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x355c
movq (%r12), %rax
movq %r14, (%rax)
movl %r15d, 0x8(%rax)
movl %ebp, %edi
callq 0x2360
movl %ebx, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2360
leaq 0x3aa1(%rip), %rsi      # 0x8b03
xorl %edi, %edi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2405
leaq 0x3ac5(%rip), %rsi      # 0x8b3f
movl $0x3, %edi
movl %ebp, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x355c
movl %ebp, %edi
movl %ebx, %esi
callq 0x53d4
movl %eax, %edi
callq 0x2250
// File: /workspace/github_cpp_makefile_star2_O1/qian-jiahong[P]uvncrep017-ws/repeater.cpp
// Function: findServerList(long)
static int findServerList(long code)
{
    int i;

    for (i = 0; i < maxSessions; i++) {
        if (servers[i] -> code == code) {
            debug(LEVEL_3, "findServerList(): server found at index %d, code = %ld\n", i, servers[i] -> code);
            return i;
        }
    }

    debug(LEVEL_2, "findServerList(): server not found (code = %ld)\n", code);
    return UNKNOWN_REPINFO_IND;
}

// Assembly:
pushq %rbx
movq %rdi, %rdx
leaq 0x799b(%rip), %rax      # 0xca40
movslq (%rax), %rax
testq %rax, %rax
jle 0x50ce
leaq 0xb9cc(%rip), %rsi      # 0x10a80
xorl %ebx, %ebx
movq (%rsi), %rcx
movq 0x8(%rcx), %rcx
cmpq %rdx, %rcx
je 0x50e8
incq %rbx
addq $0x8, %rsi
cmpq %rbx, %rax
jne 0x50b6
leaq 0x3b5f(%rip), %rsi      # 0x8c34
movl $0x2, %edi
xorl %eax, %eax
callq 0x355c
movl $0xf423f, %ebx          # imm = 0xF423F
jmp 0x50fd
leaq 0x3b0d(%rip), %rsi      # 0x8bfc
movl $0x3, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x355c
movl %ebx, %eax
popq %rbx
retq