// File: /workspace/github_cpp_makefile_star2_O1/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, %ebp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x178(%rsp), %rdi
movq %r15, %rsi
callq 0x55a0
leaq 0xf8(%rsp), %rdi
movq %r14, 0xd0(%rsp)
movq %r14, %rsi
callq 0x55a0
movl %ebp, 0x34(%rsp)
movq (%r15), %rbp
movq %r15, 0xd8(%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %rbp
movq %rbx, 0xb8(%rsp)
je 0x3d8d
leaq 0x48(%rsp), %r12
leaq 0x8(%rsp), %r15
movq (%rbp), %r14
movl 0xc(%r14), %r13d
movq (%r14), %rax
movl 0x8(%r14), %esi
movq %rax, 0x10(%rsp)
movq %r15, %rdi
callq 0x62f4
movl (%r14), %eax
movl %eax, 0xc8(%rsp)
movl 0x4(%r14), %eax
movl %eax, 0xcc(%rsp)
movl 0x8(%r14), %edx
movq %r15, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x4fb8
leaq 0xf8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl %r13d, %edx
callq 0x2c0d
movslq 0x1c(%rsp), %rax
testq %rax, %rax
setle %cl
jle 0x3c19
movq 0x8(%rsp), %rcx
cmpq $0x0, 0x28(%rcx)
jne 0x3c21
addq $0x60, %rcx
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rax
je 0x3c13
leaq 0x1(%rdx), %rsi
cmpq $0x0, (%rcx)
leaq 0x38(%rcx), %rcx
je 0x3bfd
cmpq %rax, %rdx
setae %cl
testb %cl, %cl
jne 0x3d2e
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x570d(%rip), %rsi      # 0x933d
callq 0x2280
movl $0x11, %edx
movq %rbx, %rdi
leaq 0x5483(%rip), %rsi      # 0x90c7
callq 0x2280
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x5481(%rip), %rsi      # 0x90d9
callq 0x2280
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x5654
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %rdi
leaq 0x56a6(%rip), %rsi      # 0x9331
callq 0x2280
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x3ca7
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x542a(%rip), %rsi      # 0x90e0
callq 0x2280
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x583c
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x3cf3
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x533c(%rip), %rsi      # 0x903e
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 0x8(%rsp), %r14
testq %r14, %r14
je 0x3d79
movq -0x8(%r14), %r13
testq %r13, %r13
je 0x3d58
imulq $0x38, %r13, %r15
leaq -0x38(%r14), %r12
leaq (%r12,%r15), %rdi
callq 0x6422
addq $-0x38, %r15
jne 0x3d49
addq $-0x8, %r14
imulq $0x38, %r13, %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x2390
movq 0xb8(%rsp), %rbx
leaq 0x48(%rsp), %r12
addq $0x8, %rbp
cmpq 0x28(%rsp), %rbp
leaq 0x8(%rsp), %r15
jne 0x3b81
movq 0xd8(%rsp), %rax
movq (%rax), %r12
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r12
je 0x3fbe
leaq 0x48(%rsp), %r14
leaq 0x8(%rsp), %r15
leaq 0x38(%rsp), %rbp
movq (%r12), %r13
movq (%r13), %rax
movl 0x8(%r13), %esi
movq %rax, 0x10(%rsp)
movq %r15, %rdi
callq 0x62f4
movl (%r13), %eax
movl %eax, 0xc0(%rsp)
movl 0x4(%r13), %eax
movl %eax, 0xc4(%rsp)
movl 0x8(%r13), %edx
movq %r15, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x4fb8
leaq 0xf8(%rsp), %rdi
movq %r15, %rsi
callq 0x2b4a
movslq 0x1c(%rsp), %rax
testq %rax, %rax
setle %cl
jle 0x3e4a
movq 0x8(%rsp), %rcx
cmpq $0x0, 0x28(%rcx)
jne 0x3e52
addq $0x60, %rcx
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rax
je 0x3e44
leaq 0x1(%rdx), %rsi
cmpq $0x0, (%rcx)
leaq 0x38(%rcx), %rcx
je 0x3e2e
cmpq %rax, %rdx
setae %cl
testb %cl, %cl
jne 0x3f59
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x54dc(%rip), %rsi      # 0x933d
callq 0x2280
movl $0x11, %edx
movq %rbx, %rdi
leaq 0x5275(%rip), %rsi      # 0x90ea
callq 0x2280
movl $0x6, %edx
movq %rbx, %rdi
leaq 0x5250(%rip), %rsi      # 0x90d9
callq 0x2280
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5654
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %rdi
leaq 0x5477(%rip), %rsi      # 0x9331
callq 0x2280
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x3ed6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x9, %edx
movq %rbx, %rdi
leaq 0x51fb(%rip), %rsi      # 0x90e0
callq 0x2280
movq %rbp, %rdi
movq %r15, %rsi
callq 0x583c
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x3f1e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x5111(%rip), %rsi      # 0x903e
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 0x8(%rsp), %r13
testq %r13, %r13
je 0x3faf
movq %r14, %rbx
movq -0x8(%r13), %rbp
testq %rbp, %rbp
je 0x3f86
imulq $0x38, %rbp, %r14
leaq -0x38(%r13), %r15
leaq (%r15,%r14), %rdi
callq 0x6422
addq $-0x38, %r14
jne 0x3f77
addq $-0x8, %r13
imulq $0x38, %rbp, %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x2390
movq %rbx, %r14
movq 0xb8(%rsp), %rbx
leaq 0x8(%rsp), %r15
leaq 0x38(%rsp), %rbp
addq $0x8, %r12
cmpq 0x28(%rsp), %r12
jne 0x3db9
cmpb $0x0, 0x34(%rsp)
je 0x41ca
leaq 0xe0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0x178(%rsp), %rdx
movq 0xd0(%rsp), %rcx
callq 0x31e7
movq 0xe0(%rsp), %r13
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r13
je 0x41bd
leaq 0x48(%rsp), %r15
leaq 0x58(%rsp), %r14
leaq 0x80(%rsp), %r12
movl (%r13), %eax
movl %eax, 0x38(%rsp)
movl 0x4(%r13), %eax
movl %eax, 0x3c(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x40(%rsp)
movq %r14, 0x48(%rsp)
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7372
leaq 0x30(%r13), %rsi
leaq 0x68(%rsp), %rdi
callq 0x4ea8
leaq 0x48(%r13), %rsi
xorl %ecx, %ecx
movq %rcx, 0x80(%rsp)
movq 0x50(%r13), %rax
movq %rax, 0x88(%rsp)
movq %rcx, 0x90(%rsp)
movq 0x60(%r13), %rax
movq %rax, 0x98(%rsp)
movups 0x68(%r13), %xmm0
movups %xmm0, 0x58(%r15)
movq %rcx, 0xb0(%rsp)
movq %r12, 0x8(%rsp)
movq %r12, %rdi
leaq 0x8(%rsp), %rdx
callq 0x6ea0
movslq 0x7c(%rsp), %rax
testq %rax, %rax
setle %cl
jle 0x40f3
movq 0x68(%rsp), %rcx
cmpq $0x0, 0x28(%rcx)
je 0x40cc
xorl %ecx, %ecx
jmp 0x40f3
addq $0x60, %rcx
leaq -0x1(%rax), %rsi
xorl %edx, %edx
cmpq %rdx, %rsi
je 0x40ea
incq %rdx
cmpq $0x0, (%rcx)
leaq 0x38(%rcx), %rcx
je 0x40d6
jmp 0x40ed
movq %rax, %rdx
cmpq %rax, %rdx
setae %cl
testb %cl, %cl
je 0x4102
cmpq $0x0, 0x98(%rsp)
je 0x413f
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x599a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x413f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
movq %r12, %rdi
callq 0x70b2
movq 0x68(%rsp), %rbp
testq %rbp, %rbp
je 0x4197
movq -0x8(%rbp), %r14
testq %r14, %r14
je 0x4171
imulq $0x38, %r14, %r15
leaq -0x38(%rbp), %r12
leaq (%r12,%r15), %rdi
callq 0x6422
addq $-0x38, %r15
jne 0x4162
addq $-0x8, %rbp
imulq $0x38, %r14, %rsi
addq $0x8, %rsi
movq %rbp, %rdi
callq 0x2390
leaq 0x58(%rsp), %r14
leaq 0x48(%rsp), %r15
leaq 0x80(%rsp), %r12
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x41ae
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2240
subq $-0x80, %r13
cmpq 0x28(%rsp), %r13
jne 0x401e
leaq 0xe0(%rsp), %rdi
callq 0x5570
leaq 0xf8(%rsp), %rdi
callq 0x532c
leaq 0x178(%rsp), %rdi
callq 0x532c
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x427e
movq %rax, %rbx
jmp 0x42ca
movq %rax, %rbx
jmp 0x4227
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4227
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0x38(%rsp), %rdi
callq 0x54f2
jmp 0x4261
movq %rax, %rbx
jmp 0x4261
movq %rax, %rbx
jmp 0x424a
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4e4c
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x4261
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2240
leaq 0xe0(%rsp), %rdi
callq 0x5570
jmp 0x42bd
jmp 0x42b0
jmp 0x42b0
jmp 0x4283
jmp 0x42b0
jmp 0x42b0
jmp 0x4292
jmp 0x427e
movq %rax, %rbx
jmp 0x42bd
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
jne 0x429f
jmp 0x42b3
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x42b3
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x42b3
jmp 0x42b0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4e4c
leaq 0xf8(%rsp), %rdi
callq 0x532c
leaq 0x178(%rsp), %rdi
callq 0x532c
movq %rbx, %rdi
callq 0x2360