// File: /workspace/github_cpp_makefile_star2_O2/temelmertcan[P]multgen/src/wallace.cpp
// Function: compress_concat_vector(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, int&)
void compress_concat_vector (string* arr, int& size){

  const unsigned long max = std::string::npos;

  // cout << "Starting compress_concat_vector before:" << endl;
  // for (int i = 0 ; i <size ; i++)
  //   cout << arr[i] << " ";
  // cout << endl;
    
  
  try{
    
    int offset = 0;
    for (int i = 0; i<size-1-offset; i++){
      string& a = arr[i];
      string b = arr[i+1+offset];
      if (a.find("'b0") < max && b.find("'b0") < max){

	// !!
	//cout << "Merging zeros sizes: " << a.size() << " "<< b.size() << endl;
	//cout << "Merging zeros find res: " << a.find("'b0") << " "<< b.find("'b0") << endl;
	//cout << "Merging zeros: " << a << " "<< b << endl;
	
	int newcoef = stoi(a.substr(0,a.find("'b0"))) + stoi(b.substr(0,b.find("'b0")));
	a = to_string(newcoef) + "'b0";
	i--;
	offset++;
      }
      else if (a.find("[") <max && b.find("[") <max && a.find("]") <max && b.find("]")<max
	  && a.substr(0, a.find("[")) == b.substr(0, b.find("["))){

	int s1, e1;
	if (a.find(":")<max){
	  e1 = stoi(a.substr(a.find("[")+1,a.find(":")));
	  s1 = stoi(a.substr(a.find(":")+1,a.find("]")));
	}else {
	  s1 = stoi(a.substr(a.find("[")+1,a.find("]")));
	  e1 = s1;
	}

	int s2, e2;
	if (b.find(":")<max){
	  e2 = stoi(b.substr(b.find("[")+1,b.find(":")));
	  s2 = stoi(b.substr(b.find(":")+1,b.find("]")));
	}else {
	  s2 = stoi(b.substr(a.find("[")+1,b.find("]")));
	  e2 = s2;
	}
      
	if (s2 == (1 + e1)){
	  
	  // !!
	  //cout << "Merging vectors: " << a << " "<< b << endl;

	  
	  a = a.substr(0, a.find("[")) + "[" + to_string(e2) + ":" + to_string(s1) + "]";
	  i--;
	  offset++;
	} else {
	  arr[i+1] = b;
	}
      } else
	arr[i+1] = b;
    }

    size -= offset;
    

  }
  catch(exception &err)
    {
      cout<<"Conversion failure"<<endl;
      //cout << err << endl;
    }

  // for (int i = 0 ; i <size ; i++)
  //   cout << arr[i] << " ";
  // cout << endl;
  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, -0x98(%rbp)
movq %rdi, %rbx
xorl %edx, %edx
leaq 0x597e(%rip), %r13      # 0x32fc5
xorl %esi, %esi
movq %rdi, -0x50(%rbp)
movq -0x98(%rbp), %rax
movl (%rax), %eax
movl %esi, %ecx
notl %ecx
addl %eax, %ecx
cmpl %ecx, %edx
jge 0x2dc7e
movq %rsi, -0x38(%rbp)
leal (%rdx,%rsi), %eax
incl %eax
movslq %eax, %rsi
shlq $0x5, %rsi
addq %rbx, %rsi
leaq -0x90(%rbp), %rdi
movq %rdx, %r14
callq 0x2250
movq %rbx, %rax
movq %r14, -0x30(%rbp)
movslq %r14d, %rbx
shlq $0x5, %rbx
addq %rax, %rbx
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2370
cmpq $-0x1, %rax
je 0x2d7a8
leaq -0x90(%rbp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2370
cmpq $-0x1, %rax
je 0x2d7a8
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2370
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, %r12d
leaq -0x90(%rbp), %r13
movq %r13, %rdi
leaq 0x58ba(%rip), %rsi      # 0x32fc5
xorl %edx, %edx
callq 0x2370
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, %r13d
addl %r12d, %r13d
movq %r15, %rdi
callq 0x20f0
movq %r14, %rdi
callq 0x20f0
movq %r15, %rdi
movl %r13d, %esi
callq 0x11c73
movq %r14, %rdi
movq %r15, %rsi
leaq 0x5861(%rip), %r13      # 0x32fc5
movq %r13, %rdx
callq 0x11ba1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x20f0
movq %r15, %rdi
callq 0x20f0
movq -0x30(%rbp), %r14
decl %r14d
movq -0x38(%rbp), %rax
incl %eax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rbx
leaq -0x90(%rbp), %r12
jmp 0x2d992
movq -0x30(%rbp), %rax
leal 0x1(%rax), %r12d
movq %rbx, %rdi
leaq 0x4cd0(%rip), %rsi      # 0x3248a
xorl %edx, %edx
callq 0x2370
movslq %r12d, %r12
cmpq $-0x1, %rax
je 0x2d971
leaq -0x90(%rbp), %rdi
leaq 0x4cae(%rip), %rsi      # 0x3248a
xorl %edx, %edx
callq 0x2370
cmpq $-0x1, %rax
je 0x2d971
movq %rbx, %rdi
leaq 0x4622(%rip), %rsi      # 0x31e19
xorl %edx, %edx
callq 0x2370
cmpq $-0x1, %rax
je 0x2d971
leaq -0x90(%rbp), %rdi
leaq 0x4603(%rip), %rsi      # 0x31e19
xorl %edx, %edx
callq 0x2370
cmpq $-0x1, %rax
je 0x2d971
movq %rbx, %rdi
leaq 0x4c59(%rip), %r14      # 0x3248a
movq %r14, %rsi
xorl %edx, %edx
callq 0x2370
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
leaq -0x90(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2370
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2faae
movl %eax, %r13d
movq %r15, %rdi
callq 0x20f0
movq %r14, %rdi
callq 0x20f0
testb %r13b, %r13b
leaq 0x5722(%rip), %r13      # 0x32fc5
je 0x2d971
movq %rbx, %rdi
leaq 0x2df7(%rip), %r14      # 0x306aa
movq %r14, %rsi
xorl %edx, %edx
callq 0x2370
movq %rbx, %rdi
leaq 0x4bc3(%rip), %rsi      # 0x3248a
xorl %edx, %edx
cmpq $-0x1, %rax
je 0x2d9a9
callq 0x2370
leaq 0x1(%rax), %r13
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2370
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, -0x44(%rbp)
movq %r14, %rdi
callq 0x20f0
movq %rbx, %rdi
leaq 0x2d8a(%rip), %rsi      # 0x306aa
xorl %edx, %edx
callq 0x2370
leaq 0x1(%rax), %r13
movq %rbx, %rdi
leaq 0x44e4(%rip), %rsi      # 0x31e19
xorl %edx, %edx
callq 0x2370
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, -0x40(%rbp)
leaq 0x4b26(%rip), %r13      # 0x3248a
movq %r14, %rdi
callq 0x20f0
jmp 0x2d9ff
shlq $0x5, %r12
movq -0x50(%rbp), %rbx
addq %rbx, %r12
movq %r12, %rdi
leaq -0x90(%rbp), %r12
movq %r12, %rsi
callq 0x2130
movq -0x30(%rbp), %r14
movq %r12, %rdi
callq 0x20f0
incl %r14d
movq %r14, %rdx
movq -0x38(%rbp), %rsi
jmp 0x2d64d
callq 0x2370
leaq 0x1(%rax), %r13
movq %rbx, %rdi
leaq 0x445d(%rip), %rsi      # 0x31e19
xorl %edx, %edx
callq 0x2370
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, %r15d
movq %r14, %rdi
callq 0x20f0
movl %r15d, -0x40(%rbp)
movl %r15d, -0x44(%rbp)
leaq 0x4a8b(%rip), %r13      # 0x3248a
leaq -0x90(%rbp), %rdi
movq %rdi, %r15
leaq 0x2c9a(%rip), %r14      # 0x306aa
movq %r14, %rsi
xorl %edx, %edx
callq 0x2370
cmpq $-0x1, %rax
je 0x2dac7
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2370
leaq 0x1(%rax), %r13
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2370
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, -0x3c(%rbp)
movq %r14, %rdi
callq 0x20f0
leaq -0x90(%rbp), %r15
movq %r15, %rdi
leaq 0x2c2a(%rip), %rsi      # 0x306aa
xorl %edx, %edx
callq 0x2370
leaq 0x1(%rax), %r13
movq %r15, %rdi
leaq 0x4384(%rip), %rsi      # 0x31e19
xorl %edx, %edx
callq 0x2370
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, %r13d
movq %r14, %rdi
callq 0x20f0
jmp 0x2db1a
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2370
leaq 0x1(%rax), %r13
movq %r15, %rdi
leaq 0x4337(%rip), %rsi      # 0x31e19
xorl %edx, %edx
callq 0x2370
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x2fa8d
movl %eax, %r13d
movq %r14, %rdi
callq 0x20f0
movl %r13d, -0x3c(%rbp)
movl -0x44(%rbp), %eax
incl %eax
cmpl %eax, %r13d
jne 0x2dc51
movq %rbx, %rdi
leaq 0x4958(%rip), %r12      # 0x3248a
movq %r12, %rsi
xorl %edx, %edx
callq 0x2370
leaq -0x158(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21e0
leaq 0x546b(%rip), %r13      # 0x32fc5
leaq -0xd8(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x11ba1
leaq -0x138(%rbp), %r14
movq %r14, %rdi
movl -0x3c(%rbp), %esi
callq 0x11c73
leaq -0x178(%rbp), %r15
movq %r15, %rdi
leaq -0xd8(%rbp), %rsi
movq %r14, %rdx
callq 0x11bca
leaq -0xf8(%rbp), %rdi
movq %r15, %rsi
leaq 0x2b02(%rip), %rdx      # 0x306aa
callq 0x11ba1
leaq -0x118(%rbp), %r14
movq %r14, %rdi
movl -0x40(%rbp), %esi
callq 0x11c73
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
leaq -0xf8(%rbp), %rsi
movq %r14, %rdx
callq 0x11bca
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
leaq 0x4230(%rip), %rdx      # 0x31e19
callq 0x11ba1
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x20f0
movq %r15, %rdi
callq 0x20f0
leaq -0x118(%rbp), %rdi
callq 0x20f0
leaq -0xf8(%rbp), %rdi
callq 0x20f0
leaq -0x178(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0xd8(%rbp), %rdi
callq 0x20f0
leaq -0x158(%rbp), %rdi
jmp 0x2d782
shlq $0x5, %r12
movq -0x50(%rbp), %rbx
addq %rbx, %r12
movq %r12, %rdi
leaq -0x90(%rbp), %r12
movq %r12, %rsi
callq 0x2130
leaq 0x5350(%rip), %r13      # 0x32fc5
movq -0x30(%rbp), %r14
jmp 0x2d992
subl %esi, %eax
movq -0x98(%rbp), %rcx
movl %eax, (%rcx)
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2dd7a
jmp 0x2dd7a
jmp 0x2dd8b
jmp 0x2dd8b
jmp 0x2dd8b
movq %rdx, %rbx
movq %rax, %r14
jmp 0x2dcfa
movq %rdx, %rbx
movq %rax, %r14
jmp 0x2dd12
movq %rdx, %rbx
movq %rax, %r14
jmp 0x2dd2a
movq %rdx, %rbx
movq %rax, %r14
jmp 0x2dd06
movq %rdx, %rbx
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
callq 0x20f0
jmp 0x2dcee
movq %rdx, %rbx
movq %rax, %r14
leaq -0x118(%rbp), %rdi
callq 0x20f0
leaq -0xf8(%rbp), %rdi
callq 0x20f0
leaq -0x178(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0xd8(%rbp), %rdi
callq 0x20f0
leaq -0x158(%rbp), %rdi
jmp 0x2dd84
movq %rdx, %rbx
movq %rax, %r14
jmp 0x2dd1e
jmp 0x2dd8b
jmp 0x2dd7a
jmp 0x2dd8b
jmp 0x2dd8b
jmp 0x2dd7a
jmp 0x2dd8b
jmp 0x2dd7a
jmp 0x2dd8b
jmp 0x2dd7a
jmp 0x2dd8b
jmp 0x2dd7a
jmp 0x2dd8b
jmp 0x2dd8b
jmp 0x2dd7a
movq %rdx, %rbx
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
jmp 0x2dd84
movq %rdx, %rbx
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
callq 0x20f0
jmp 0x2dd80
movq %rdx, %rbx
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x20f0
jmp 0x2dd91
movq %rdx, %rbx
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x2dda5
movq %rdx, %rbx
movq %rax, %r14
cmpl $0x1, %ebx
jne 0x2dddf
movq %r14, %rdi
callq 0x20c0
movq 0x1120f(%rip), %rdi     # 0x3efc8
leaq 0x5951(%rip), %rsi      # 0x33711
callq 0x21c0
movq %rax, %rdi
callq 0x2110
callq 0x2300
jmp 0x2dc89
movq %rax, %r14
callq 0x2300
movq %r14, %rdi
callq 0x2330
movq %rax, %rdi
callq 0x11f30