#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ abort();
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int getopt_long(int, char **, char *, struct option *, int *);
scalar_t__ isalpha(char);
scalar_t__ isupper(char);
#define no_argument 128
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int *relSearch(char *, char *, int, int);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int strlen(char *);
int strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  char *helpString =
      "Usage: ariko [-b <NB>] [-e <END>] [-x <ID>] <FILEPATH> "
      "<SEARCHSTRING>\nExecute a relative search to find character "
      "encoding.\n\n  -b      bits per character (8 or 16)\n  -e      "
      "endianness: \"little\" OR \"big\"\n  -x      id of result to export to "
      "character map\n  --help  display this message\n";
  int *result = NULL;
  int bits = 8;
  int expId = -1;
  bool bigEndian = true;
  static struct option longOptions[] = {
      {"help", no_argument, 0, 'h'},
  };
  int opt;
  int optindex = 0;
  while ((opt = getopt_long(argc, argv, "b:e:x:", longOptions, &optindex)) !=
         -1) {
    switch (opt) {
    case 'b':
      bits = strtol(optarg, NULL, 10);
      if (bits != 8 && bits != 16) {
        printf("Error: -b option takes only 8 or 16.\n");
        return 1;
      }
      break;
    case 'e':
      if (argc == 4 || strcmp(optarg, "big") == 0) {
        bigEndian = false;
      } else {
        bigEndian = true;
      }
      break;
    case 'h':
      printf("%s", helpString);
      return 0;
    case 'x':
      expId = strtol(optarg, NULL, 10);
      break;
    case '?':
      return 1;
    default:
      abort();
    }
  }
  if (argc - optindex != 3) {
    printf("Error: wrong arguments count. See --help.\n");
    return 1;
  }
  if (access(argv[optindex + 1], F_OK) == -1) {
    printf("Can't read specified file.\n");
    return 1;
  }
  int uppers = 0;
  int lowers = 0;
  for (int x = 0; x < strlen(argv[optindex + 2]); x++) {
    if (isalpha(argv[optindex + 2][x])) {
      if (isupper(argv[optindex + 2][x])) {
        uppers++;
      } else {
        lowers++;
      }
    }
  }
  if (lowers < 2 && uppers < 2) {
    printf("Error: string to search is badly formed.\n");
    return 1;
  }
  result = relSearch(argv[optindex + 1], argv[optindex + 2], bits, bigEndian);
  if (result[0] == 0) {
    printf("No results found.\n");
    free(result);
    return 1;
  }
  if (expId != -1) {
    if (expId > result[0] - 1) {
      printf("Error: can't export character map, id %d not found.\n", expId);
      printf("-> %d result(s) found. ", result[0]);
      free(result);
      return 1;
    }
    char temp[] = "x";
    if (result[expId + 2] != -1) {
      for (int i = 0; i < 26; i++) {
        temp[0] = 65 + i;
        printf("%x=%s\n", result[expId + 2] + i, temp);
      }
    }
    if (result[expId + 3] != -1) {
      for (int i = 0; i < 26; i++) {
        temp[0] = 97 + i;
        printf("%x=%s\n", result[expId + 3] + i, temp);
      }
    }
    free(result);
    return 0;
  }
  printf("[");
  for (int x = 0; x < result[0] * 3; x += 3) {
    printf("{'id':%d,'address':'0x%x', ", x / 3, result[x + 1]);
    if (result[x + 2] >= 0) {
      printf("'A':'0x%x'", result[x + 2]);
      if (result[x + 3] >= 0) {
        printf(", 'a':'0x%x'", result[x + 3]);
      }
    } else if (result[x + 3] >= 0) {
      printf("'a':'0x%x'", result[x + 3]);
    }
    printf("}");
    if (x != (result[0] - 1) * 3) {
      printf(",\n");
    }
  }
  printf("]\n");
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe33(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x8,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf20(%rip),%rdx
lea    0x2e76(%rip),%rcx
lea    -0x34(%rbp),%r8
call   1060 <getopt_long@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
je     1359 <main+0x1a9>
mov    -0x30(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x3f,%eax
je     1341 <main+0x191>
jmp    1233 <main+0x83>
mov    -0x54(%rbp),%eax
sub    $0x62,%eax
je     1277 <main+0xc7>
jmp    1244 <main+0x94>
mov    -0x54(%rbp),%eax
sub    $0x65,%eax
je     12c4 <main+0x114>
jmp    1255 <main+0xa5>
mov    -0x54(%rbp),%eax
sub    $0x68,%eax
je     1304 <main+0x154>
jmp    1266 <main+0xb6>
mov    -0x54(%rbp),%eax
sub    $0x78,%eax
je     1322 <main+0x172>
jmp    134d <main+0x19d>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
je     12bf <main+0x10f>
cmpl   $0x10,-0x24(%rbp)
je     12bf <main+0x10f>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
jmp    1354 <main+0x1a4>
cmpl   $0x4,-0x8(%rbp)
je     12ec <main+0x13c>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12f8 <main+0x148>
movl   $0x0,-0x2c(%rbp)
jmp    12ff <main+0x14f>
movl   $0x1,-0x2c(%rbp)
jmp    1354 <main+0x1a4>
mov    -0x18(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17b9 <main+0x609>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %eax,-0x28(%rbp)
jmp    1354 <main+0x1a4>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    11f5 <main+0x45>
mov    -0x8(%rbp),%eax
sub    -0x34(%rbp),%eax
cmp    $0x3,%eax
je     1382 <main+0x1d2>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
call   10d0 <access@plt>
cmp    $0xffffffff,%eax
jne    13c4 <main+0x214>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jge    1481 <main+0x2d1>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
je     146e <main+0x2be>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10b0 <isupper@plt>
cmp    $0x0,%rax
je     1460 <main+0x2b0>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1469 <main+0x2b9>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    146e <main+0x2be>
jmp    1473 <main+0x2c3>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    13d9 <main+0x229>
cmpl   $0x2,-0x3c(%rbp)
jge    14af <main+0x2ff>
cmpl   $0x2,-0x38(%rbp)
jge    14af <main+0x2ff>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x24(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   10c0 <relSearch@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1510 <main+0x360>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
cmpl   $0xffffffff,-0x28(%rbp)
je     165a <main+0x4aa>
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    1568 <main+0x3b8>
mov    -0x28(%rbp),%esi
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    17b9 <main+0x609>
mov    0xcb9(%rip),%ax
mov    %ax,-0x42(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     15dc <main+0x42c>
movl   $0x0,-0x48(%rbp)
cmpl   $0x1a,-0x48(%rbp)
jge    15d7 <main+0x427>
mov    -0x48(%rbp),%eax
add    $0x41,%eax
mov    %al,-0x42(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
add    -0x48(%rbp),%esi
lea    -0x42(%rbp),%rdx
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1591 <main+0x3e1>
jmp    15dc <main+0x42c>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     1645 <main+0x495>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x1a,-0x4c(%rbp)
jge    1640 <main+0x490>
mov    -0x4c(%rbp),%eax
add    $0x61,%eax
mov    %al,-0x42(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
add    -0x4c(%rbp),%esi
lea    -0x42(%rbp),%rdx
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    15fa <main+0x44a>
jmp    1645 <main+0x495>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    17b9 <main+0x609>
lea    0xbd0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x20(%rbp),%rcx
imul   $0x3,(%rcx),%ecx
cmp    %ecx,%eax
jge    179b <main+0x5eb>
mov    -0x50(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xb8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     171b <main+0x56b>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xb75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     1716 <main+0x566>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xb4b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1755 <main+0x5a5>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     1750 <main+0x5a0>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xb13(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1755 <main+0x5a5>
lea    0xb0b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x50(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
imul   $0x3,%ecx,%ecx
cmp    %ecx,%eax
je     1788 <main+0x5d8>
lea    0xae8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    178d <main+0x5dd>
mov    -0x50(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x50(%rbp)
jmp    166f <main+0x4bf>
lea    0xaca(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
mov    %edi,%ebx
movl   $0x0,0xc(%rsp)
mov    $0x1,%ebp
movl   $0xffffffff,0x10(%rsp)
ff
mov    $0x8,%eax
lea    0xe01(%rip),%r13
lea    0x2e85(%rip),%r14
lea    0xc(%rsp),%r15
mov    %eax,0x14(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1080 <getopt_long@plt>
cmp    $0x65,%eax
jne    125e <main+0x8e>
xor    %ebp,%ebp
cmp    $0x4,%ebx
je     1220 <main+0x50>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
call   10a0 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
jmp    1220 <main+0x50>
cmp    $0x61,%eax
jle    12d2 <main+0x102>
cmp    $0x78,%eax
jne    1290 <main+0xc0>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    %eax,0x10(%rsp)
jmp    1220 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x68,%eax
je     12e7 <main+0x117>
cmp    $0x62,%eax
jne    12e0 <main+0x110>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
cmp    $0x8,%eax
je     1210 <main+0x40>
cmp    $0x10,%eax
je     1210 <main+0x40>
lea    0xf71(%rip),%rdi
call   1060 <puts@plt>
jmp    1602 <main+0x432>
cmp    $0xffffffff,%eax
je     12fa <main+0x12a>
cmp    $0x3f,%eax
je     1602 <main+0x432>
xor    %eax,%eax
call   1050 <abort@plt>
lea    0xe2e(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
jmp    1607 <main+0x437>
movslq 0xc(%rsp),%rax
sub    %eax,%ebx
cmp    $0x3,%ebx
jne    13a4 <main+0x1d4>
mov    0x8(%r12,%rax,8),%rdi
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
call   10f0 <access@plt>
cmp    $0xffffffff,%eax
je     13b5 <main+0x1e5>
movslq 0xc(%rsp),%rax
mov    0x10(%r12,%rax,8),%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    13c6 <main+0x1f6>
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    136e <main+0x19e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14d
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
mov    0x10(%r12,%rax,8),%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    13cc <main+0x1fc>
movslq 0xc(%rsp),%rax
mov    0x10(%r12,%rax,8),%rax
movsbl (%rax,%rbx,1),%edi
call   10c0 <isalpha@plt>
test   %rax,%rax
je     1354 <main+0x184>
movslq 0xc(%rsp),%rax
mov    0x10(%r12,%rax,8),%rax
movsbl (%rax,%rbx,1),%edi
call   10d0 <isupper@plt>
test   %rax,%rax
je     1350 <main+0x180>
add    $0x1,%r15d
jmp    1354 <main+0x184>
lea    0xd47(%rip),%rdi
call   1060 <puts@plt>
jmp    1602 <main+0x432>
lea    0xd1b(%rip),%rdi
call   1060 <puts@plt>
jmp    1602 <main+0x432>
xor    %r15d,%r15d
xor    %r14d,%r14d
cmp    $0x1,%r14d
jg     13e9 <main+0x219>
cmp    $0x2,%r15d
jge    13e9 <main+0x219>
lea    0xccf(%rip),%rdi
call   1060 <puts@plt>
jmp    1602 <main+0x432>
movslq 0xc(%rsp),%rax
mov    0x8(%r12,%rax,8),%rdi
mov    0x10(%r12,%rax,8),%rsi
mov    0x14(%rsp),%edx
mov    %ebp,%ecx
call   10e0 <relSearch@plt>
mov    %rax,%rbx
mov    (%rax),%eax
test   %eax,%eax
je     14f7 <main+0x327>
mov    0x10(%rsp),%esi
cmp    $0xffffffff,%esi
je     1508 <main+0x338>
cmp    %eax,%esi
jge    15dc <main+0x40c>
movw   $0x78,0xa(%rsp)
movslq %esi,%r12
mov    0x8(%rbx,%r12,4),%esi
cmp    $0xffffffff,%esi
je     1492 <main+0x2c2>
lea    0x2(%r12),%r13
movb   $0x41,0xa(%rsp)
lea    0xc13(%rip),%r14
lea    0xa(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x41(%rbp),%eax
mov    (%rbx,%r13,4),%esi
add    %ebp,%esi
mov    %al,0xa(%rsp)
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x1,%ebp
cmp    $0x1a,%ebp
jne    1470 <main+0x2a0>
mov    0xc(%rbx,%r12,4),%esi
cmp    $0xffffffff,%esi
je     15d0 <main+0x400>
add    $0x3,%r12
movb   $0x61,0xa(%rsp)
lea    0xbad(%rip),%r14
lea    0xa(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
lea    0x61(%rbp),%eax
mov    (%rbx,%r12,4),%esi
add    %ebp,%esi
mov    %al,0xa(%rsp)
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x1,%ebp
cmp    $0x1a,%ebp
jne    14d0 <main+0x300>
jmp    15d0 <main+0x400>
lea    0xb9e(%rip),%rdi
call   1060 <puts@plt>
jmp    15fa <main+0x42a>
mov    $0x5b,%edi
call   1040 <putchar@plt>
cmpl   $0x0,(%rbx)
jle    15c4 <main+0x3f4>
lea    0xb42(%rip),%rbp
lea    0xb57(%rip),%r14
lea    0xb6a(%rip),%r12
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    1550 <main+0x380>
nopl   0x0(%rax,%rax,1)
lea    (%rax,%rax,2),%eax
add    $0x3,%r15
add    $0x1,%r13d
cmp    %r15d,%eax
jle    15c4 <main+0x3f4>
mov    0x4(%rbx,%r15,4),%edx
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%rbx,%r15,4),%esi
test   %esi,%esi
js     1587 <main+0x3b7>
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0xc(%rbx,%r15,4),%esi
test   %esi,%esi
js     159e <main+0x3ce>
lea    0xb06(%rip),%rdi
jmp    1597 <main+0x3c7>
mov    0xc(%rbx,%r15,4),%esi
test   %esi,%esi
js     159e <main+0x3ce>
lea    0xaf6(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x7d,%edi
call   1040 <putchar@plt>
mov    (%rbx),%eax
lea    (%rax,%rax,2),%ecx
add    $0xfffffffd,%ecx
cmp    %rcx,%r15
je     1540 <main+0x370>
mov    %r12,%rdi
call   1060 <puts@plt>
mov    (%rbx),%eax
jmp    1540 <main+0x370>
lea    0xacd(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1607 <main+0x437>
lea    0xa2d(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%rbx),%esi
lea    0xa52(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [286 x i8] c"Usage: ariko [-b <NB>] [-e <END>] [-x <ID>] <FILEPATH> <SEARCHSTRING>\0AExecute a relative search to find character encoding.\0A\0A -b bits per character (8 or 16)\0A -e endianness: \22little\22 OR \22big\22\0A -x id of result to export to character map\0A --help display this message\0A\00"
@main.longOptions = internal global [1 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 104 }]
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [7 x i8] c"b:e:x:\00"
@optarg = global i32 0
@.str.3 = [38 x i8] c"Error: -b option takes only 8 or 16.\0A\00"
@.str.4 = [4 x i8] c"big\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [43 x i8] c"Error: wrong arguments count. See --help.\0A\00"
@F_OK = global i32 0
@.str.7 = [28 x i8] c"Can't read specified file.\0A\00"
@.str.8 = [42 x i8] c"Error: string to search is badly formed.\0A\00"
@.str.9 = [19 x i8] c"No results found.\0A\00"
@.str.10 = [53 x i8] c"Error: can't export character map, id %d not found.\0A\00"
@.str.11 = [24 x i8] c"-> %d result(s) found. \00"
@__const.main.temp = [2 x i8] c"x\00"
@.str.12 = [7 x i8] c"%x=%s\0A\00"
@.str.13 = [2 x i8] c"[\00"
@.str.14 = [28 x i8] c"{'id':%d,'address':'0x%x', \00"
@.str.15 = [11 x i8] c"'A':'0x%x'\00"
@.str.16 = [13 x i8] c", 'a':'0x%x'\00"
@.str.17 = [11 x i8] c"'a':'0x%x'\00"
@.str.18 = [2 x i8] c"}\00"
@.str.19 = [3 x i8] c",\0A\00"
@.str.20 = [3 x i8] c"]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [2 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([286 x i8], [286 x i8]* @.str, i64 0, i64 0), i8** %6
store i32* null, i32** %7
store i32 8, i32* %8
store i32 -1, i32* %9
store i32 1, i32* %10
store i32 0, i32* %12
br label %20
20: ; preds = %57, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt_long(i32 %21, i8** %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([1 x %struct.option], [1 x %struct.option]* @main.longOptions, i64 0, i64 0), i32* %12)
store i32 %23, i32* %11
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %58
25: ; preds = %20
%26 = load i32, i32* %11
switch i32 %26, label %55 [
i32 98, label %27
i32 101, label %38
i32 104, label %48
i32 120, label %51
i32 63, label %54
]
27: ; preds = %25
%28 = load i32, i32* @optarg
%29 = call i32 @strtol(i32 %28, i32* null, i32 10)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 8
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i32, i32* %8
%34 = icmp ne i32 %33, 16
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %328
37: ; preds = %32, %27
br label %57
38: ; preds = %25
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 4
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = load i32, i32* @optarg
%43 = call i32 @strcmp(i32 %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41, %38
store i32 0, i32* %10
br label %47
46: ; preds = %41
store i32 1, i32* %10
br label %47
47: ; preds = %46, %45
br label %57
48: ; preds = %25
%49 = load i8*, i8** %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %49)
store i32 0, i32* %3
br label %328
51: ; preds = %25
%52 = load i32, i32* @optarg
%53 = call i32 @strtol(i32 %52, i32* null, i32 10)
store i32 %53, i32* %9
br label %57
54: ; preds = %25
store i32 1, i32* %3
br label %328
55: ; preds = %25
%56 = call i32 (...) @abort()
unreachable
57: ; preds = %51, %47, %37
br label %20
58: ; preds = %20
%59 = load i32, i32* %4
%60 = load i32, i32* %12
%61 = sub nsw i32 %59, %60
%62 = icmp ne i32 %61, 3
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %328
65: ; preds = %58
%66 = load i8**, i8*** %5
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %66, i64 %69
%71 = load i8*, i8** %70
%72 = load i32, i32* @F_OK
%73 = call i32 @access(i8* %71, i32 %72)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %77
75: ; preds = %65
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %328
77: ; preds = %65
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
br label %78
78: ; preds = %122, %77
%79 = load i32, i32* %15
%80 = load i8**, i8*** %5
%81 = load i32, i32* %12
%82 = add nsw i32 %81, 2
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %80, i64 %83
%85 = load i8*, i8** %84
%86 = call i32 @strlen(i8* %85)
%87 = icmp slt i32 %79, %86
br i1 %87, label %88, label %125
88: ; preds = %78
%89 = load i8**, i8*** %5
%90 = load i32, i32* %12
%91 = add nsw i32 %90, 2
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8*, i8** %89, i64 %92
%94 = load i8*, i8** %93
%95 = load i32, i32* %15
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
%99 = call i64 @isalpha(i8 signext %98)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %121
101: ; preds = %88
%102 = load i8**, i8*** %5
%103 = load i32, i32* %12
%104 = add nsw i32 %103, 2
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %102, i64 %105
%107 = load i8*, i8** %106
%108 = load i32, i32* %15
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %107, i64 %109
%111 = load i8, i8* %110
%112 = call i64 @isupper(i8 signext %111)
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %101
%115 = load i32, i32* %13
%116 = add nsw i32 %115, 1
store i32 %116, i32* %13
br label %120
117: ; preds = %101
%118 = load i32, i32* %14
%119 = add nsw i32 %118, 1
store i32 %119, i32* %14
br label %120
120: ; preds = %117, %114
br label %121
121: ; preds = %120, %88
br label %122
122: ; preds = %121
%123 = load i32, i32* %15
%124 = add nsw i32 %123, 1
store i32 %124, i32* %15
br label %78
125: ; preds = %78
%126 = load i32, i32* %14
%127 = icmp slt i32 %126, 2
br i1 %127, label %128, label %133
128: ; preds = %125
%129 = load i32, i32* %13
%130 = icmp slt i32 %129, 2
br i1 %130, label %131, label %133
131: ; preds = %128
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %328
133: ; preds = %128, %125
%134 = load i8**, i8*** %5
%135 = load i32, i32* %12
%136 = add nsw i32 %135, 1
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8*, i8** %134, i64 %137
%139 = load i8*, i8** %138
%140 = load i8**, i8*** %5
%141 = load i32, i32* %12
%142 = add nsw i32 %141, 2
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds i8*, i8** %140, i64 %143
%145 = load i8*, i8** %144
%146 = load i32, i32* %8
%147 = load i32, i32* %10
%148 = call i32* @relSearch(i8* %139, i8* %145, i32 %146, i32 %147)
store i32* %148, i32** %7
%149 = load i32*, i32** %7
%150 = getelementptr inbounds i32, i32* %149, i64 0
%151 = load i32, i32* %150
%152 = icmp eq i32 %151, 0
br i1 %152, label %153, label %157
153: ; preds = %133
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%155 = load i32*, i32** %7
%156 = call i32 @free(i32* %155)
store i32 1, i32* %3
br label %328
157: ; preds = %133
%158 = load i32, i32* %9
%159 = icmp ne i32 %158, -1
br i1 %159, label %160, label %242
160: ; preds = %157
%161 = load i32, i32* %9
%162 = load i32*, i32** %7
%163 = getelementptr inbounds i32, i32* %162, i64 0
%164 = load i32, i32* %163
%165 = sub nsw i32 %164, 1
%166 = icmp sgt i32 %161, %165
br i1 %166, label %167, label %176
167: ; preds = %160
%168 = load i32, i32* %9
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0), i32 %168)
%170 = load i32*, i32** %7
%171 = getelementptr inbounds i32, i32* %170, i64 0
%172 = load i32, i32* %171
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %172)
%174 = load i32*, i32** %7
%175 = call i32 @free(i32* %174)
store i32 1, i32* %3
br label %328
176: ; preds = %160
%177 = bitcast [2 x i8]* %16 to i8*
%178 = load i32*, i32** %7
%179 = load i32, i32* %9
%180 = add nsw i32 %179, 2
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds i32, i32* %178, i64 %181
%183 = load i32, i32* %182
%184 = icmp ne i32 %183, -1
br i1 %184, label %185, label %208
185: ; preds = %176
store i32 0, i32* %17
br label %186
186: ; preds = %204, %185
%187 = load i32, i32* %17
%188 = icmp slt i32 %187, 26
br i1 %188, label %189, label %207
189: ; preds = %186
%190 = load i32, i32* %17
%191 = add nsw i32 65, %190
%192 = trunc i32 %191 to i8
%193 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
store i8 %192, i8* %193
%194 = load i32*, i32** %7
%195 = load i32, i32* %9
%196 = add nsw i32 %195, 2
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds i32, i32* %194, i64 %197
%199 = load i32, i32* %198
%200 = load i32, i32* %17
%201 = add nsw i32 %199, %200
%202 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %201, i8* %202)
br label %204
204: ; preds = %189
%205 = load i32, i32* %17
%206 = add nsw i32 %205, 1
store i32 %206, i32* %17
br label %186
207: ; preds = %186
br label %208
208: ; preds = %207, %176
%209 = load i32*, i32** %7
%210 = load i32, i32* %9
%211 = add nsw i32 %210, 3
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds i32, i32* %209, i64 %212
%214 = load i32, i32* %213
%215 = icmp ne i32 %214, -1
br i1 %215, label %216, label %239
216: ; preds = %208
store i32 0, i32* %18
br label %217
217: ; preds = %235, %216
%218 = load i32, i32* %18
%219 = icmp slt i32 %218, 26
br i1 %219, label %220, label %238
220: ; preds = %217
%221 = load i32, i32* %18
%222 = add nsw i32 97, %221
%223 = trunc i32 %222 to i8
%224 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
store i8 %223, i8* %224
%225 = load i32*, i32** %7
%226 = load i32, i32* %9
%227 = add nsw i32 %226, 3
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds i32, i32* %225, i64 %228
%230 = load i32, i32* %229
%231 = load i32, i32* %18
%232 = add nsw i32 %230, %231
%233 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
%234 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %232, i8* %233)
br label %235
235: ; preds = %220
%236 = load i32, i32* %18
%237 = add nsw i32 %236, 1
store i32 %237, i32* %18
br label %217
238: ; preds = %217
br label %239
239: ; preds = %238, %208
%240 = load i32*, i32** %7
%241 = call i32 @free(i32* %240)
store i32 0, i32* %3
br label %328
242: ; preds = %157
%243 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %19
br label %244
244: ; preds = %321, %242
%245 = load i32, i32* %19
%246 = load i32*, i32** %7
%247 = getelementptr inbounds i32, i32* %246, i64 0
%248 = load i32, i32* %247
%249 = mul nsw i32 %248, 3
%250 = icmp slt i32 %245, %249
br i1 %250, label %251, label %324
251: ; preds = %244
%252 = load i32, i32* %19
%253 = sdiv i32 %252, 3
%254 = load i32*, i32** %7
%255 = load i32, i32* %19
%256 = add nsw i32 %255, 1
%257 = sext i32 %256 to i64
%258 = getelementptr inbounds i32, i32* %254, i64 %257
%259 = load i32, i32* %258
%260 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i32 %253, i32 %259)
%261 = load i32*, i32** %7
%262 = load i32, i32* %19
%263 = add nsw i32 %262, 2
%264 = sext i32 %263 to i64
%265 = getelementptr inbounds i32, i32* %261, i64 %264
%266 = load i32, i32* %265
%267 = icmp sge i32 %266, 0
br i1 %267, label %268, label %292
268: ; preds = %251
%269 = load i32*, i32** %7
%270 = load i32, i32* %19
%271 = add nsw i32 %270, 2
%272 = sext i32 %271 to i64
%273 = getelementptr inbounds i32, i32* %269, i64 %272
%274 = load i32, i32* %273
%275 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i32 %274)
%276 = load i32*, i32** %7
%277 = load i32, i32* %19
%278 = add nsw i32 %277, 3
%279 = sext i32 %278 to i64
%280 = getelementptr inbounds i32, i32* %276, i64 %279
%281 = load i32, i32* %280
%282 = icmp sge i32 %281, 0
br i1 %282, label %283, label %291
283: ; preds = %268
%284 = load i32*, i32** %7
%285 = load i32, i32* %19
%286 = add nsw i32 %285, 3
%287 = sext i32 %286 to i64
%288 = getelementptr inbounds i32, i32* %284, i64 %287
%289 = load i32, i32* %288
%290 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 %289)
br label %291
291: ; preds = %283, %268
br label %309
292: ; preds = %251
%293 = load i32*, i32** %7
%294 = load i32, i32* %19
%295 = add nsw i32 %294, 3
%296 = sext i32 %295 to i64
%297 = getelementptr inbounds i32, i32* %293, i64 %296
%298 = load i32, i32* %297
%299 = icmp sge i32 %298, 0
br i1 %299, label %300, label %308
300: ; preds = %292
%301 = load i32*, i32** %7
%302 = load i32, i32* %19
%303 = add nsw i32 %302, 3
%304 = sext i32 %303 to i64
%305 = getelementptr inbounds i32, i32* %301, i64 %304
%306 = load i32, i32* %305
%307 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), i32 %306)
br label %308
308: ; preds = %300, %292
br label %309
309: ; preds = %308, %291
%310 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%311 = load i32, i32* %19
%312 = load i32*, i32** %7
%313 = getelementptr inbounds i32, i32* %312, i64 0
%314 = load i32, i32* %313
%315 = sub nsw i32 %314, 1
%316 = mul nsw i32 %315, 3
%317 = icmp ne i32 %311, %316
br i1 %317, label %318, label %320
318: ; preds = %309
%319 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0))
br label %320
320: ; preds = %318, %309
br label %321
321: ; preds = %320
%322 = load i32, i32* %19
%323 = add nsw i32 %322, 3
store i32 %323, i32* %19
br label %244
324: ; preds = %244
%325 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%326 = load i32*, i32** %7
%327 = call i32 @free(i32* %326)
store i32 0, i32* %3
br label %328
328: ; preds = %324, %239, %167, %153, %131, %75, %63, %54, %48, %35
%329 = load i32, i32* %3
ret i32 %329
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@main.longOptions = internal global [1 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 104 }]
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [7 x i8] c"b:e:x:\00"
@optarg = global i32 0
@.str.4 = [4 x i8] c"big\00"
@F_OK = global i32 0
@.str.10 = [53 x i8] c"Error: can't export character map, id %d not found.\0A\00"
@.str.11 = [24 x i8] c"-> %d result(s) found. \00"
@.str.12 = [7 x i8] c"%x=%s\0A\00"
@.str.14 = [28 x i8] c"{'id':%d,'address':'0x%x', \00"
@.str.15 = [11 x i8] c"'A':'0x%x'\00"
@.str.16 = [13 x i8] c", 'a':'0x%x'\00"
@.str.17 = [11 x i8] c"'a':'0x%x'\00"
@str = [2 x i8] c"]\00"
@str.21 = [2 x i8] c",\00"
@str.22 = [18 x i8] c"No results found.\00"
@str.23 = [41 x i8] c"Error: string to search is badly formed.\00"
@str.24 = [27 x i8] c"Can't read specified file.\00"
@str.25 = [42 x i8] c"Error: wrong arguments count. See --help.\00"
@str.26 = [285 x i8] c"Usage: ariko [-b <NB>] [-e <END>] [-x <ID>] <FILEPATH> <SEARCHSTRING>\0AExecute a relative search to find character encoding.\0A\0A -b bits per character (8 or 16)\0A -e endianness: \22little\22 OR \22big\22\0A -x id of result to export to character map\0A --help display this message\00"
@str.27 = [37 x i8] c"Error: -b option takes only 8 or 16.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i16
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = icmp eq i32 %0, 4
br label %7
7: ; preds = %20, %2
%8 = phi i32 [ 8, %2 ], [ %19, %20 ]
%9 = phi i32 [ -1, %2 ], [ %12, %20 ]
%10 = phi i32 [ 1, %2 ], [ %15, %20 ]
br label %11
11: ; preds = %7, %33
%12 = phi i32 [ %9, %7 ], [ %35, %33 ]
%13 = phi i32 [ %10, %7 ], [ %15, %33 ]
br label %14
14: ; preds = %29, %11
%15 = phi i32 [ %13, %11 ], [ %30, %29 ]
%16 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([1 x %struct.option], [1 x %struct.option]* @main.longOptions, i64 0, i64 0), i32* %3)
switch i32 %16, label %36 [
i32 -1, label %38
i32 98, label %17
i32 101, label %23
i32 104, label %31
i32 120, label %33
i32 63, label %221
]
17: ; preds = %14
%18 = load i32, i32* @optarg
%19 = call i32 @strtol(i32 %18, i32* null, i32 10)
switch i32 %19, label %21 [
i32 16, label %20
i32 8, label %20
]
20: ; preds = %17, %17
br label %7
21: ; preds = %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.27, i64 0, i64 0))
br label %221
23: ; preds = %14
br i1 %6, label %29, label %24
24: ; preds = %23
%25 = load i32, i32* @optarg
%26 = call i32 @strcmp(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %24, %23
%30 = phi i32 [ 0, %23 ], [ %28, %24 ]
br label %14
31: ; preds = %14
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([285 x i8], [285 x i8]* @str.26, i64 0, i64 0))
br label %221
33: ; preds = %14
%34 = load i32, i32* @optarg
%35 = call i32 @strtol(i32 %34, i32* null, i32 10)
br label %11
36: ; preds = %14
%37 = call i32 (...) @abort()
unreachable
38: ; preds = %14
%39 = load i32, i32* %3
%40 = sub nsw i32 %0, %39
%41 = icmp eq i32 %40, 3
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.25, i64 0, i64 0))
br label %221
44: ; preds = %38
%45 = add nsw i32 %39, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %1, i64 %46
%48 = load i8*, i8** %47
%49 = load i32, i32* @F_OK
%50 = call i32 @access(i8* %48, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %60, label %52
52: ; preds = %44
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %1, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 @strlen(i8* %57)
%59 = icmp sgt i32 %58, 0
br i1 %59, label %68, label %62
60: ; preds = %44
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.24, i64 0, i64 0))
br label %221
62: ; preds = %95, %52
%63 = phi i32 [ 0, %52 ], [ %96, %95 ]
%64 = phi i32 [ 0, %52 ], [ %97, %95 ]
%65 = icmp slt i32 %64, 2
%66 = icmp slt i32 %63, 2
%67 = select i1 %65, i1 %66, i1 false
br i1 %67, label %107, label %109
68: ; preds = %52, %95
%69 = phi i64 [ %98, %95 ], [ 0, %52 ]
%70 = phi i32 [ %97, %95 ], [ 0, %52 ]
%71 = phi i32 [ %96, %95 ], [ 0, %52 ]
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 2
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %1, i64 %74
%76 = load i8*, i8** %75
%77 = getelementptr inbounds i8, i8* %76, i64 %69
%78 = load i8, i8* %77
%79 = call i64 @isalpha(i8 signext %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %95, label %81
81: ; preds = %68
%82 = load i32, i32* %3
%83 = add nsw i32 %82, 2
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %1, i64 %84
%86 = load i8*, i8** %85
%87 = getelementptr inbounds i8, i8* %86, i64 %69
%88 = load i8, i8* %87
%89 = call i64 @isupper(i8 signext %88)
%90 = icmp eq i64 %89, 0
br i1 %90, label %93, label %91
91: ; preds = %81
%92 = add nsw i32 %71, 1
br label %95
93: ; preds = %81
%94 = add nsw i32 %70, 1
br label %95
95: ; preds = %68, %93, %91
%96 = phi i32 [ %92, %91 ], [ %71, %93 ], [ %71, %68 ]
%97 = phi i32 [ %70, %91 ], [ %94, %93 ], [ %70, %68 ]
%98 = add nuw nsw i64 %69, 1
%99 = load i32, i32* %3
%100 = add nsw i32 %99, 2
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %1, i64 %101
%103 = load i8*, i8** %102
%104 = call i32 @strlen(i8* %103)
%105 = sext i32 %104 to i64
%106 = icmp slt i64 %98, %105
br i1 %106, label %68, label %62
107: ; preds = %62
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.23, i64 0, i64 0))
br label %221
109: ; preds = %62
%110 = load i32, i32* %3
%111 = add nsw i32 %110, 1
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8*, i8** %1, i64 %112
%114 = load i8*, i8** %113
%115 = add nsw i32 %110, 2
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8*, i8** %1, i64 %116
%118 = load i8*, i8** %117
%119 = call i32* @relSearch(i8* %114, i8* %118, i32 %8, i32 %15)
%120 = load i32, i32* %119
%121 = icmp eq i32 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %109
%123 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.22, i64 0, i64 0))
%124 = call i32 @free(i32* %119)
br label %221
125: ; preds = %109
%126 = icmp eq i32 %12, -1
br i1 %126, label %171, label %127
127: ; preds = %125
%128 = icmp slt i32 %12, %120
br i1 %128, label %134, label %129
129: ; preds = %127
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0), i32 %12)
%131 = load i32, i32* %119
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0), i32 %131)
%133 = call i32 @free(i32* %119)
br label %221
134: ; preds = %127
%135 = bitcast i16* %4 to i8*
store i16 120, i16* %4
%136 = add nsw i32 %12, 2
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i32, i32* %119, i64 %137
%139 = load i32, i32* %138
%140 = icmp eq i32 %139, -1
br i1 %140, label %152, label %141
141: ; preds = %134
store i8 65, i8* %135
%142 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %139, i16* %4)
br label %143
143: ; preds = %141, %143
%144 = phi i32 [ 1, %141 ], [ %150, %143 ]
%145 = load i32, i32* %138
%146 = trunc i32 %144 to i8
%147 = add nuw nsw i8 %146, 65
store i8 %147, i8* %135
%148 = add nsw i32 %145, %144
%149 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %148, i16* %4)
%150 = add nuw nsw i32 %144, 1
%151 = icmp eq i32 %150, 26
br i1 %151, label %152, label %143
152: ; preds = %143, %134
%153 = add nsw i32 %12, 3
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i32, i32* %119, i64 %154
%156 = load i32, i32* %155
%157 = icmp eq i32 %156, -1
br i1 %157, label %169, label %158
158: ; preds = %152
store i8 97, i8* %135
%159 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %156, i16* %4)
br label %160
160: ; preds = %158, %160
%161 = phi i32 [ 1, %158 ], [ %167, %160 ]
%162 = load i32, i32* %155
%163 = trunc i32 %161 to i8
%164 = add nuw nsw i8 %163, 97
store i8 %164, i8* %135
%165 = add nsw i32 %162, %161
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i32 %165, i16* %4)
%167 = add nuw nsw i32 %161, 1
%168 = icmp eq i32 %167, 26
br i1 %168, label %169, label %160
169: ; preds = %160, %152
%170 = call i32 @free(i32* %119)
br label %221
171: ; preds = %125
%172 = call i32 @putchar(i32 91)
%173 = load i32, i32* %119
%174 = icmp sgt i32 %173, 0
br i1 %174, label %178, label %175
175: ; preds = %216, %171
%176 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%177 = call i32 @free(i32* %119)
br label %221
178: ; preds = %171, %216
%179 = phi i64 [ %218, %216 ], [ 0, %171 ]
%180 = udiv i64 %179, 3
%181 = add nuw nsw i64 %179, 1
%182 = getelementptr inbounds i32, i32* %119, i64 %181
%183 = load i32, i32* %182
%184 = trunc i64 %180 to i32
%185 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i32 %184, i32 %183)
%186 = add nuw nsw i64 %179, 2
%187 = getelementptr inbounds i32, i32* %119, i64 %186
%188 = load i32, i32* %187
%189 = icmp sgt i32 %188, -1
br i1 %189, label %190, label %198
190: ; preds = %178
%191 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i32 %188)
%192 = add nuw nsw i64 %179, 3
%193 = getelementptr inbounds i32, i32* %119, i64 %192
%194 = load i32, i32* %193
%195 = icmp sgt i32 %194, -1
br i1 %195, label %196, label %205
196: ; preds = %190
%197 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 %194)
br label %205
198: ; preds = %178
%199 = add nuw nsw i64 %179, 3
%200 = getelementptr inbounds i32, i32* %119, i64 %199
%201 = load i32, i32* %200
%202 = icmp sgt i32 %201, -1
br i1 %202, label %203, label %205
203: ; preds = %198
%204 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), i32 %201)
br label %205
205: ; preds = %198, %203, %190, %196
%206 = call i32 @putchar(i32 125)
%207 = load i32, i32* %119
%208 = mul i32 %207, 3
%209 = add i32 %208, -3
%210 = zext i32 %209 to i64
%211 = icmp eq i64 %179, %210
br i1 %211, label %216, label %212
212: ; preds = %205
%213 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.21, i64 0, i64 0))
%214 = load i32, i32* %119
%215 = mul nsw i32 %214, 3
br label %216
216: ; preds = %205, %212
%217 = phi i32 [ %208, %205 ], [ %215, %212 ]
%218 = add nuw i64 %179, 3
%219 = trunc i64 %218 to i32
%220 = icmp sgt i32 %217, %219
br i1 %220, label %178, label %175
221: ; preds = %14, %107, %122, %129, %169, %175, %60, %42, %31, %21
%222 = phi i32 [ 0, %31 ], [ 1, %21 ], [ 1, %42 ], [ 1, %60 ], [ 1, %107 ], [ 1, %122 ], [ 1, %129 ], [ 0, %169 ], [ 0, %175 ], [ 1, %14 ]
ret i32 %222
}