// File: /workspace/github_c_makefile_star2_O2/vrancurel[P]ec/main.c
// Function: main
int main(int argc, char **argv)
{
  int n_data, n_coding, opt;
  t_mat *mat;
  char *prefix = NULL;
  int cflag = 0;
  int rflag = 0;
  int uflag = 0;
  int sflag = 0;

  n_data = n_coding = -1;
  prefix = NULL;
  while ((opt = getopt(argc, argv, "n:m:p:scruv")) != -1) {
    switch (opt) {
    case 'v':
      vflag = 1;
      break ;
    case 'u':
      uflag = 1;
      break ;
    case 'c':
      cflag = 1;
      break ;
    case 'r':
      rflag = 1;
      break ;
    case 's':
      sflag = 1;
      break ;
    case 'n':
      n_data = atoi(optarg);
      break;
    case 'm':
      n_coding = atoi(optarg);
      break;
    case 'p':
      prefix = xstrdup(optarg);
      break;
    default: /* '?' */
      xusage();
    }
  }

  if (!(uflag || cflag || rflag))
    xusage();

  if (0 != check_w(n_data + n_coding)) {
    fprintf(stderr, "Number of fragments is too big compared to Galois field size\n");
    exit(1);
  }

  setup_tables();
  //dump_tables();

  if (uflag) {
    utest();
    goto end;
  }

  if (-1 == n_data || -1 == n_coding || NULL == prefix)
    xusage();

  if (sflag) {
    mat = mat_cauchy(n_coding, n_data);
  } else {
    mat = mat_vandermonde_correct(n_coding, n_data);
  }
  if (vflag)
    mat_dump(mat);

  if (rflag) {
    if (0 != repair_data_files(prefix, mat)) {
      exit(1);
    }
  }
  create_coding_files(prefix, mat);

  mat_free(mat);

 end:
  free(prefix);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movl %edi, %ebp
movq $0x0, 0x10(%rsp)
pushq $-0x1
popq %rax
leaq 0x1284(%rip), %r13      # 0x32c1
pushq $0x1
popq %rbx
leaq 0x1199(%rip), %r14      # 0x31e0
movq %rax, 0x20(%rsp)
movq %rax, 0x18(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
movl %eax, %r15d
movl %ebp, %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1110
leal -0x63(%rax), %ecx
cmpl $0x13, %ecx
ja 0x210d
movslq (%r14,%rcx,4), %rcx
addq %r14, %rcx
movl %ebx, %eax
jmpq *%rcx
movl %ebx, 0x8(%rsp)
movl %r15d, %eax
jmp 0x206b
movl $0x1, 0x3053(%rip)      # 0x50f8
movl %r15d, %eax
jmp 0x206b
movq 0x2f27(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x2a91
movq %rax, 0x10(%rsp)
movl %r15d, %eax
jmp 0x206b
movl %ebx, 0xc(%rsp)
movl %r15d, %eax
jmp 0x206b
movq 0x2f05(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x1120
movq %rax, 0x18(%rsp)
movl %r15d, %eax
jmp 0x206b
movl %r15d, %eax
movl %ebx, 0x4(%rsp)
jmp 0x206b
movq 0x2ee0(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x1120
movq %rax, 0x20(%rsp)
movl %r15d, %eax
jmp 0x206b
cmpl $-0x1, %eax
jne 0x21e8
movl 0x8(%rsp), %eax
orl %r15d, %eax
movl 0xc(%rsp), %ebp
orl %ebp, %eax
je 0x21e8
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r12
leal (%r12,%r14), %edi
xorl %eax, %eax
callq 0x1287
testl %eax, %eax
jne 0x21ed
xorl %eax, %eax
callq 0x1292
testl %r15d, %r15d
je 0x2160
xorl %eax, %eax
callq 0x1416
movq 0x10(%rsp), %rbx
jmp 0x21cf
cmpl $-0x1, %r12d
movq 0x10(%rsp), %rbx
je 0x21e8
cmpl $-0x1, %r14d
je 0x21e8
testq %rbx, %rbx
je 0x21e8
cmpl $0x0, 0x4(%rsp)
je 0x218a
movl %r14d, %edi
movl %r12d, %esi
callq 0x2358
jmp 0x2195
movl %r14d, %edi
movl %r12d, %esi
callq 0x25b4
movq %rax, %r14
cmpl $0x0, 0x2f59(%rip)      # 0x50f8
je 0x21a9
movq %r14, %rdi
callq 0x229a
testl %ebp, %ebp
je 0x21bc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1a43
testl %eax, %eax
jne 0x2209
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1770
movq %r14, %rdi
callq 0x227e
movq %rbx, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1ff0
movq 0x2e04(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x10cf(%rip), %rdi      # 0x32cd
pushq $0x3d
popq %rsi
pushq $0x1
popq %rdx
callq 0x1140
pushq $0x1
popq %rdi
callq 0x1130
nopl (%rax)