// File: /workspace/github_c_makefile_star2_O1/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)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x20(%rsp)
leaq 0x10a9(%rip), %r13      # 0x32c1
leaq 0xfc1(%rip), %r15       # 0x31e0
movq 0x2db2(%rip), %r14      # 0x4fd8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
movl %eax, %ebx
movl %ebp, %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1110
leal -0x63(%rax), %ecx
cmpl $0x13, %ecx
ja 0x22d7
movl $0x1, %eax
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
jmpq *%rcx
movl $0x1, 0x8(%rsp)
movl %ebx, %eax
jmp 0x224a
movl $0x1, 0x2e73(%rip)      # 0x50f8
movl %ebx, %eax
jmp 0x224a
movq (%r14), %rdi
callq 0x2d10
movq %rax, 0x10(%rsp)
movl %ebx, %eax
jmp 0x224a
movl $0x1, 0xc(%rsp)
movl %ebx, %eax
jmp 0x224a
movq (%r14), %rdi
callq 0x1120
movq %rax, 0x18(%rsp)
movl %ebx, %eax
jmp 0x224a
movl $0x1, 0x4(%rsp)
movl %ebx, %eax
jmp 0x224a
movq (%r14), %rdi
callq 0x1120
movq %rax, 0x20(%rsp)
movl %ebx, %eax
jmp 0x224a
cmpl $-0x1, %eax
jne 0x23bc
movl 0x8(%rsp), %eax
orl %ebx, %eax
movl 0xc(%rsp), %ebp
orl %ebp, %eax
je 0x23c1
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
leal (%r15,%r14), %edi
xorl %eax, %eax
callq 0x13c7
testl %eax, %eax
jne 0x23c6
xorl %eax, %eax
callq 0x13d2
testl %ebx, %ebx
je 0x2328
xorl %eax, %eax
callq 0x1579
movq 0x10(%rsp), %rbx
jmp 0x23a3
cmpl $-0x1, %r15d
movq 0x10(%rsp), %rbx
je 0x23cb
cmpl $-0x1, %r14d
je 0x23cb
testq %rbx, %rbx
je 0x23cb
cmpl $0x0, 0x4(%rsp)
je 0x235e
movl %r14d, %edi
movl %r15d, %esi
callq 0x252b
jmp 0x2369
movl %r14d, %edi
movl %r15d, %esi
callq 0x27ae
movq %rax, %r14
cmpl $0x0, 0x2d85(%rip)      # 0x50f8
je 0x237d
movq %r14, %rdi
callq 0x2464
testl %ebp, %ebp
je 0x2390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1c05
testl %eax, %eax
jne 0x23d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x191c
movq %r14, %rdi
callq 0x2448
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 0x1278
callq 0x1205
callq 0x122c
callq 0x1251
movl $0x1, %edi
callq 0x1130
nop