// File: Marcos30004347[P]JSS-with-VNS/main.cpp
// Function: main
int main (int argc, char *argv[]) {

  if (argc < 3)
    return help(argv[0]);

  srand(time(nullptr));

  ifstream file(argv[1]);
  string line;
  
  it_max = atoi(argv[2]);
  
  for(unsigned i=0; i<4; i++)
    getline(file, line);

  file >> n >> m;
  for(unsigned i=0; i<n; i++) {
    vector<op> job;

    for(unsigned j=0; j<m; j++){
      op curr;
      file >> curr.machine >> curr.cost;
      job.push_back(curr);
    }

    ops.push_back(job);
  }

  costs = build_cost_matrix(ops);

  solution s;
  for (int j=0; j<n; j++)
    for (int i=0; i<m; i++)
      s.push_back(j);
  
  s = permutate(s);

  solution vns = general_vns(s);

  cout << total_cost(vns) << endl;

  file.close();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x8(%rbp)
jge 0x3bc3
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2400
movl %eax, -0x4(%rbp)
jmp 0x3ffb
xorl %eax, %eax
movl %eax, %edi
callq 0x20f0
movl %eax, %edi
callq 0x2100
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x218(%rbp), %rdi
movl $0x8, %edx
callq 0x21d0
leaq -0x238(%rbp), %rdi
callq 0x2160
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2190
movl %eax, 0xd545(%rip)      # 0x11150
movl $0x0, -0x23c(%rbp)
cmpl $0x4, -0x23c(%rbp)
jae 0x3c5d
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x2040
jmp 0x3c33
jmp 0x3c35
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x3c15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x3fe1
leaq 0xd4e4(%rip), %rsi      # 0x11148
leaq -0x218(%rbp), %rdi
callq 0x2030
movq %rax, -0x320(%rbp)
jmp 0x3c79
movq -0x320(%rbp), %rdi
leaq 0xd4c5(%rip), %rsi      # 0x1114c
callq 0x2030
jmp 0x3c8e
movl $0x0, -0x250(%rbp)
movl -0x250(%rbp), %eax
cmpl 0xd4a4(%rip), %eax      # 0x11148
jae 0x3d7f
leaq -0x268(%rbp), %rdi
callq 0x4c60
movl $0x0, -0x26c(%rbp)
movl -0x26c(%rbp), %eax
cmpl 0xd480(%rip), %eax      # 0x1114c
jae 0x3d4a
leaq -0x218(%rbp), %rdi
leaq -0x274(%rbp), %rsi
callq 0x2030
movq %rax, -0x328(%rbp)
jmp 0x3cea
movq -0x328(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x2030
jmp 0x3cff
leaq -0x268(%rbp), %rdi
leaq -0x274(%rbp), %rsi
callq 0x4c80
jmp 0x3d14
jmp 0x3d16
movl -0x26c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x26c(%rbp)
jmp 0x3cc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x4af0
jmp 0x3fe1
leaq 0xd3df(%rip), %rdi      # 0x11130
leaq -0x268(%rbp), %rsi
callq 0x4cf0
jmp 0x3d5f
leaq -0x268(%rbp), %rdi
callq 0x4af0
movl -0x250(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
jmp 0x3c98
leaq 0xd3aa(%rip), %rsi      # 0x11130
leaq -0x290(%rbp), %rdi
callq 0x3960
jmp 0x3d94
leaq 0xd37d(%rip), %rdi      # 0x11118
leaq -0x290(%rbp), %rsi
callq 0x4d60
leaq -0x290(%rbp), %rdi
callq 0x4040
leaq -0x2a8(%rbp), %rdi
callq 0x4430
movl $0x0, -0x2ac(%rbp)
movl -0x2ac(%rbp), %eax
cmpl 0xd373(%rip), %eax      # 0x11148
jae 0x3e50
movl $0x0, -0x2b0(%rbp)
movl -0x2b0(%rbp), %eax
cmpl 0xd35f(%rip), %eax      # 0x1114c
jae 0x3e3a
movl -0x2ac(%rbp), %eax
movl %eax, -0x2b4(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b4(%rbp), %rsi
callq 0x4d90
jmp 0x3e10
jmp 0x3e12
movl -0x2b0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b0(%rbp)
jmp 0x3de1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x3fd5
jmp 0x3e3c
movl -0x2ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2ac(%rbp)
jmp 0x3dc9
leaq -0x2d0(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x2860
jmp 0x3e65
leaq -0x2a8(%rbp), %rdi
movq %rdi, -0x330(%rbp)
leaq -0x2d0(%rbp), %rsi
movq %rsi, -0x338(%rbp)
callq 0x4830
movq -0x338(%rbp), %rdi
callq 0x43d0
movq -0x330(%rbp), %rsi
leaq -0x300(%rbp), %rdi
callq 0x44f0
jmp 0x3ea7
leaq -0x2e8(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x37b0
jmp 0x3ebc
leaq -0x300(%rbp), %rdi
callq 0x43d0
leaq -0x318(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x44f0
jmp 0x3edd
leaq -0x318(%rbp), %rdi
callq 0x2450
movl %eax, -0x33c(%rbp)
jmp 0x3ef1
movl -0x33c(%rbp), %esi
movq 0xd0da(%rip), %rdi      # 0x10fd8
callq 0x2150
movq %rax, -0x348(%rbp)
jmp 0x3f0c
movq -0x348(%rbp), %rdi
movq 0xd0ae(%rip), %rsi      # 0x10fc8
callq 0x2140
jmp 0x3f21
leaq -0x318(%rbp), %rdi
callq 0x43d0
leaq -0x218(%rbp), %rdi
callq 0x2050
jmp 0x3f3b
movl $0x0, -0x4(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x43d0
leaq -0x2a8(%rbp), %rdi
callq 0x43d0
leaq -0x238(%rbp), %rdi
callq 0x20c0
leaq -0x218(%rbp), %rdi
callq 0x2060
jmp 0x3ffb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x43d0
jmp 0x3fd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x3fc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x43d0
leaq -0x2e8(%rbp), %rdi
callq 0x43d0
leaq -0x2a8(%rbp), %rdi
callq 0x43d0
leaq -0x238(%rbp), %rdi
callq 0x20c0
leaq -0x218(%rbp), %rdi
callq 0x2060
jmp 0x4007
movl -0x4(%rbp), %eax
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
movq -0x248(%rbp), %rdi
callq 0x21c0
nopw %cs:(%rax,%rax)
nopl (%rax)