// File: /workspace/github_cpp_makefile_star2_O3/BUSEC[P]RPKI_Downgrade_Detector/./exp.cpp
// Function: OutputDowngrades(std::vector<ROA*, std::allocator<ROA*>>*, std::vector<ROA*, std::allocator<ROA*>>*, std::ostream*, bool)
void OutputDowngrades( vector<ROA*>* oldROAs, vector<ROA*>* newROAs, ostream* output, bool U2I ) {
  vector<PrefixRange*> validToUnknownPrefixes; 


  ROAGroup oldPrefixes = ROAGroup(oldROAs); // old.AS.valid
  ROAGroup newPrefixes = ROAGroup(newROAs); // new.AS.valid

  //valid to invalid move this into method 
  for ( ROA* rOld: *oldROAs){
    int as = rOld->getAS();

    PrefixRange effect = PrefixRange( rOld->getPrefix(), rOld->getMaxlen() ); 
    effect.addROA( rOld->getPrefix(), rOld->getMaxlen() ); 

    ValidToInvalid( &newPrefixes, &effect, as);

    if( ! effect.empty() ) {
      (*output)<<"{";
      (*output)<<"\"CHANGE\":\"-V2I\", ";
      (*output)<<"\"ROA\":"<<rOld->toJSON()<<", ";      
      (*output)<< "\"EFFECT\":"<<effect.toJSON(); 
      (*output)<<"}"<<endl;
    }
  }

  //valid to unknown
  for ( ROA* rOld: *oldROAs){
    PrefixRange effect = PrefixRange( rOld->getPrefix(), rOld->getMaxlen() );
    effect.addROA( rOld->getPrefix(), rOld->getMaxlen() );

    ValidToUnknown( &newPrefixes, &effect);

    if( ! effect.empty() )  {
      (*output)<<"{";
      (*output)<<"\"CHANGE\":\"-V2U\", ";
      (*output)<<"\"ROA\":"<<rOld->toJSON()<<", ";      
      (*output)<< "\"EFFECT\":"<<effect.toJSON(); 
      (*output)<<"}"<<endl;
    }

  }
  
  if( U2I ){
    //unknown to invalid
    vector<UnknownToInvalidDowngrade> unknownToInvalid = UnknownToInvalid( &newPrefixes, &oldPrefixes, newROAs);
      
    for (UnknownToInvalidDowngrade effect:  unknownToInvalid){
      if( ! effect.empty() ) (*output)<<effect.toJSON();
    }
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movl %ecx, 0x3c(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x178(%rsp), %rdi
movq %r15, %rsi
callq 0x532a
leaq 0xf8(%rsp), %rdi
movq %r14, 0xc0(%rsp)
movq %r14, %rsi
callq 0x532a
movq (%r15), %r12
movq %r15, 0xc8(%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x30(%rsp)
cmpq %rax, %r12
je 0x3da7
leaq 0x10(%rsp), %r15
movq (%r12), %r14
movl 0xc(%r14), %r13d
movl 0x8(%r14), %esi
movq (%r14), %rax
movq %rax, 0x18(%rsp)
movq %r15, %rdi
callq 0x6062
movq (%r14), %rax
movq %rax, 0xd8(%rsp)
movl 0x8(%r14), %edx
movq %r15, %rdi
leaq 0xd8(%rsp), %rsi
callq 0x4d5e
leaq 0xf8(%rsp), %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x2bba
movslq 0x24(%rsp), %rax
movq 0x10(%rsp), %r13
testq %rax, %rax
jle 0x3b24
cmpq $0x0, 0x28(%r13)
jne 0x3a0a
leaq 0x60(%r13), %rcx
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rax
je 0x3a01
leaq 0x1(%rdx), %rsi
cmpq $0x0, (%rcx)
leaq 0x38(%rcx), %rcx
je 0x39eb
cmpq %rax, %rdx
jae 0x3b29
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x4924(%rip), %rsi      # 0x833d
callq 0x2280
movl $0x11, %edx
movq %rbx, %rdi
leaq 0x469a(%rip), %rsi      # 0x80c7
callq 0x2280
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x4698(%rip), %rsi      # 0x80d9
callq 0x2280
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x53d8
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %rdi
leaq 0x48bd(%rip), %rsi      # 0x8331
callq 0x2280
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3a95
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x463c(%rip), %rsi      # 0x80e0
callq 0x2280
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x55ba
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3ae4
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x454b(%rip), %rsi      # 0x803e
callq 0x2280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x10(%rsp), %r13
testq %r13, %r13
je 0x3b73
movq %r12, 0x8(%rsp)
movq %rbx, %rbp
movq %r15, %rbx
movq -0x8(%r13), %r14
testq %r14, %r14
je 0x3b54
imulq $0x38, %r14, %r15
leaq -0x38(%r13), %r12
leaq (%r12,%r15), %rdi
callq 0x618a
addq $-0x38, %r15
jne 0x3b45
addq $-0x8, %r13
imulq $0x38, %r14, %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x2390
movq %rbx, %r15
movq %rbp, %rbx
movq 0x8(%rsp), %r12
addq $0x8, %r12
cmpq 0x30(%rsp), %r12
jne 0x397a
movq 0xc8(%rsp), %rax
movq (%rax), %r12
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
cmpq %rax, %r12
je 0x3da7
leaq 0x10(%rsp), %r15
movq (%r12), %r13
movl 0x8(%r13), %esi
movq (%r13), %rax
movq %rax, 0x18(%rsp)
movq %r15, %rdi
callq 0x6062
movq (%r13), %rax
movq %rax, 0xd0(%rsp)
movl 0x8(%r13), %edx
movq %r15, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x4d5e
leaq 0xf8(%rsp), %rdi
movq %r15, %rsi
callq 0x2af7
movslq 0x24(%rsp), %rax
movq 0x10(%rsp), %r14
testq %rax, %rax
jle 0x3d49
cmpq $0x0, 0x28(%r14)
jne 0x3c2f
leaq 0x60(%r14), %rcx
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rax
je 0x3c26
leaq 0x1(%rdx), %rsi
cmpq $0x0, (%rcx)
leaq 0x38(%rcx), %rcx
je 0x3c10
cmpq %rax, %rdx
jae 0x3d4e
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x46ff(%rip), %rsi      # 0x833d
callq 0x2280
movl $0x11, %edx
movq %rbx, %rdi
leaq 0x4498(%rip), %rsi      # 0x80ea
callq 0x2280
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x4473(%rip), %rsi      # 0x80d9
callq 0x2280
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x53d8
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %rdi
leaq 0x4698(%rip), %rsi      # 0x8331
callq 0x2280
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3cba
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x4417(%rip), %rsi      # 0x80e0
callq 0x2280
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x55ba
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3d09
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x4326(%rip), %rsi      # 0x803e
callq 0x2280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x3d98
movq %r12, 0x8(%rsp)
movq %rbx, %r12
movq %r15, %rbx
movq -0x8(%r14), %r13
testq %r13, %r13
je 0x3d79
imulq $0x38, %r13, %rbp
leaq -0x38(%r14), %r15
leaq (%r15,%rbp), %rdi
callq 0x618a
addq $-0x38, %rbp
jne 0x3d6a
addq $-0x8, %r14
imulq $0x38, %r13, %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x2390
movq %rbx, %r15
movq %r12, %rbx
movq 0x8(%rsp), %r12
addq $0x8, %r12
cmpq 0x30(%rsp), %r12
jne 0x3ba4
cmpb $0x0, 0x3c(%rsp)
je 0x3fa3
leaq 0xe0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x178(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0x3028
movq 0xe0(%rsp), %r13
movq 0xe8(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %r13
je 0x3f96
leaq 0x50(%rsp), %r15
leaq 0x60(%rsp), %r14
leaq 0x88(%rsp), %r12
movq (%r13), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x48(%rsp)
movq %r14, 0x50(%rsp)
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7078
leaq 0x30(%r13), %rsi
leaq 0x70(%rsp), %rdi
callq 0x4c54
leaq 0x48(%r13), %rsi
xorl %ecx, %ecx
movq %rcx, 0x88(%rsp)
movq 0x50(%r13), %rax
movq %rax, 0x90(%rsp)
movq %rcx, 0x98(%rsp)
movq 0x60(%r13), %rax
movq %rax, 0xa0(%rsp)
movups 0x68(%r13), %xmm0
movups %xmm0, 0x58(%r15)
movq %rcx, 0xb8(%rsp)
movq %r12, 0x10(%rsp)
movq %r12, %rdi
leaq 0x10(%rsp), %rdx
callq 0x6c02
movslq 0x84(%rsp), %rax
testq %rax, %rax
jle 0x3ed0
movq 0x70(%rsp), %rcx
cmpq $0x0, 0x28(%rcx)
jne 0x3edb
addq $0x60, %rcx
leaq -0x1(%rax), %rsi
xorl %edx, %edx
cmpq %rdx, %rsi
je 0x3ec8
incq %rdx
cmpq $0x0, (%rcx)
leaq 0x38(%rcx), %rcx
je 0x3eb4
jmp 0x3ecb
movq %rax, %rdx
cmpq %rax, %rdx
jb 0x3edb
cmpq $0x0, 0xa0(%rsp)
je 0x3f18
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x571a
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3f18
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2240
movq %r12, %rdi
callq 0x6e14
movq 0x70(%rsp), %rbp
testq %rbp, %rbp
je 0x3f70
movq -0x8(%rbp), %r14
testq %r14, %r14
je 0x3f4a
imulq $0x38, %r14, %r15
leaq -0x38(%rbp), %r12
leaq (%r12,%r15), %rdi
callq 0x618a
addq $-0x38, %r15
jne 0x3f3b
addq $-0x8, %rbp
imulq $0x38, %r14, %rsi
addq $0x8, %rsi
movq %rbp, %rdi
callq 0x2390
leaq 0x60(%rsp), %r14
leaq 0x50(%rsp), %r15
leaq 0x88(%rsp), %r12
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x3f87
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2240
subq $-0x80, %r13
cmpq 0x8(%rsp), %r13
jne 0x3e07
leaq 0xe0(%rsp), %rdi
callq 0x52fa
leaq 0xf8(%rsp), %rdi
callq 0x50b4
leaq 0x178(%rsp), %rdi
callq 0x50b4
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4062
movq %rax, %rbx
jmp 0x40a4
jmp 0x408a
jmp 0x4067
jmp 0x408a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x400f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x400f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x527c
jmp 0x4049
movq %rax, %rbx
jmp 0x4049
movq %rax, %rbx
jmp 0x4032
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4bf8
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x4049
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0xe0(%rsp), %rdi
callq 0x52fa
jmp 0x4097
jmp 0x408a
jmp 0x4067
jmp 0x408a
jmp 0x4062
jmp 0x4067
movq %rax, %rbx
jmp 0x4097
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x408d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x408d
jmp 0x408a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4bf8
leaq 0xf8(%rsp), %rdi
callq 0x50b4
leaq 0x178(%rsp), %rdi
callq 0x50b4
movq %rbx, %rdi
callq 0x2360