// File: ahupowerdns[P]spamidea/getsender.cc
// Function: processLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, MailTreeNode*&)
void processLine(std::string& l, MailTreeNode*& start)
{
  //std::regex received_regex(R"(Received: from ([\S.]+) \(([^)]*)\) by ([\S.]+) \(([^)]*)\).*for <(.*@.*)>.*)");



  if(boost::starts_with(l, "Received: ")) {
    auto pos = l.find(';');
    if(pos != string::npos)
      l.resize(pos);
    // Received: from server.ds9a.nl ([127.0.0.1]) by localhost (server.ds9a.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CedExUADWeuK for <ahu@ds9a.nl>

    //             their chosen name       what we think of that                       ourname    sometimes address                            destination
    // Received: from mail.ietf.org (mail.ietf.org [IPv6:2001:1900:3001:11::2c]) by server.ds9a.nl (Postfix) with ESMTPS id 30A4DAC011D for <bert@hubertnet.nl>



    std::smatch received_match;
    cout<<l<<endl;
    string fromServer, fromAddress, ourName, ourAddress, forAddress;
    
    if(std::regex_search(l, received_match, received_regex)) {
      static std::vector<pair<string*, int>> l({
        {&fromServer, 1},
            {&ourName, 2}
        });

          
      for(auto& p : l)
        *p.first = received_match[p.second];

      if(ourName != "localhost") {
        start=start->add(ourName);
      }

      cout << "\t"<<received_match[1] << " | " << received_match[2] << " | " << received_match[3]<< " | " << received_match[4] << endl;
    }
    else if(std::regex_search(l, received_match, received_regex2)) {
      ourName = received_match[1];
      start=start->add(ourName);
      cout << "\t"<<received_match[1] << " | " << received_match[2] << " | " << received_match[3]<< " | " << received_match[4] << endl;
    }
    else
      cout << "\tNo match"<<endl;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3268a(%rip), %rsi     # 0x391d8
callq 0x82b0
testb $0x1, %al
jne 0x6b5c
jmp 0x72b3
movq -0x8(%rbp), %rdi
movl $0x3b, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x65d0
movq %rax, -0x18(%rbp)
cmpq $-0x1, -0x18(%rbp)
je 0x6b86
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6630
leaq -0x38(%rbp), %rdi
callq 0x82e0
movq -0x8(%rbp), %rsi
movq 0x4f41e(%rip), %rdi     # 0x55fb8
callq 0x63e0
movq %rax, -0x1a0(%rbp)
jmp 0x6ba8
movq -0x1a0(%rbp), %rdi
movq 0x4f3ca(%rip), %rsi     # 0x55f80
callq 0x6480
jmp 0x6bbd
leaq -0x68(%rbp), %rdi
callq 0x6640
leaq -0x88(%rbp), %rdi
callq 0x6640
leaq -0xa8(%rbp), %rdi
callq 0x6640
leaq -0xc8(%rbp), %rdi
callq 0x6640
leaq -0xe8(%rbp), %rdi
callq 0x6640
movq -0x8(%rbp), %rdi
leaq 0x4fcaf(%rip), %rdx     # 0x568b0
leaq -0x38(%rbp), %rsi
xorl %ecx, %ecx
callq 0x8320
movb %al, -0x1a1(%rbp)
jmp 0x6c14
movb -0x1a1(%rbp), %al
testb $0x1, %al
jne 0x6c23
jmp 0x6ff3
cmpb $0x0, 0x4fcde(%rip)     # 0x56908
jne 0x6d2b
leaq 0x4fcd1(%rip), %rdi     # 0x56908
callq 0x67d0
cmpl $0x0, %eax
je 0x6d2b
leaq -0x68(%rbp), %rax
movq %rax, -0x120(%rbp)
movl $0x1, -0x124(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x124(%rbp), %rdx
callq 0x8380
jmp 0x6c76
leaq -0x108(%rbp), %rdi
leaq -0xa8(%rbp), %rax
movq %rax, -0x130(%rbp)
movl $0x2, -0x134(%rbp)
leaq -0x130(%rbp), %rsi
leaq -0x134(%rbp), %rdx
callq 0x8380
jmp 0x6caa
leaq -0x118(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq $0x2, -0xf0(%rbp)
leaq -0x135(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x83b0
movq -0x1b0(%rbp), %rcx
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
leaq 0x4fbfe(%rip), %rdi     # 0x568f0
callq 0x83d0
jmp 0x6cf9
leaq -0x135(%rbp), %rdi
callq 0x8450
leaq 0x1764(%rip), %rdi      # 0x8470
leaq 0x4fbdd(%rip), %rsi     # 0x568f0
leaq 0x4f72e(%rip), %rdx     # 0x56448
callq 0x63d0
leaq 0x4fbe2(%rip), %rdi     # 0x56908
callq 0x62d0
leaq 0x4fbbe(%rip), %rax     # 0x568f0
movq %rax, -0x140(%rbp)
leaq 0x4fbb0(%rip), %rdi     # 0x568f0
callq 0x84d0
movq %rax, -0x148(%rbp)
leaq 0x4fb9d(%rip), %rdi     # 0x568f0
callq 0x8500
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x8530
testb $0x1, %al
jne 0x6d7b
jmp 0x6e4c
leaq -0x148(%rbp), %rdi
callq 0x8570
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movslq 0x8(%rax), %rsi
leaq -0x38(%rbp), %rdi
callq 0x8590
movq %rax, -0x1b8(%rbp)
jmp 0x6dab
movq -0x1b8(%rbp), %rsi
leaq -0x178(%rbp), %rdi
callq 0x8600
jmp 0x6dc0
movq -0x158(%rbp), %rax
movq (%rax), %rdi
leaq -0x178(%rbp), %rsi
callq 0x6570
leaq -0x178(%rbp), %rdi
callq 0x6290
leaq -0x148(%rbp), %rdi
callq 0x8630
jmp 0x6d5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x72a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x726f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6e3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x135(%rbp), %rdi
callq 0x8450
leaq 0x4fac6(%rip), %rdi     # 0x56908
callq 0x62c0
jmp 0x726f
leaq 0x32390(%rip), %rsi     # 0x391e3
leaq -0xa8(%rbp), %rdi
callq 0x8650
movb %al, -0x1b9(%rbp)
jmp 0x6e67
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x6e73
jmp 0x6e9d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x8680
movq %rax, -0x1c8(%rbp)
jmp 0x6e8f
movq -0x1c8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x4f114(%rip), %rdi     # 0x55fb8
leaq 0x32342(%rip), %rsi     # 0x391ed
callq 0x6420
movq %rax, -0x1d0(%rbp)
jmp 0x6eb9
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x8590
movq %rax, -0x1d8(%rbp)
jmp 0x6ed0
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdi
callq 0x8c10
movq %rax, -0x1e0(%rbp)
jmp 0x6eec
movq -0x1e0(%rbp), %rdi
leaq 0x322f5(%rip), %rsi     # 0x391ef
callq 0x6420
movq %rax, -0x1e8(%rbp)
jmp 0x6f08
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x8590
movq %rax, -0x1f0(%rbp)
jmp 0x6f1f
movq -0x1f0(%rbp), %rsi
movq -0x1e8(%rbp), %rdi
callq 0x8c10
movq %rax, -0x1f8(%rbp)
jmp 0x6f3b
movq -0x1f8(%rbp), %rdi
leaq 0x322a6(%rip), %rsi     # 0x391ef
callq 0x6420
movq %rax, -0x200(%rbp)
jmp 0x6f57
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x8590
movq %rax, -0x208(%rbp)
jmp 0x6f6e
movq -0x208(%rbp), %rsi
movq -0x200(%rbp), %rdi
callq 0x8c10
movq %rax, -0x210(%rbp)
jmp 0x6f8a
movq -0x210(%rbp), %rdi
leaq 0x32257(%rip), %rsi     # 0x391ef
callq 0x6420
movq %rax, -0x218(%rbp)
jmp 0x6fa6
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x8590
movq %rax, -0x220(%rbp)
jmp 0x6fbd
movq -0x220(%rbp), %rsi
movq -0x218(%rbp), %rdi
callq 0x8c10
movq %rax, -0x228(%rbp)
jmp 0x6fd9
movq -0x228(%rbp), %rdi
movq 0x4ef99(%rip), %rsi     # 0x55f80
callq 0x6480
jmp 0x6fee
jmp 0x722b
movq -0x8(%rbp), %rdi
leaq 0x4f8d2(%rip), %rdx     # 0x568d0
leaq -0x38(%rbp), %rsi
xorl %ecx, %ecx
callq 0x8320
movb %al, -0x229(%rbp)
jmp 0x7011
movb -0x229(%rbp), %al
testb $0x1, %al
jne 0x7020
jmp 0x71f6
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x8590
movq %rax, -0x238(%rbp)
jmp 0x7037
movq -0x238(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x8600
jmp 0x704c
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x248(%rbp)
leaq -0x198(%rbp), %rsi
movq %rsi, -0x250(%rbp)
callq 0x6570
movq -0x250(%rbp), %rdi
callq 0x6290
movq -0x248(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x8680
movq %rax, -0x240(%rbp)
jmp 0x7095
movq -0x240(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x4ef0e(%rip), %rdi     # 0x55fb8
leaq 0x3213c(%rip), %rsi     # 0x391ed
callq 0x6420
movq %rax, -0x258(%rbp)
jmp 0x70bf
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x8590
movq %rax, -0x260(%rbp)
jmp 0x70d6
movq -0x260(%rbp), %rsi
movq -0x258(%rbp), %rdi
callq 0x8c10
movq %rax, -0x268(%rbp)
jmp 0x70f2
movq -0x268(%rbp), %rdi
leaq 0x320ef(%rip), %rsi     # 0x391ef
callq 0x6420
movq %rax, -0x270(%rbp)
jmp 0x710e
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x8590
movq %rax, -0x278(%rbp)
jmp 0x7125
movq -0x278(%rbp), %rsi
movq -0x270(%rbp), %rdi
callq 0x8c10
movq %rax, -0x280(%rbp)
jmp 0x7141
movq -0x280(%rbp), %rdi
leaq 0x320a0(%rip), %rsi     # 0x391ef
callq 0x6420
movq %rax, -0x288(%rbp)
jmp 0x715d
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x8590
movq %rax, -0x290(%rbp)
jmp 0x7174
movq -0x290(%rbp), %rsi
movq -0x288(%rbp), %rdi
callq 0x8c10
movq %rax, -0x298(%rbp)
jmp 0x7190
movq -0x298(%rbp), %rdi
leaq 0x32051(%rip), %rsi     # 0x391ef
callq 0x6420
movq %rax, -0x2a0(%rbp)
jmp 0x71ac
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x8590
movq %rax, -0x2a8(%rbp)
jmp 0x71c3
movq -0x2a8(%rbp), %rsi
movq -0x2a0(%rbp), %rdi
callq 0x8c10
movq %rax, -0x2b0(%rbp)
jmp 0x71df
movq -0x2b0(%rbp), %rdi
movq 0x4ed93(%rip), %rsi     # 0x55f80
callq 0x6480
jmp 0x71f4
jmp 0x7229
movq 0x4edbb(%rip), %rdi     # 0x55fb8
leaq 0x31fef(%rip), %rsi     # 0x391f3
callq 0x6420
movq %rax, -0x2b8(%rbp)
jmp 0x7212
movq -0x2b8(%rbp), %rdi
movq 0x4ed60(%rip), %rsi     # 0x55f80
callq 0x6480
jmp 0x7227
jmp 0x7229
jmp 0x722b
leaq -0xe8(%rbp), %rdi
callq 0x6290
leaq -0xc8(%rbp), %rdi
callq 0x6290
leaq -0xa8(%rbp), %rdi
callq 0x6290
leaq -0x88(%rbp), %rdi
callq 0x6290
leaq -0x68(%rbp), %rdi
callq 0x6290
leaq -0x38(%rbp), %rdi
callq 0x8c80
jmp 0x72b3
leaq -0xe8(%rbp), %rdi
callq 0x6290
leaq -0xc8(%rbp), %rdi
callq 0x6290
leaq -0xa8(%rbp), %rdi
callq 0x6290
leaq -0x88(%rbp), %rdi
callq 0x6290
leaq -0x68(%rbp), %rdi
callq 0x6290
leaq -0x38(%rbp), %rdi
callq 0x8c80
jmp 0x72bc
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x67a0
nopw %cs:(%rax,%rax)