// File: /workspace/github_c_makefile_star2_O3/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 0x1099(%rip), %r13      # 0x32c1
leaq 0xfb1(%rip), %r15       # 0x31e0
movq 0x2da2(%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 0x22e7
movl $0x1, %eax
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
jmpq *%rcx
movl $0x1, 0x8(%rsp)
movl %ebx, %eax
jmp 0x225a
movl $0x1, 0x2e63(%rip)      # 0x50f8
movl %ebx, %eax
jmp 0x225a
movq (%r14), %rdi
callq 0x2d18
movq %rax, 0x10(%rsp)
movl %ebx, %eax
jmp 0x225a
movl $0x1, 0xc(%rsp)
movl %ebx, %eax
jmp 0x225a
movq (%r14), %rdi
callq 0x1120
movq %rax, 0x18(%rsp)
movl %ebx, %eax
jmp 0x225a
movl $0x1, 0x4(%rsp)
movl %ebx, %eax
jmp 0x225a
movq (%r14), %rdi
callq 0x1120
movq %rax, 0x20(%rsp)
movl %ebx, %eax
jmp 0x225a
cmpl $-0x1, %eax
jne 0x23cc
movl 0x8(%rsp), %eax
orl %ebx, %eax
movl 0xc(%rsp), %ebp
orl %ebp, %eax
je 0x23d1
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
leal (%r15,%r14), %edi
xorl %eax, %eax
callq 0x1397
testl %eax, %eax
jne 0x23d6
xorl %eax, %eax
callq 0x13a2
testl %ebx, %ebx
je 0x2338
xorl %eax, %eax
callq 0x1549
movq 0x10(%rsp), %rbx
jmp 0x23b3
cmpl $-0x1, %r15d
movq 0x10(%rsp), %rbx
je 0x23db
cmpl $-0x1, %r14d
je 0x23db
testq %rbx, %rbx
je 0x23db
cmpl $0x0, 0x4(%rsp)
je 0x236e
movl %r14d, %edi
movl %r15d, %esi
callq 0x253b
jmp 0x2379
movl %r14d, %edi
movl %r15d, %esi
callq 0x27ba
movq %rax, %r14
cmpl $0x0, 0x2d75(%rip)      # 0x50f8
je 0x238d
movq %r14, %rdi
callq 0x2474
testl %ebp, %ebp
je 0x23a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bf9
testl %eax, %eax
jne 0x23e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x18ec
movq %r14, %rdi
callq 0x2458
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 0x124f
callq 0x11dc
callq 0x1203
callq 0x1228
movl $0x1, %edi
callq 0x1130
nop