LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::WriteString(char const*)
void Serial::WriteString(const char *String)
{
   int length=strlen(String);
   if (write(fd,String,length)!=length)
   {
      throw ErrorWriteException();
   }
   return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x30e0
movl (%r14), %edi
movslq %eax, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x30b0
cmpq %r14, %rax
jne 0x57f6
popq %rbx
popq %r14
popq %rbp
retq
movl $0x8, %edi
callq 0x3110
leaq 0x4501(%rip), %rcx      # 0x9d08
movq %rcx, (%rax)
leaq 0x444f(%rip), %rsi      # 0x9c60
movq 0x47c8(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::ReadChar(char*, unsigned int)
unsigned Serial::ReadChar(char *pByte, unsigned TimeOut_ms)
{
   // Timer per la gestione del timeout
   TimeOut Timer;
   Timer.InitTimer();
   while (Timer.ElapsedTime_ms()<TimeOut_ms || TimeOut_ms==0)
   {
      switch (read(fd,pByte,1))
      {
         case -1: throw ErrorReadException();
         case 1 : return 1;
      }
   }
   throw TimeoutException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq -0x38(%rbp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x3390
movl %ebx, %r13d
movq %r12, %rdi
callq 0x5926
testl %ebx, %ebx
je 0x58a3
cmpq %r13, %rax
jae 0x58f0
movl (%r15), %edi
movl $0x1, %edx
movq %r14, %rsi
callq 0x3330
cmpq $0x1, %rax
je 0x58dc
cmpq $-0x1, %rax
jne 0x5892
movl $0x8, %edi
callq 0x3110
leaq 0x4460(%rip), %rcx      # 0x9d30
movq %rcx, (%rax)
leaq 0x439e(%rip), %rsi      # 0x9c78
jmp 0x590b
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x3110
leaq 0x4457(%rip), %rcx      # 0x9d58
movq %rcx, (%rax)
leaq 0x430d(%rip), %rsi      # 0x9c18
movq 0x46ce(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33d0
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: TimeOut::ElapsedTime_ms()
unsigned long int TimeOut::ElapsedTime_ms()
{
   struct timeval CurrentTime;
   int sec,usec;
   gettimeofday(&CurrentTime, NULL);
   sec=CurrentTime.tv_sec-PreviousTime.tv_sec;
   usec=CurrentTime.tv_usec-PreviousTime.tv_usec;
   if (usec<0)
   {
      usec=1000000-PreviousTime.tv_usec+CurrentTime.tv_usec;
      sec--;
   }
   return sec*1000+usec/1000;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq -0x20(%rbp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x3390
movl (%r14), %eax
subl (%rbx), %eax
movl 0x8(%r14), %ecx
subl 0x8(%rbx), %ecx
leal 0xf4240(%rcx), %edx
movl %ecx, %esi
sarl $0x1f, %esi
addl %eax, %esi
testl %ecx, %ecx
cmovnsl %ecx, %edx
imull $0x3e8, %esi, %eax      # imm = 0x3E8
movslq %edx, %rcx
imulq $0x10624dd3, %rcx, %rcx # imm = 0x10624DD3
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x26, %rcx
addl %edx, %ecx
addl %eax, %ecx
movslq %ecx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::ReadStringNoTimeOut(char*, char, unsigned int)
unsigned Serial::ReadStringNoTimeOut(char *String, char FinalChar, unsigned MaxNbBytes)
{
   unsigned NbBytes=0;
   unsigned ret;
   while (NbBytes<MaxNbBytes)
   {
      ret=ReadChar(&String[NbBytes]);
      if (ret==1)
      {
         if (String[NbBytes]==FinalChar)
         {
            String[NbBytes]='\0';
            return NbBytes;
         }
         NbBytes++;
      }
      else
      {
         // Ramo superfluo in quanto l'eccezione verrebbe lanciata da ReadChar(...)
         // lasciato per facilitare un eventuale debug
         throw ErrorReadException();
      }
   }
   throw ErrorBufferFullException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %ecx, %ecx
je 0x59c9
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r15
movl %ecx, %r13d
xorl %r12d, %r12d
leaq (%rbx,%r12), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x5868
cmpb %r14b, (%rbx,%r12)
je 0x59f3
incq %r12
cmpl %r12d, %r13d
jne 0x59ad
movl $0x8, %edi
callq 0x3110
leaq 0x43a6(%rip), %rcx      # 0x9d80
movq %rcx, (%rax)
leaq 0x42ac(%rip), %rsi      # 0x9c90
movq 0x45f5(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33d0
movb $0x0, (%rbx,%r12)
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::ReadString(char*, char, unsigned int, unsigned int)
unsigned Serial::ReadString(char *String,char FinalChar,unsigned MaxNbBytes,unsigned TimeOut_ms)
{
   // Se non è specificato un timeout, usa il metodo senza timeout
   if (TimeOut_ms==0)
      return ReadStringNoTimeOut(String,FinalChar,MaxNbBytes);
   unsigned NbBytes=0;
   unsigned ret;

   // Timer la gestione del timeout
   TimeOut Timer;
   long int TimeOutParam;

   // Inizializza il timer
   Timer.InitTimer();

   while (NbBytes<MaxNbBytes)
   {
      // Tempo trascorso
      TimeOutParam=TimeOut_ms-Timer.ElapsedTime_ms();
      if (TimeOutParam>0)
      {
         ret=ReadChar(&String[NbBytes],TimeOutParam);
         if (ret==1)
         {
            if (String[NbBytes]==FinalChar)
            {
               String[NbBytes]='\0';
               return NbBytes;
            }
            NbBytes++;
         }
         else
          throw ErrorReadException();
      }
      if (Timer.ElapsedTime_ms()>TimeOut_ms)
      {
         String[NbBytes]='\0';
         throw TimeoutException();
      }
   }
   throw ErrorBufferFullException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %r15d
movl %edx, -0x2c(%rbp)
testl %r8d, %r8d
je 0x5ae1
movl %r8d, %ebx
movq %rdi, -0x40(%rbp)
movq %rsi, -0x38(%rbp)
xorl %r14d, %r14d
leaq -0x58(%rbp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x3390
movl %ebx, %ebx
cmpl %r15d, %r14d
jae 0x5afb
movq %r12, %rdi
callq 0x5926
movq %rbx, %rdx
subq %rax, %rdx
jle 0x5a95
movq %r12, %r13
movl %r14d, %eax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rcx
leaq (%rcx,%rax), %r12
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x5868
movl -0x2c(%rbp), %eax
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rdx
cmpb %al, (%rdx,%rcx)
je 0x5aca
incl %r14d
movq %r13, %r12
movq %r12, %rdi
callq 0x5926
cmpq %rbx, %rax
jbe 0x5a48
movl %r14d, %eax
movq -0x38(%rbp), %rcx
movb $0x0, (%rcx,%rax)
movl $0x8, %edi
callq 0x3110
leaq 0x429a(%rip), %rcx      # 0x9d58
movq %rcx, (%rax)
leaq 0x4150(%rip), %rsi      # 0x9c18
jmp 0x5b16
movb $0x0, (%r12)
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl -0x2c(%rbp), %edx
movl %r15d, %ecx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x598c
movl $0x8, %edi
callq 0x3110
leaq 0x4274(%rip), %rcx      # 0x9d80
movq %rcx, (%rax)
leaq 0x417a(%rip), %rsi      # 0x9c90
movq 0x44c3(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/serial.cpp
// Function: Serial::Read(void*, unsigned int, unsigned int)
unsigned Serial::Read (void *Buffer,unsigned MaxNbBytes,unsigned TimeOut_ms)
{
   // Timer per gestire il timeout
   TimeOut Timer;

   // Inizializza il timer
   Timer.InitTimer();
   unsigned NbByteRead=0;
   while (Timer.ElapsedTime_ms()<TimeOut_ms || TimeOut_ms==0)
   {
      unsigned char* Ptr=(unsigned char*)Buffer+NbByteRead;
      int Ret=read(fd,(void*)Ptr,MaxNbBytes-NbByteRead);
      if (Ret==-1)
         throw ErrorReadException();
      if (Ret>0)
      {
         NbByteRead+=Ret;
         if (NbByteRead>=MaxNbBytes)
            return NbByteRead;
      }
   }
   throw TimeoutException();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movl %edx, %r14d
movq %rsi, -0x38(%rbp)
movq %rdi, %r12
xorl %r15d, %r15d
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x3390
movl %ebx, %eax
movq %rax, -0x30(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5926
testl %ebx, %ebx
je 0x5b6a
cmpq -0x30(%rbp), %rax
jae 0x5bcf
movl %r15d, %esi
addq -0x38(%rbp), %rsi
movl (%r12), %edi
movl %r14d, %edx
subl %r15d, %edx
callq 0x3330
cmpl $-0x1, %eax
je 0x5bb2
leal (%r15,%rax), %ecx
cmpl %r14d, %ecx
setb %dl
testl %eax, %eax
cmovgl %ecx, %r15d
setle %al
orb %dl, %al
cmovel %ecx, %r13d
jne 0x5b57
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x3110
leaq 0x416d(%rip), %rcx      # 0x9d30
movq %rcx, (%rax)
leaq 0x40ab(%rip), %rsi      # 0x9c78
jmp 0x5bea
movl $0x8, %edi
callq 0x3110
leaq 0x4178(%rip), %rcx      # 0x9d58
movq %rcx, (%rax)
leaq 0x402e(%rip), %rsi      # 0x9c18
movq 0x43ef(%rip), %rdx      # 0x9fe0
movq %rax, %rdi
callq 0x33d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: GenerateSTATEOutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string GenerateSTATEOutput (string line)
{
		istringstream iss(line);
		string sub;

		// Scarta nome comando
		iss >> sub;
		// Prende nome stato
		iss >> sub;
		if (sub == "RESET;")
		{
			return "!!!!!*";
		}
		else if (sub == "IDLE;") 
		{
			return "*";
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
leaq -0x1b8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33b0
leaq -0x28(%rbp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq -0x38(%rbp), %rsi
movq %r14, %rdi
callq 0x32e0
leaq -0x1b8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x32e0
leaq 0x1274(%rip), %rsi      # 0x77a9
leaq -0x38(%rbp), %rdi
callq 0x3080
testl %eax, %eax
je 0x6571
leaq 0x126e(%rip), %rsi      # 0x77b7
leaq -0x38(%rbp), %rdi
callq 0x3080
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x1255(%rip), %rsi      # 0x77b5
leaq 0x124f(%rip), %rdx      # 0x77b6
movq %rbx, %rdi
callq 0x51c0
jmp 0x658e
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x1231(%rip), %rsi      # 0x77b0
leaq 0x1230(%rip), %rdx      # 0x77b6
movq %rbx, %rdi
callq 0x51c0
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0x65a3
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x3a16(%rip), %rsi      # 0x9fc0
leaq -0x1b8(%rbp), %rdi
callq 0x3320
leaq -0x140(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x65d7
jmp 0x65d7
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0x65ef
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x39ca(%rip), %rsi      # 0x9fc0
leaq -0x1b8(%rbp), %rdi
callq 0x3320
leaq -0x140(%rbp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x33e0
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: GenerateRUNTESTOutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string GenerateRUNTESTOutput (string line)
{
		istringstream iss(line);
		string sub, str;
		long int n;
		int i;

		// Scarta nome comando
		iss >> sub;
		iss >> n;

		// Impostiamo come massimo il numero di caratteri che possiamo inviare sulla seriale
		if(n > 1000)
			n = 1000;

		// Assumendo che i cicli di clock indicati siano divisibili per 4
		for (i=0; i < n/4; i++)
		{
			// Tanti '0' quanti sono i cicli di clock richiesti divisi per 4
			str += '0';
		}

		return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, %rbx
leaq -0x1c8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33b0
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x10(%rbx), %r12
movq %r12, (%rbx)
movq %rax, 0x8(%rbx)
movb %al, 0x10(%rbx)
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x32e0
leaq -0x1c8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3260
cmpq $0x3e9, -0x28(%rbp)     # imm = 0x3E9
jl 0x668c
movq $0x3e8, -0x28(%rbp)     # imm = 0x3E8
cmpq $0x4, -0x28(%rbp)
jl 0x66be
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x30, %esi
callq 0x31f0
incq %r14
movq -0x28(%rbp), %rax
leaq 0x3(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jg 0x6696
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x66d3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x38e6(%rip), %rsi      # 0x9fc0
leaq -0x1c8(%rbp), %rdi
callq 0x3320
leaq -0x150(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6707
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x671e
movq (%r12), %rsi
incq %rsi
callq 0x3250
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x6733
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x3886(%rip), %rsi      # 0x9fc0
leaq -0x1c8(%rbp), %rdi
callq 0x3320
leaq -0x150(%rbp), %rdi
callq 0x30a0
movq %r14, %rdi
callq 0x33e0
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: hexCharToBin[abi:cxx11](char)
string hexCharToBin(char c)	// Funzione di conversione valore esadecimale in valore binario
{
    switch(toupper(c))
    {
        case '0': return "0000";
        case '1': return "0001";
        case '2': return "0010";
        case '3': return "0011";
        case '4': return "0100";
        case '5': return "0101";
        case '6': return "0110";
        case '7': return "0111";
        case '8': return "1000";
        case '9': return "1001";
        case 'A': return "1010";
        case 'B': return "1011";
        case 'C': return "1100";
        case 'D': return "1101";
        case 'E': return "1110";
        case 'F': return "1111";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, %edi
callq 0x3410
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
addl $-0x30, %eax
leaq 0xfb9(%rip), %rcx       # 0x7734
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1032(%rip), %rsi      # 0x77bd
leaq 0x102f(%rip), %rdx      # 0x77c1
jmp 0x6897
leaq 0x1056(%rip), %rsi      # 0x77f4
leaq 0x1053(%rip), %rdx      # 0x77f8
jmp 0x6897
leaq 0x1048(%rip), %rsi      # 0x77f9
leaq 0x1045(%rip), %rdx      # 0x77fd
jmp 0x6897
leaq 0x100d(%rip), %rsi      # 0x77d1
leaq 0x100a(%rip), %rdx      # 0x77d5
jmp 0x6897
leaq 0x1013(%rip), %rsi      # 0x77ea
leaq 0x1010(%rip), %rdx      # 0x77ee
jmp 0x6897
leaq 0x101e(%rip), %rsi      # 0x7808
leaq 0x101b(%rip), %rdx      # 0x780c
jmp 0x6897
leaq 0xfca(%rip), %rsi       # 0x77c7
leaq 0xfc7(%rip), %rdx       # 0x77cb
jmp 0x6897
leaq 0xfbc(%rip), %rsi       # 0x77cc
leaq 0xfb9(%rip), %rdx       # 0x77d0
jmp 0x6897
leaq 0xfde(%rip), %rsi       # 0x77fe
leaq 0xfdb(%rip), %rdx       # 0x7802
jmp 0x6897
leaq 0xfb0(%rip), %rsi       # 0x77e0
leaq 0xfad(%rip), %rdx       # 0x77e4
jmp 0x6897
leaq 0xfaf(%rip), %rsi       # 0x77ef
leaq 0xfac(%rip), %rdx       # 0x77f3
jmp 0x6897
leaq 0xf72(%rip), %rsi       # 0x77c2
leaq 0xf6f(%rip), %rdx       # 0x77c6
jmp 0x6897
leaq 0xf76(%rip), %rsi       # 0x77d6
leaq 0xf73(%rip), %rdx       # 0x77da
jmp 0x6897
leaq 0xf6b(%rip), %rsi       # 0x77db
leaq 0xf68(%rip), %rdx       # 0x77df
jmp 0x6897
leaq 0xf65(%rip), %rsi       # 0x77e5
leaq 0xf62(%rip), %rdx       # 0x77e9
jmp 0x6897
leaq 0xf73(%rip), %rsi       # 0x7803
leaq 0xf70(%rip), %rdx       # 0x7807
movq %rbx, %rdi
callq 0x51c0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: hexstrToBinstr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string hexstrToBinstr(string hex)	// Funzione di conversione stringa esadecimale in stringa binaria
{
		string bin;

		for(unsigned k = 0; k != hex.length(); ++k)
		{
			bin += hexCharToBin(hex[k]);
		}

		return bin;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, -0x30(%rbp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
cmpq $0x0, 0x8(%rsi)
je 0x692e
movq %rsi, %r14
movl $0x1, %r12d
leaq -0x40(%rbp), %r13
xorl %eax, %eax
leaq -0x50(%rbp), %r15
movq (%r14), %rcx
movsbl (%rcx,%rax), %esi
movq %r15, %rdi
callq 0x675a
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %rbx, %rdi
callq 0x3090
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x6922
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movl %r12d, %eax
incl %r12d
cmpq %rax, 0x8(%r14)
jne 0x68ee
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x695d
movq %rax, %r14
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x695d
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movq (%rbx), %rdi
cmpq -0x30(%rbp), %rdi
je 0x6975
movq -0x30(%rbp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3250
movq %r14, %rdi
callq 0x33e0
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::~timer_qheap()
timer_qheap::~timer_qheap() {
    if (this->tfd != -1) {
        ::close(this->tfd);
        this->tfd = -1;
    }
    for (const auto &v : this->qheap)
        delete v;
    this->qheap.clear();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8171(%rip), %rax      # 0xefb8
addq $0x10, %rax
movq %rax, (%rdi)
movl 0x30(%rdi), %edi
cmpl $-0x1, %edi
je 0x6e62
callq 0x6830
movl $0xffffffff, 0x30(%rbx) # imm = 0xFFFFFFFF
movq 0x40(%rbx), %r14
movq 0x48(%rbx), %r15
cmpq %r15, %r14
je 0x6e82
movq (%r14), %rdi
testq %rdi, %rdi
je 0x6e7c
callq 0x6480
addq $0x8, %r14
jmp 0x6e6a
movq 0x40(%rbx), %rdi
cmpq %rdi, 0x48(%rbx)
je 0x6e90
movq %rdi, 0x48(%rbx)
testq %rdi, %rdi
je 0x6e9f
popq %rbx
popq %r14
popq %r15
jmp 0x6480
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rdi
callq 0x7444
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::open()
int timer_qheap::open() {
    int fd = ::timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK|TFD_CLOEXEC);
    if (fd == -1) {
        fprintf(stderr, "reactor: timerfd_create fail! %s\n", strerror(errno));
        return -1;
    }
    this->tfd = fd;
    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x7, %edi
movl $0x80800, %esi          # imm = 0x80800
callq 0x6760
cmpl $-0x1, %eax
je 0x6edf
movl %eax, 0x30(%rbx)
xorl %eax, %eax
popq %rbx
retq
callq 0x6870
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6edd
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::adjust_timerfd(long)
void timer_qheap::adjust_timerfd(int64_t delay /*millisecond*/) {
    struct timespec ts;
    ts.tv_sec = delay / 1000;
    ts.tv_nsec = delay % 1000 * 1000 * 1000;
    if (delay < 1)
        ts.tv_nsec = 1;
    struct itimerspec its;
    ::memset(&its, 0, sizeof(its));
    its.it_value = ts;
    ::timerfd_settime(this->tfd, 0 /*Relative time*/, &its, nullptr);
}

// Assembly:
subq $0x28, %rsp
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
movq %rsi, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
movq %rsi, %rcx
subq %rax, %rcx
imulq $0xf4240, %rcx, %rax    # imm = 0xF4240
testq %rsi, %rsi
movl $0x1, %ecx
cmovgq %rax, %rcx
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rdx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl 0x30(%rdi), %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x6390
addq $0x28, %rsp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::schedule(ev_handler*, int, int)
int timer_qheap::schedule(ev_handler *eh, const int delay, const int interval) {
    if (eh == nullptr)
        return -1;

    struct timeval tv;
    ::gettimeofday(&tv, nullptr);
    int64_t now = int64_t(tv.tv_sec) * 1000 + tv.tv_usec / 1000; // millisecond
    auto item = new timer_item();
    item->eh = eh;
    item->expire_at = now + delay;
    item->interval = interval;
    eh->set_timer(item);
    this->insert(item);

    auto min = this->qheap[0];
    if (min->expire_at != this->timerfd_settime) {
        this->adjust_timerfd(min->expire_at - now);
        this->timerfd_settime = min->expire_at;
    }
    return 0;
}

// Assembly:
testq %rsi, %rsi
je 0x6fef
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movl %edx, %r13d
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x66b0
movabsq $0x20c49ba5e353f7cf, %rax # imm = 0x20C49BA5E353F7CF
imulq 0x8(%r14)
movq %rdx, %r15
imulq $0x3e8, (%r14), %rax    # imm = 0x3E8
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x7, %r15
addq %rcx, %r15
addq %rax, %r15
movl $0x18, %edi
callq 0x64a0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r12, 0x10(%rax)
movslq %r13d, %rcx
addq %r15, %rcx
movq %rcx, 0x8(%rax)
movl %ebp, (%rax)
movq %rax, 0x28(%r12)
movq %rax, (%rsp)
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0x6ff5
movq %rax, (%rsi)
addq $0x8, 0x48(%rbx)
jmp 0x7001
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
leaq 0x40(%rbx), %rdi
movq %rsp, %rdx
callq 0x66f0
movq 0x48(%rbx), %rsi
subq 0x40(%rbx), %rsi
shrq $0x3, %rsi
decl %esi
movq %rbx, %rdi
callq 0x6530
movq 0x40(%rbx), %rax
movq (%rax), %r14
movq 0x8(%r14), %rcx
cmpq 0x38(%rbx), %rcx
je 0x7095
subq %r15, %rcx
movq %rcx, %rax
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
imulq %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
movq %rcx, %rsi
subq %rax, %rsi
imulq $0xf4240, %rsi, %rax    # imm = 0xF4240
testq %rcx, %rcx
movl $0x1, %ecx
cmovgq %rax, %rcx
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rdx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl 0x30(%rbx), %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x6390
movq 0x8(%r14), %rax
movq %rax, 0x38(%rbx)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::shift_up(int)
void timer_qheap::shift_up(int idx) {
    auto item = this->qheap[idx];
    while (idx > 0
        && item->expire_at < this->qheap[get_parent_index(idx)]->expire_at) {
        this->qheap[idx] = this->qheap[get_parent_index(idx)];
        idx = get_parent_index(idx);
    }
    this->qheap[idx] = item;
}

// Assembly:
movslq %esi, %rcx
movq 0x40(%rdi), %rax
movq (%rax,%rcx,8), %rax
testl %ecx, %ecx
jle 0x70fd
movq 0x8(%rax), %rcx
leal -0x1(%rsi), %r8d
movl %r8d, %edx
shrl $0x2, %edx
movq 0x40(%rdi), %r9
movq (%r9,%rdx,8), %r10
cmpq 0x8(%r10), %rcx
jge 0x70fd
movl %esi, %esi
movq %r10, (%r9,%rsi,8)
movl %edx, %esi
cmpl $0x3, %r8d
ja 0x70d5
jmp 0x70ff
movl %esi, %edx
movslq %edx, %rcx
movq 0x40(%rdi), %rdx
movq %rax, (%rdx,%rcx,8)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::shift_down(int)
void timer_qheap::shift_down(int idx) {
    int min_child = 0;
    auto item = this->qheap[idx];
    while (true) {
        min_child = get_child_index(idx, 0);
        if (min_child >= static_cast<int>(this->qheap.size()))
            break;

        for (int i = 1; i < 4; ++i) {
            int child_idx = get_child_index(idx, i);
            if (child_idx < static_cast<int>(this->qheap.size())
                && this->qheap[child_idx]->expire_at < this->qheap[min_child]->expire_at)
                min_child = child_idx;
        }

        if (this->qheap[min_child]->expire_at >= item->expire_at)
            break;

        this->qheap[idx] = this->qheap[min_child];
        idx = min_child;
    }
    this->qheap[idx] = item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movslq %esi, %rax
movq 0x40(%rdi), %rcx
movq 0x48(%rdi), %r10
movq (%rcx,%rax,8), %rax
leal 0x1(,%rsi,4), %r9d
subq %rcx, %r10
shrq $0x3, %r10
cmpl %r10d, %r9d
jge 0x71be
leal (,%rsi,4), %r11d
movq 0x8(%rax), %rdx
movslq %r11d, %r11
movslq %r10d, %r10
addq $0x2, %r11
movl $0x3, %ebx
movl %r9d, %r8d
cmpq %r10, %r11
jge 0x7179
movq (%rcx,%r11,8), %r9
movq 0x8(%r9), %r14
movslq %r8d, %r9
movq (%rcx,%r9,8), %r15
movl %r11d, %r9d
cmpq 0x8(%r15), %r14
jl 0x7176
movl %r8d, %r9d
movl %r9d, %r8d
incq %r11
decq %rbx
jne 0x7156
movslq %r8d, %r9
movq (%rcx,%r9,8), %r9
cmpq %rdx, 0x8(%r9)
jge 0x71be
movslq %esi, %rsi
movq %r9, (%rcx,%rsi,8)
leal (,%r8,4), %r11d
leal 0x1(,%r8,4), %r9d
movq 0x40(%rdi), %rcx
movq 0x48(%rdi), %r10
subq %rcx, %r10
shrq $0x3, %r10
movl %r8d, %esi
cmpl %r10d, %r9d
jl 0x7144
jmp 0x71c1
movl %esi, %r8d
movslq %r8d, %rdx
movq %rax, (%rcx,%rdx,8)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/timer_qheap.cpp
// Function: timer_qheap::on_read()
bool timer_qheap::on_read() {
    int64_t v = 0;
    int ret = 0;
    do {
        ret = ::read(this->tfd, &v, sizeof(v));
        if (ret == -1 && errno == EINTR)
            continue;
    } while (false); 

    struct timeval tv;
    ::gettimeofday(&tv, nullptr);
    int64_t now = int64_t(tv.tv_sec) * 1000 + tv.tv_usec / 1000; // millisecond
    auto delay = this->handle_expired(now);
    if (delay > 0)
        this->adjust_timerfd(delay);
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
movq $0x0, (%rsi)
movl 0x30(%rdi), %edi
movl $0x8, %edx
callq 0x6640
leaq 0x10(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x66b0
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
movq %r14, %rax
imulq 0x8(%r15)
imulq $0x3e8, (%r15), %rax    # imm = 0x3E8
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x7, %rdx
addq %rdx, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x6310
testq %rax, %rax
jle 0x73a9
movq %rax, %rcx
shrq $0x3, %rax
mulq %r14
shrq $0x4, %rdx
imulq $0x3e8, %rdx, %rax      # imm = 0x3E8
subq %rax, %rcx
imulq $0xf4240, %rcx, %rcx    # imm = 0xF4240
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rdx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl 0x30(%rbx), %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x6390
movb $0x1, %al
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poller.cpp
// Function: poller::destroy()
void poller::destroy() {
    if (this->efd == -1) {
        ::close(this->efd);
        this->efd = -1;
    }
    if (this->poll_descs != nullptr) {
        delete this->poll_descs;
        this->poll_descs = nullptr;
    }
    if (this->ready_events != nullptr) {
        delete[] this->ready_events;
        this->ready_events = nullptr;
    }
    if (this->io_buf != nullptr) {
        delete[] this->io_buf;
        this->io_buf = nullptr;
    }
    if (this->timer != nullptr) {
        delete this->timer;
        this->timer = nullptr;
    }
    if (this->async_sendq != nullptr) {
        delete this->async_sendq;
        this->async_sendq = nullptr;
    }
    if (this->poll_sync_opterate != nullptr) {
        delete this->poll_sync_opterate;
        this->poll_sync_opterate = nullptr;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $-0x1, 0x4(%rdi)
jne 0x7842
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x6830
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
movq 0x30(%rbx), %r14
testq %r14, %r14
je 0x7863
movq %r14, %rdi
callq 0x64e0
movq %r14, %rdi
callq 0x6480
movq $0x0, 0x30(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x7879
callq 0x6580
movq $0x0, 0x18(%rbx)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x788f
callq 0x6580
movq $0x0, 0x10(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x78a6
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x20(%rbx)
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x78bd
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x28(%rbx)
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x78d4
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poller.cpp
// Function: poller::add(ev_handler*, int, unsigned int)
int poller::add(ev_handler *eh, const int fd, const uint32_t ev) {
    eh->set_poller(this);
    int64_t seq = this->seq.fetch_add(1, std::memory_order_relaxed);
    eh->set_seq(seq);
    auto pd = this->poll_descs->new_one(fd);
    pd->fd = fd;
    pd->eh = eh;
    pd->events = ev;
    pd->seq = seq;
    this->poll_descs->store(fd, pd);

    struct epoll_event epev;
    epev.events = ev;
    epev.data.ptr = pd;

    if (::epoll_ctl(this->efd, EPOLL_CTL_ADD, fd, &epev) == 0)
        return 0;
    this->poll_descs->del(fd);
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r8d
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r14
movq %rdi, 0x18(%rsi)
movl $0x1, %ebp
lock
xaddq %rbp, 0x48(%rdi)
movq %rbp, 0x10(%rsi)
movq 0x30(%rdi), %r12
cmpl %edx, (%r12)
jle 0x7924
movslq %ebx, %rax
leaq (%rax,%rax,2), %r15
shlq $0x3, %r15
addq 0x8(%r12), %r15
jmp 0x7955
movl $0x18, %edi
movl %r8d, %r15d
callq 0x64a0
movl %r15d, %r8d
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, (%r15)
movq $-0x1, 0x8(%r15)
movl %ebx, (%r15)
movq %r13, 0x10(%r15)
movl %r8d, 0x4(%r15)
movq %rbp, 0x8(%r15)
movl %ebx, 0xc(%rsp)
cmpl %ebx, (%r12)
jg 0x79a1
movl %r8d, %ebp
leaq 0x48(%r12), %r13
movq %r13, %rdi
callq 0x6680
testl %eax, %eax
jne 0x79e4
addq $0x10, %r12
leaq 0xc(%rsp), %rsi
movq %r12, %rdi
callq 0x67e0
movq %r15, (%rax)
movq %r13, %rdi
callq 0x6380
movl %ebp, %r8d
leaq 0xc(%rsp), %rcx
movl %r8d, (%rcx)
movq %r15, 0x4(%rcx)
movl 0x4(%r14), %edi
movl $0x1, %esi
movl %ebx, %edx
callq 0x65d0
testl %eax, %eax
je 0x79d3
movq 0x30(%r14), %rdi
movl %ebx, %esi
callq 0x6850
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x79d5
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x6320
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poller.cpp
// Function: poller::append(int, unsigned int)
int poller::append(const int fd, const uint32_t ev) {
    auto pd = this->poll_descs->load(fd);
    if (pd == nullptr)
        return -1;

    // Always save first, recover if failed  (this method is for multi-threading scenarios)."
    pd->events |= ev;
    
    struct epoll_event epev;
    epev.events = pd->events;
    epev.data.ptr = pd;
    if (::epoll_ctl(this->efd, EPOLL_CTL_MOD, fd, &epev) != 0) {
        pd->events &= ~ev;
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movq 0x30(%rdi), %r12
cmpl %esi, (%r12)
jle 0x7a68
movq 0x8(%r12), %rax
movslq %ebp, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rax
xorl %r12d, %r12d
cmpl $-0x1, (%rax)
cmovneq %rax, %r12
jmp 0x7afa
leaq 0x48(%r12), %r15
movq %r15, %rdi
callq 0x6680
testl %eax, %eax
jne 0x7b45
movslq %ebp, %rax
movq 0x10(%r12), %rsi
movq 0x18(%r12), %rdi
xorl %r9d, %r9d
xorl %edx, %edx
divq %rdi
movq (%rsi,%rdx,8), %rax
testq %rax, %rax
je 0x7ad8
movq (%rax), %r8
movq %rax, %r9
cmpl %ebp, 0x8(%r8)
je 0x7ad8
movq %rdx, %rcx
movq %r8, %r10
movq (%r8), %r8
testq %r8, %r8
je 0x7ad5
movslq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r9d
cmpq %rcx, %rdx
jne 0x7ad8
movq %r10, %r9
cmpl %ebp, %esi
jne 0x7aaa
jmp 0x7ad8
xorl %r9d, %r9d
testq %r9, %r9
je 0x7ae2
movq (%r9), %rax
jmp 0x7ae4
xorl %eax, %eax
testq %rax, %rax
je 0x7aef
movq 0x10(%rax), %r12
jmp 0x7af2
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x6380
testq %r12, %r12
je 0x7b2f
orl %ebx, 0x4(%r12)
movl 0x4(%r12), %eax
leaq 0x4(%rsp), %rcx
movl %eax, (%rcx)
movq %r12, 0x4(%rcx)
movl 0x4(%r14), %edi
movl $0x3, %esi
movl %ebp, %edx
callq 0x65d0
testl %eax, %eax
je 0x7b36
notl %ebx
andl %ebx, 0x4(%r12)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7b38
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x6320
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poller.cpp
// Function: poller::remove(int, unsigned int)
int poller::remove(const int fd, const uint32_t ev) {
    if (ev == ev_handler::ev_all) {
        this->poll_descs->del(fd);
        return ::epoll_ctl(this->efd, EPOLL_CTL_DEL, fd, nullptr);
    }
    auto pd = this->poll_descs->load(fd);
    if (pd == nullptr)
        return -1;
    if ((pd->events & (~ev)) == 0) {
        this->poll_descs->del(fd);
        return ::epoll_ctl(this->efd, EPOLL_CTL_DEL, fd, nullptr);
    }

    // Always save first, recover if failed  (this method is for multi-threading scenarios)."
    pd->events &= (~ev);

    struct epoll_event epev;
    epev.events = pd->events;
    epev.data.ptr = pd;
    if (::epoll_ctl(this->efd, EPOLL_CTL_MOD, fd, &epev) != 0) {
        pd->events |= ev;
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq 0x30(%rdi), %r12
cmpl $0x2005, %edx           # imm = 0x2005
jne 0x7b91
movq %r12, %rdi
movl %ebx, %esi
callq 0x6850
movl 0x4(%r14), %edi
movl $0x2, %esi
movl %ebx, %edx
xorl %ecx, %ecx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x65d0
movl %edx, %ebp
cmpl %ebx, (%r12)
jle 0x7bb8
movq 0x8(%r12), %rax
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rax
xorl %r12d, %r12d
cmpl $-0x1, (%rax)
cmovneq %rax, %r12
jmp 0x7c4a
leaq 0x48(%r12), %r15
movq %r15, %rdi
callq 0x6680
testl %eax, %eax
jne 0x7ca7
movslq %ebx, %rax
movq 0x10(%r12), %rsi
movq 0x18(%r12), %rdi
xorl %r9d, %r9d
xorl %edx, %edx
divq %rdi
movq (%rsi,%rdx,8), %rax
testq %rax, %rax
je 0x7c28
movq (%rax), %r8
movq %rax, %r9
cmpl %ebx, 0x8(%r8)
je 0x7c28
movq %rdx, %rcx
movq %r8, %r10
movq (%r8), %r8
testq %r8, %r8
je 0x7c25
movslq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r9d
cmpq %rcx, %rdx
jne 0x7c28
movq %r10, %r9
cmpl %ebx, %esi
jne 0x7bfa
jmp 0x7c28
xorl %r9d, %r9d
testq %r9, %r9
je 0x7c32
movq (%r9), %rax
jmp 0x7c34
xorl %eax, %eax
testq %rax, %rax
je 0x7c3f
movq 0x10(%rax), %r12
jmp 0x7c42
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x6380
testq %r12, %r12
je 0x7c88
movl %ebp, %eax
notl %eax
andl 0x4(%r12), %eax
je 0x7c9a
movl %eax, 0x4(%r12)
movl 0x4(%r12), %eax
leaq 0x4(%rsp), %rcx
movl %eax, (%rcx)
movq %r12, 0x4(%rcx)
movl 0x4(%r14), %edi
movl $0x3, %esi
movl %ebx, %edx
callq 0x65d0
testl %eax, %eax
je 0x7ca3
orl %ebp, 0x4(%r12)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%r14), %rdi
jmp 0x7b6c
xorl %eax, %eax
jmp 0x7c8d
movl %eax, %edi
callq 0x6320
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poller.cpp
// Function: poller::set_cpu_affinity()
void poller::set_cpu_affinity() {
    if (this->cpu_id == -1)
        return;
    cpu_set_t cpu_set;
    CPU_ZERO(&cpu_set);
    CPU_SET(this->cpu_id, &cpu_set);
    if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpu_set) != 0)
        fprintf(stderr, "reactor: set cpu affinity fail! %s\n", strerror(errno));
}

// Assembly:
movl (%rdi), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rcx
je 0x7d22
subq $0x88, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
cmpl $0x3ff, %ecx            # imm = 0x3FF
ja 0x7d02
movl $0x1, %eax
shlq %cl, %rax
shrl $0x6, %ecx
orq %rax, (%rsp,%rcx,8)
callq 0x6410
movq %rsp, %rdx
movl $0x80, %esi
movq %rax, %rdi
callq 0x6730
testl %eax, %eax
jne 0x7d23
addq $0x88, %rsp
retq
callq 0x6a4d
jmp 0x7d1b
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_desc.h
// Function: poll_desc_map::~poll_desc_map()
~poll_desc_map() {
        if (this->arr != nullptr)
            delete[] this->arr;
        this->mtx.lock();
        for (const auto &kv : this->map)
            delete kv.second;
        
        this->mtx.unlock();
    }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x7f0e
callq 0x6580
leaq 0x48(%rbx), %r14
movq %r14, %rdi
callq 0x6680
testl %eax, %eax
jne 0x7f53
movq 0x20(%rbx), %r15
testq %r15, %r15
je 0x7f3a
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x7f35
callq 0x6480
movq (%r15), %r15
jmp 0x7f22
addq $0x10, %rbx
movq %r14, %rdi
callq 0x6380
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x60b0
movl %eax, %edi
callq 0x6320
movq %rax, %rdi
callq 0x7444
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_desc.h
// Function: poll_desc_map::del(int)
void del(const int i) {
        if (i < this->arr_size) {
            poll_desc *p = &(this->arr[i]);
            p->events =  0;
            p->fd     = -1;
            p->seq    = -1;
            p->eh     = nullptr;
            return;
        }
        this->mtx.lock();
        auto ret = this->map.find(i);
        if (ret != this->map.end()) {
            delete ret->second;
            this->map.erase(ret);
        }
        this->mtx.unlock();
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpl %esi, (%rdi)
jle 0x7fa3
movq 0x8(%rbx), %rax
movslq %ebp, %rcx
leaq (%rcx,%rcx,2), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, (%rax,%rcx,8)
movq $-0x1, 0x8(%rax,%rcx,8)
movq $0x0, 0x10(%rax,%rcx,8)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x48(%rbx), %r14
movq %r14, %rdi
callq 0x6680
testl %eax, %eax
jne 0x8051
movslq %ebp, %rax
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdi
xorl %r9d, %r9d
xorl %edx, %edx
divq %rdi
movq (%rsi,%rdx,8), %rax
testq %rax, %rax
je 0x8010
movq (%rax), %r8
movq %rax, %r9
cmpl %ebp, 0x8(%r8)
je 0x8010
movq %rdx, %rcx
movq %r8, %r10
movq (%r8), %r8
testq %r8, %r8
je 0x800d
movslq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r9d
cmpq %rcx, %rdx
jne 0x8010
movq %r10, %r9
cmpl %ebp, %esi
jne 0x7fe2
jmp 0x8010
xorl %r9d, %r9d
testq %r9, %r9
je 0x801a
movq (%r9), %r15
jmp 0x801d
xorl %r15d, %r15d
testq %r15, %r15
je 0x803f
addq $0x10, %rbx
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x8034
callq 0x6480
movq %rbx, %rdi
movq %r15, %rsi
callq 0x65f0
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6380
movl %eax, %edi
callq 0x6320
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_sync_opt.cpp
// Function: poll_sync_opt::~poll_sync_opt()
poll_sync_opt::~poll_sync_opt() {
   if (this->efd != -1)
        ::close(this->efd);
    
   if (this->readq != nullptr)
       delete this->readq;
   if (this->writeq != nullptr)
       delete this->writeq;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x6a0a(%rip), %rax      # 0xefc8
addq $0x10, %rax
movq %rax, (%rdi)
movl 0x30(%rdi), %edi
cmpl $-0x1, %edi
je 0x85d2
callq 0x6830
movq 0x68(%rbx), %r14
testq %r14, %r14
je 0x85f1
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x85e9
callq 0x6580
movq %r14, %rdi
callq 0x6480
movq 0x70(%rbx), %rbx
testq %rbx, %rbx
je 0x8617
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x8608
callq 0x6580
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6480
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rdi
callq 0x7444
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_sync_opt.cpp
// Function: poll_sync_opt::do_sync(poll_sync_opt::opt_arg const&)
void poll_sync_opt::do_sync(const poll_sync_opt::opt_arg &arg) {
    if (arg.type == poll_sync_opt::sync_cache_t) {
        auto p = (poll_sync_opt::sync_cache *)arg.arg;
        this->poll->poll_cache_set(p->id, p->value, p->free_func);
        delete p;
    }
}

// Assembly:
cmpl $0x1, (%rsi)
jne 0x8666
pushq %rbx
movq 0x8(%rsi), %rbx
movq 0x18(%rdi), %rdi
movl (%rbx), %esi
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rcx
callq 0x63d0
movq %rbx, %rdi
popq %rbx
jmp 0x6480
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_sync_opt.cpp
// Function: poll_sync_opt::open(poller*)
int poll_sync_opt::open(poller *poll) {
    int fd = ::eventfd(0, EFD_NONBLOCK|EFD_CLOEXEC);
    if (fd == -1) {
        fprintf(stderr, "reactor: create eventfd fail! %s\n", strerror(errno));
        return -1;
    }
    if (poll->add(this, fd, ev_handler::ev_read) == -1) {
        fprintf(stderr, "reactor: add eventfd to poller fail! %s\n", strerror(errno));
        ::close(fd);
        return -1;
    }
    this->efd = fd;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
xorl %edi, %edi
movl $0x80800, %esi          # imm = 0x80800
callq 0x6550
cmpl $-0x1, %eax
je 0x86a6
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %edx
movl $0x2001, %ecx           # imm = 0x2001
callq 0x67f0
cmpl $-0x1, %eax
je 0x86ad
movl %ebp, 0x30(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
callq 0x6ac9
jmp 0x86b4
movl %ebp, %edi
callq 0x6a8b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x86a1
nop
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_sync_opt.cpp
// Function: poll_sync_opt::push(poll_sync_opt::opt_arg const&)
void poll_sync_opt::push(const poll_sync_opt::opt_arg &arg) {
    this->mtx.lock();
    this->writeq->push_back(arg);
    this->mtx.unlock();

    int expected = 0;
    if (!this->notified.compare_exchange_strong(expected, 1))
        return ;
    int64_t v = 1;
    int ret = 0;
    do {
        ret = ::write(this->efd, (void *)&v, sizeof(v));
    } while (ret == -1 && errno == EINTR);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
movq %r14, %rdi
callq 0x6680
testl %eax, %eax
jne 0x876f
movq 0x70(%rbx), %r12
movl 0xc(%r12), %eax
cmpl (%r12), %eax
jne 0x86f5
movq %r12, %rdi
callq 0x61f0
movq 0x10(%r12), %rcx
movslq 0x8(%r12), %rdx
leal 0x1(%rdx), %eax
shlq $0x4, %rdx
movl (%r15), %esi
movl %esi, (%rcx,%rdx)
movq 0x8(%r15), %rsi
movq %rsi, 0x8(%rcx,%rdx)
cltd
idivl (%r12)
movl %edx, 0x8(%r12)
incl 0xc(%r12)
movq %r14, %rdi
callq 0x6380
movl $0x1, %ecx
xorl %eax, %eax
lock
cmpxchgl %ecx, 0x60(%rbx)
jne 0x8763
movq %rsp, %r14
movq $0x1, (%r14)
movl 0x30(%rbx), %edi
movl $0x8, %edx
movq %r14, %rsi
callq 0x6150
cmpl $-0x1, %eax
jne 0x8763
callq 0x6040
cmpl $0x4, (%rax)
je 0x8744
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl %eax, %edi
callq 0x6320
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poll_sync_opt.cpp
// Function: poll_sync_opt::on_read()
bool poll_sync_opt::on_read() {
    if (this->readq->empty()) {
        this->mtx.lock();
        std::swap(this->readq, this->writeq);
        this->mtx.unlock();
    }
    for (auto i = 0; i < 8 && !this->readq->empty(); ++i) {
        poll_sync_opt::opt_arg &arg = this->readq->front();
        this->do_sync(arg);
        this->readq->pop_front();
    }
    if (!this->readq->empty()) // Ignore readable eventfd, continue
        return true;

    int64_t v = 0;
    int ret = 0;
    do {
        ret = ::read(this->efd, (void *)&v, sizeof(v));
    } while (ret == -1 && errno == EINTR);

    this->notified.store(0);
    return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x68(%rdi), %rax
cmpl $0x0, 0xc(%rax)
jne 0x87b6
leaq 0x38(%rbx), %r14
movq %r14, %rdi
callq 0x6680
testl %eax, %eax
jne 0x8857
movdqu 0x68(%rbx), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, 0x68(%rbx)
movq %r14, %rdi
callq 0x6380
movl $0x8, %ebp
movq 0x68(%rbx), %rax
cmpl $0x0, 0xc(%rax)
je 0x8812
movslq 0x4(%rax), %rsi
shlq $0x4, %rsi
addq 0x10(%rax), %rsi
movq %rbx, %rdi
callq 0x6090
movq 0x68(%rbx), %rcx
movl 0xc(%rcx), %esi
testl %esi, %esi
je 0x880e
movq 0x10(%rcx), %rdx
movslq 0x4(%rcx), %rdi
leal 0x1(%rdi), %eax
shlq $0x4, %rdi
movl $0x0, (%rdx,%rdi)
movq $0x0, 0x8(%rdx,%rdi)
cltd
idivl (%rcx)
movl %edx, 0x4(%rcx)
decl %esi
movl %esi, 0xc(%rcx)
decl %ebp
jne 0x87bb
movq 0x68(%rbx), %rax
cmpl $0x0, 0xc(%rax)
jne 0x884c
leaq 0x8(%rsp), %r14
movq $0x0, (%r14)
movl 0x30(%rbx), %edi
movl $0x8, %edx
movq %r14, %rsi
callq 0x6640
cmpl $-0x1, %eax
jne 0x8847
callq 0x6040
cmpl $0x4, (%rax)
je 0x8828
xorl %eax, %eax
xchgl %eax, 0x60(%rbx)
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl %eax, %edi
callq 0x6320
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/poller.h
// Function: poller::poll_cache_set(int, void*, void (*)(void*))
void poll_cache_set(const int id, void *val, void (*free_func)(void *)) {
        auto itor = this->pcache.find(id);
        if (itor != this->pcache.end())
            free_func(itor->second);
        this->pcache[id] = val;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rdi, %r14
movl %esi, 0xc(%rsp)
movslq %esi, %rax
movq 0x50(%rdi), %r8
movq 0x58(%rdi), %r9
xorl %r11d, %r11d
xorl %edx, %edx
divq %r9
movq (%r8,%rdx,8), %rax
testq %rax, %rax
je 0x88cb
movq (%rax), %r10
movq %rax, %r11
cmpl %esi, 0x8(%r10)
je 0x88cb
movq %rdx, %rdi
movq %r10, %r15
movq (%r10), %r10
testq %r10, %r10
je 0x88c8
movslq 0x8(%r10), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r9
movl $0x0, %r11d
cmpq %rdi, %rdx
jne 0x88cb
movq %r15, %r11
cmpl %esi, %r8d
jne 0x889c
jmp 0x88cb
xorl %r11d, %r11d
testq %r11, %r11
je 0x88d5
movq (%r11), %rax
jmp 0x88d7
xorl %eax, %eax
addq $0x50, %r14
testq %rax, %rax
je 0x88e6
movq 0x10(%rax), %rdi
callq *%rcx
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x6260
movq %rbx, (%rax)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/shaovie[P]reactor/src/ringq.h
// Function: ringq<async_send::item>::grow()
void grow() {
        int new_size = this->size * 2;
        if (new_size == 0)
            new_size = 2;
        item_t *newrq = new item_t[new_size]();

        for (int i = 0; i < this->len; ++i)
            newrq[i] = this->rq[(this->head + i) % this->size];
        delete[] this->rq;
        this->rq = newrq;
        this->size = new_size;
        this->head = 0;
        this->tail = this->len;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %r12d
leal (%r12,%r12), %eax
testl %r12d, %r12d
movl $0x2, %ebp
cmovnel %eax, %ebp
movslq %ebp, %r15
movl $0x28, %ecx
movq %r15, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x6030
movq %rax, %r14
leaq (%r15,%r15,4), %rax
leaq (%r14,%rax,8), %rax
xorps %xmm0, %xmm0
movq %r14, %rcx
movups %xmm0, (%rcx)
movups %xmm0, 0x10(%rcx)
movq $0x0, 0x20(%rcx)
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
movq $-0x1, 0x8(%rcx)
addq $0x28, %rcx
cmpq %rax, %rcx
jne 0xa078
movslq 0xc(%rbx), %rax
testq %rax, %rax
jle 0xa0f6
movq 0x10(%rbx), %rsi
movl 0x4(%rbx), %ecx
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
xorl %r8d, %r8d
movl %ecx, %eax
cltd
idivl %r12d
movslq %edx, %rax
leaq (%rax,%rax,4), %rax
movl (%rsi,%rax,8), %edx
movl %edx, (%r14,%r8)
movq 0x10(%rsi,%rax,8), %rdx
movq %rdx, 0x10(%r14,%r8)
movq 0x20(%rsi,%rax,8), %rdx
movq %rdx, 0x20(%r14,%r8)
movq 0x18(%rsi,%rax,8), %rax
movq %rax, 0x18(%r14,%r8)
incl %ecx
addq $0x28, %r8
cmpq %r8, %rdi
jne 0xa0b9
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0xa104
callq 0x6580
movq %r14, 0x10(%rbx)
movl %ebp, (%rbx)
movl $0x0, 0x4(%rbx)
movl 0xc(%rbx), %eax
movl %eax, 0x8(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq