// File: /workspace/github_c_makefile_star2_O0/negge[P]xlink/src/xlink.c
// Function: main
int main(int argc, char *argv[]) {
  xlink_binary bin;
  int c;
  int opt_index;
  unsigned int flags;
  char mapfile[256];
  xlink_binary_init(&bin);
  flags = 0;
  while ((c = getopt_long(argc, argv, OPTSTRING, OPTIONS, &opt_index)) != EOF) {
    switch (c) {
      case 'o' : {
        bin.output = optarg;
        break;
      }
      case 'e' : {
        bin.entry = optarg;
        break;
      }
      case 'i' : {
        bin.init = optarg;
        break;
      }
      case 'p' : {
        flags |= MOD_PACK;
        break;
      }
      case '1' : {
        flags |= MOD_ONE;
        break;
      }
      case 'L' : {
        flags |= MOD_LOW;
        break;
      }
      case 'C' : {
        flags |= MOD_CLAMP;
        break;
      }
      case 'E' : {
        flags |= MOD_EXIT;
        break;
      }
      case 'B' : {
        flags |= MOD_BASE;
        break;
      }
      case 'M' : {
        bin.hash_table_memory = atoi(optarg);
        break;
      }
      case 'd' : {
        flags |= MOD_DUMP;
        break;
      }
      case 'm' : {
        flags |= MOD_MAP;
        break;
      }
      case 's' : {
        flags |= MOD_SPLIT;
        break;
      }
      case 'c' : {
        flags |= MOD_CHECK;
        break;
      }
      case 'h' :
      default : {
        usage(argv[0]);
        return EXIT_FAILURE;
      }
    }
  }
  XLINK_ERROR(flags & MOD_PACK && flags & MOD_EXIT,
   ("Specified -E --exit with -p --pack but only valid for unpacked binaries"));
  XLINK_ERROR(bin.hash_table_memory & 1,
   ("Specified -M --memory size %i must be even", bin.hash_table_memory));
  XLINK_ERROR(flags & MOD_ONE && !(flags & MOD_PACK),
   ("Specified -1 --one without -p --pack but only valid for packed binaries"));
  XLINK_ERROR(flags & MOD_LOW && !(flags & MOD_PACK || flags & MOD_CHECK),
   ("Specified -L --low without -p --pack or -c --check command line option"));
  XLINK_ERROR(flags & MOD_CLAMP && !(flags & MOD_PACK || flags & MOD_CHECK),
   ("Specified -C --clamp without -p --pack or -c --check command line option"));
  if (flags & MOD_CHECK) {
    xlink_list bytes;
    xlink_list models;
    /* Read bytes from stdin */
    xlink_list_init(&bytes, sizeof(unsigned char), 0);
    while (!XLINK_FEOF(stdin)) {
      xlink_list_add_byte(&bytes, getc(stdin));
    }
    xlink_list_init(&models, sizeof(xlink_model), 0);
    /* Search for the best context to use for bytes */
    xlink_model_search(&models, &bytes);
    if (xlink_list_length(&models) > 0) {
      xlink_context ctx;
      xlink_bitstream bs;
      int size;
      /* Segment header has 4 weight bytes + n model bytes */
      printf("Required header: 4 weight bytes + %i model byte(s)\n",
       xlink_list_length(&models));
      xlink_model_set_state(&models,
       xlink_model_compute_packed_weights(&models));
      /* Create a context from models */
      xlink_context_init(&ctx, &models, 0, flags & MOD_LOW, flags & MOD_CLAMP);
      /* Create a bitstream for writing */
      xlink_bitstream_init(&bs);
      /* Encode bytes with the context and perfect hashing */
      xlink_bitstream_from_context(&bs, &ctx, &bytes);
      size = 8 + xlink_list_length(&models) + (bs.bits + 7)/8;
      printf("Perfect hashing: %i bits, %i bytes\n", bs.bits, (bs.bits + 7)/8);
      printf("Compressed size: %i bytes -> %2.3lf%% smaller\n", size,
       XLINK_RATIO(size, xlink_list_length(&bytes)));
      /* Encode bytes with the context and replacement hashing */
      printf("Using hash table size = %i\n", bin.hash_table_memory/2);
      xlink_context_set_fixed_capacity(&ctx, bin.hash_table_memory/2);
      xlink_bitstream_from_context(&bs, &ctx, &bytes);
      size = 8 + xlink_list_length(&models) + (bs.bits + 7)/8;
      printf("Replace hashing: %i bits, %i bytes\n", bs.bits, (bs.bits + 7)/8);
      printf("Compressed size: %i bytes -> %2.3lf%% smaller\n", size,
       XLINK_RATIO(size, xlink_list_length(&bytes)));
      xlink_context_clear(&ctx);
      xlink_bitstream_clear(&bs);
    }
    /* Clean up */
    xlink_list_clear(&bytes);
    xlink_list_clear(&models);
    return EXIT_SUCCESS;
  }
  if (optind == argc) {
    fprintf(stderr, "No <modules> specified!\n\n");
    usage(argv[0]);
    return EXIT_FAILURE;
  }
  if (!(flags & MOD_DUMP) && bin.output == NULL) {
    fprintf(stderr, "Output -o <program> is required!\n\n");
    usage(argv[0]);
    return EXIT_FAILURE;
  }
  if ((flags & MOD_MAP) && !(flags & MOD_DUMP)) {
    int len;
    len = strlen(bin.output);
    strcpy(mapfile, bin.output);
    if (len > 4 && strncasecmp(mapfile + len - 4, ".com", 4) == 0) {
      sprintf(mapfile + len - 4, "%s", ".map");
    }
    else {
      sprintf(mapfile + len, "%s", ".map");
    }
    bin.map = mapfile;
  }
  for (c = optind; c < argc; c++) {
    xlink_file file;
    xlink_file_init(&file, argv[c]);
    switch (file.buf[0]) {
      case OMF_THEADR :
      case OMF_LHEADR : {
        xlink_module *mod;
        mod = xlink_file_load_omf_module(&file, flags);
        XLINK_LIST_ADD(binary, module, &bin, mod);
        break;
      }
      case OMF_LIBHDR : {
        xlink_library *lib;
        lib = xlink_file_load_omf_library(&file, flags);
        XLINK_LIST_ADD(binary, library, &bin, lib);
        break;
      }
      default : {
        XLINK_ERROR(1,
         ("Unsupported file format, unknown record type %02X", file.buf[0]));
      }
    }
    xlink_file_clear(&file);
  }
  if (!(flags & MOD_DUMP)) {
    xlink_binary_link(&bin, flags);
  }
  xlink_binary_clear(&bin);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2f10
movl $0x0, -0x84(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq 0xd88e(%rip), %rdx      # 0x17128
leaq 0xa31f(%rip), %rcx      # 0x13bc0
leaq -0x80(%rbp), %r8
callq 0x2090
movl %eax, -0x7c(%rbp)
cmpl $-0x1, %eax
je 0x9a10
movl -0x7c(%rbp), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x290(%rbp)
subl $0x42, %eax
ja 0x99f3
movq -0x290(%rbp), %rax
leaq 0x4b3c(%rip), %rcx      # 0xe418
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xa6ec(%rip), %rax      # 0x13fd8
movq (%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x9a0b
movq 0xa6d9(%rip), %rax      # 0x13fd8
movq (%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x9a0b
movq 0xa6c6(%rip), %rax      # 0x13fd8
movq (%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movq 0xa638(%rip), %rax      # 0x13fd8
movq (%rax), %rdi
callq 0x21a0
movl %eax, -0x60(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
movl -0x84(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x84(%rbp)
jmp 0x9a0b
jmp 0x99f3
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xa150
movl $0x1, -0x4(%rbp)
jmp 0xa141
jmp 0x988c
jmp 0x9a12
movl -0x84(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x9a48
movl -0x84(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x9a48
leaq 0x5c4f(%rip), %rdi      # 0xf686
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x9a4a
jmp 0x9a4c
movl -0x60(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x9a72
movl -0x60(%rbp), %esi
leaq 0x5c6d(%rip), %rdi      # 0xf6ce
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x9a74
jmp 0x9a76
movl -0x84(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x9aaa
movl -0x84(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x9aaa
leaq 0x5c60(%rip), %rdi      # 0xf6f9
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x9aac
jmp 0x9aae
movl -0x84(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x9af0
movl -0x84(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x9af0
movl -0x84(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x9af0
leaq 0x5c62(%rip), %rdi      # 0xf741
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x9af2
jmp 0x9af4
movl -0x84(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x9b38
movl -0x84(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x9b38
movl -0x84(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x9b38
leaq 0x5c61(%rip), %rdi      # 0xf788
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x9b3a
movl -0x84(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x9e88
leaq -0x1a8(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xc610
movq 0xa462(%rip), %rax      # 0x13fc8
movq (%rax), %rdi
callq 0x21f0
movl %eax, %edi
movq 0xa451(%rip), %rax      # 0x13fc8
movq (%rax), %rsi
callq 0x2140
cmpl $-0x1, %eax
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x9b8d
jmp 0x9bb9
jmp 0x9b8f
movq 0xa432(%rip), %rax      # 0x13fc8
movq (%rax), %rdi
callq 0x21f0
movb %al, -0x1c1(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1c1(%rbp), %rsi
callq 0xc950
jmp 0x9b5f
leaq -0x1c0(%rbp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0xc610
leaq -0x1c0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x7f70
leaq -0x1c0(%rbp), %rdi
callq 0xc6a0
cmpl $0x0, %eax
jle 0x9e64
leaq -0x1c0(%rbp), %rdi
callq 0xc6a0
movl %eax, %esi
leaq 0x5bc8(%rip), %rdi      # 0xf7d1
movb $0x0, %al
callq 0x20a0
leaq -0x1c0(%rbp), %rdi
callq 0xb0c0
movl %eax, %esi
leaq -0x1c0(%rbp), %rdi
callq 0xb190
movl -0x84(%rbp), %ecx
andl $0x40, %ecx
movl -0x84(%rbp), %r8d
andl $0x80, %r8d
leaq -0x238(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
xorl %edx, %edx
callq 0xb850
leaq -0x258(%rbp), %rdi
callq 0xa180
leaq -0x258(%rbp), %rdi
leaq -0x238(%rbp), %rsi
leaq -0x1a8(%rbp), %rdx
callq 0x8110
leaq -0x1c0(%rbp), %rdi
callq 0xc6a0
addl $0x8, %eax
movl %eax, -0x2b4(%rbp)
movl -0x240(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x2b4(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x25c(%rbp)
movl -0x240(%rbp), %esi
movl -0x240(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq 0x57fe(%rip), %rdi      # 0xf4d0
movb $0x0, %al
callq 0x20a0
movl -0x25c(%rbp), %eax
movl %eax, -0x2a8(%rbp)
cvtsi2sdl -0x25c(%rbp), %xmm0
movsd %xmm0, -0x2b0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0xc6a0
movsd -0x2b0(%rbp), %xmm0
movl -0x2a8(%rbp), %esi
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x4851(%rip), %xmm1     # 0xe570
subsd %xmm0, %xmm1
movsd 0x483d(%rip), %xmm0     # 0xe568
mulsd %xmm1, %xmm0
leaq 0x57be(%rip), %rdi      # 0xf4f4
movb $0x1, %al
callq 0x20a0
movl -0x60(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %esi
leaq 0x5ab4(%rip), %rdi      # 0xf805
movb $0x0, %al
callq 0x20a0
movl -0x60(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %esi
leaq -0x238(%rbp), %rdi
callq 0xb8f0
leaq -0x258(%rbp), %rdi
leaq -0x238(%rbp), %rsi
leaq -0x1a8(%rbp), %rdx
callq 0x8110
leaq -0x1c0(%rbp), %rdi
callq 0xc6a0
addl $0x8, %eax
movl %eax, -0x2a4(%rbp)
movl -0x240(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x2a4(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x25c(%rbp)
movl -0x240(%rbp), %esi
movl -0x240(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq 0x5a40(%rip), %rdi      # 0xf821
movb $0x0, %al
callq 0x20a0
movl -0x25c(%rbp), %eax
movl %eax, -0x294(%rbp)
cvtsi2sdl -0x25c(%rbp), %xmm0
movsd %xmm0, -0x2a0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0xc6a0
movsd -0x2a0(%rbp), %xmm0
movl -0x294(%rbp), %esi
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x4742(%rip), %xmm1     # 0xe570
subsd %xmm0, %xmm1
movsd 0x472e(%rip), %xmm0     # 0xe568
mulsd %xmm1, %xmm0
leaq 0x56af(%rip), %rdi      # 0xf4f4
movb $0x1, %al
callq 0x20a0
leaq -0x238(%rbp), %rdi
callq 0xb970
leaq -0x258(%rbp), %rdi
callq 0xa1c0
leaq -0x1a8(%rbp), %rdi
callq 0xc680
leaq -0x1c0(%rbp), %rdi
callq 0xc680
movl $0x0, -0x4(%rbp)
jmp 0xa141
movq 0xa141(%rip), %rax      # 0x13fd0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x9ec6
movq 0xa15b(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x599e(%rip), %rsi      # 0xf845
movb $0x0, %al
callq 0x20e0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xa150
movl $0x1, -0x4(%rbp)
jmp 0xa141
movl -0x84(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x9f0b
cmpq $0x0, -0x78(%rbp)
jne 0x9f0b
movq 0xa116(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x5973(%rip), %rsi      # 0xf85f
movb $0x0, %al
callq 0x20e0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xa150
movl $0x1, -0x4(%rbp)
jmp 0xa141
movl -0x84(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x9fdf
movl -0x84(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x9fdf
movq -0x78(%rbp), %rdi
callq 0x2080
movl %eax, -0x260(%rbp)
leaq -0x190(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x2040
cmpl $0x4, -0x260(%rbp)
jle 0x9fae
leaq -0x190(%rbp), %rdi
movslq -0x260(%rbp), %rax
addq %rax, %rdi
addq $-0x4, %rdi
leaq 0x590f(%rip), %rsi      # 0xf882
movl $0x4, %edx
callq 0x2120
cmpl $0x0, %eax
jne 0x9fae
leaq -0x190(%rbp), %rdi
movslq -0x260(%rbp), %rax
addq %rax, %rdi
addq $-0x4, %rdi
leaq 0x4ad4(%rip), %rsi      # 0xea72
leaq 0x58e2(%rip), %rdx      # 0xf887
movb $0x0, %al
callq 0x21b0
jmp 0x9fd4
leaq -0x190(%rbp), %rdi
movslq -0x260(%rbp), %rax
addq %rax, %rdi
leaq 0x4aac(%rip), %rsi      # 0xea72
leaq 0x58ba(%rip), %rdx      # 0xf887
movb $0x0, %al
callq 0x21b0
leaq -0x190(%rbp), %rax
movq %rax, -0x58(%rbp)
movq 0x9fea(%rip), %rax      # 0x13fd0
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0xa11b
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x278(%rbp), %rdi
callq 0xaf20
movq -0x268(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x2b8(%rbp)
subl $0x80, %eax
je 0xa049
jmp 0xa028
movl -0x2b8(%rbp), %eax
subl $0x82, %eax
je 0xa049
jmp 0xa037
movl -0x2b8(%rbp), %eax
subl $0xf0, %eax
je 0xa093
jmp 0xa0dd
movl -0x84(%rbp), %esi
leaq -0x278(%rbp), %rdi
callq 0x6290
movq %rax, -0x280(%rbp)
movl -0x48(%rbp), %ecx
addl $0x1, %ecx
movq -0x280(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x280(%rbp), %rax
leaq -0x78(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x280(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x3fb0
jmp 0xa101
movl -0x84(%rbp), %esi
leaq -0x278(%rbp), %rdi
callq 0x7800
movq %rax, -0x288(%rbp)
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movq -0x288(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x288(%rbp), %rax
leaq -0x78(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x288(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x40e0
jmp 0xa101
jmp 0xa0df
movq -0x268(%rbp), %rax
movzbl (%rax), %esi
leaq 0x579c(%rip), %rdi      # 0xf88c
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
leaq -0x278(%rbp), %rdi
callq 0xb030
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x9feb
movl -0x84(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0xa138
movl -0x84(%rbp), %esi
leaq -0x78(%rbp), %rdi
callq 0x8a50
leaq -0x78(%rbp), %rdi
callq 0x2f50
movl -0x4(%rbp), %eax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
nopl (%rax)