#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 */
typedef int /*<<< orphan*/ fpos_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ convertLinks(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                char *, int);
int /*<<< orphan*/ convertTitle(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                char *);
int /*<<< orphan*/ exitError(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fsetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int getIndexofElektraRoot(char *);
int /*<<< orphan*/ printConvertedPath(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char *strrchr(char *, char);
int main(int argc, char *argv[]) {
  if (argc < 2 || argc > 3) {
    fprintf(stderr, "Invalid number of arguments.\n");
    fprintf(stderr, "Usage: %s [<cmake-cache-file>] <input-file>\n", argv[0]);
    return EXIT_FAILURE;
  }
  char inputFilename[strlen(argv[argc - 1]) + 1];
  strcpy(inputFilename, argv[argc - 1]);
  int indexofElektraRoot = -1;
  if (argc == 3) {
    char cmakeCacheFilename[strlen(argv[1]) + 1];
    strcpy(cmakeCacheFilename, argv[1]);
    indexofElektraRoot = getIndexofElektraRoot(cmakeCacheFilename);
  } else {
    indexofElektraRoot = getIndexofElektraRoot(NULL);
  }
  if (0 > indexofElektraRoot)
    return EXIT_FAILURE;
  FILE *input = fopen(inputFilename, "r");
  if (!input) {
    fprintf(stderr, "fopen Error: file %s not found\n", inputFilename);
    return EXIT_FAILURE;
  }
  FILE *output = fopen("temp", "w+");
  if (!output) {
    fclose(input);
    fprintf(stderr, "fopen Error: tempfile %s not found\n", "temp");
    return EXIT_FAILURE;
  }
  fpos_t startInput;
  fpos_t startTempFile;
  if (fgetpos(input, &startInput))
    exitError(input, output, "fgetpos");
  if (fgetpos(output, &startTempFile))
    exitError(input, output, "fgetpos");
  if (!strncmp("src/plugins/", &inputFilename[indexofElektraRoot],
               strlen("src/plugins/"))) {
    char *title = &inputFilename[indexofElektraRoot] + strlen("src/plugins/");
    if (strcmp(title, "README.md")) {
      printf(" # Plugin: ");
      while ((*title) != '/') {
        printf("%c", *title);
        ++title;
      }
      printf(" #\n");
    }
  }
  if (!convertTitle(input, output, &inputFilename[indexofElektraRoot])) {
    if (fsetpos(input, &startInput))
      exitError(input, output, "fsetpos");
    fclose(output);
    output = stdout;
    char *title = strrchr(inputFilename, '/');
    if (title == NULL)
      exitError(input, NULL, "parsed file path invalid");
    fprintf(output, "# %s # {#", &title[1]);
    printConvertedPath(output, &inputFilename[indexofElektraRoot]);
    fprintf(output, "}\n");
    convertLinks(input, output, inputFilename, indexofElektraRoot);
    fclose(input);
  } else {
    fclose(input);
    if (fsetpos(output, &startTempFile))
      exitError(output, NULL, "fsetpos");
    convertLinks(output, stdout, inputFilename, indexofElektraRoot);
    fclose(output);
  }
  remove("temp");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     123d <main+0x2d>
cmpl   $0x3,-0x8(%rbp)
jle    1285 <main+0x75>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rdi
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    16c5 <main+0x4b5>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <strlen@plt>
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x70(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <strcpy@plt>
movl   $0xffffffff,-0x24(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1340 <main+0x130>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <strlen@plt>
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x78(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1050 <strcpy@plt>
mov    -0x78(%rbp),%rdi
call   10d0 <getIndexofElektraRoot@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    134c <main+0x13c>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <getIndexofElektraRoot@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
jle    136f <main+0x15f>
mov    0x2c7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    16be <main+0x4ae>
mov    -0x70(%rbp),%rdi
lea    0xcd1(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13c2 <main+0x1b2>
mov    -0x70(%rbp),%rdx
mov    0x2c47(%rip),%rax
mov    (%rax),%rdi
lea    0xcaa(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2c27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    16be <main+0x4ae>
lea    0xca4(%rip),%rdi
lea    0xca2(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1424 <main+0x214>
mov    -0x48(%rbp),%rdi
call   1070 <fclose@plt>
mov    0x2bec(%rip),%rax
mov    (%rax),%rdi
lea    0xc77(%rip),%rsi
lea    0xc68(%rip),%rdx
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    0x2bc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    16be <main+0x4ae>
mov    -0x48(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   10b0 <fgetpos@plt>
cmp    $0x0,%rax
je     144f <main+0x23f>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
lea    0xc4f(%rip),%rdx
call   1060 <exitError@plt>
mov    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   10b0 <fgetpos@plt>
cmp    $0x0,%rax
je     147a <main+0x26a>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
lea    0xc24(%rip),%rdx
call   1060 <exitError@plt>
mov    -0x70(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
lea    0xc11(%rip),%rdi
call   1090 <strlen@plt>
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
lea    0xbff(%rip),%rdi
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1552 <main+0x342>
mov    -0x70(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x88(%rbp)
lea    0xbd8(%rip),%rdi
call   1090 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
lea    0xbc2(%rip),%rsi
call   10f0 <strcmp@plt>
cmp    $0x0,%rax
je     154d <main+0x33d>
lea    0xbb6(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     153f <main+0x32f>
mov    -0x60(%rbp),%rax
movsbl (%rax),%esi
lea    0xb9d(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1509 <main+0x2f9>
lea    0xb81(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
jmp    1552 <main+0x342>
mov    -0x70(%rbp),%rdx
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rdx
call   10e0 <convertTitle@plt>
cmp    $0x0,%eax
jne    1648 <main+0x438>
mov    -0x48(%rbp),%rdi
lea    -0x54(%rbp),%rsi
call   1130 <fsetpos@plt>
cmp    $0x0,%rax
je     159e <main+0x38e>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
lea    0xb32(%rip),%rdx
call   1060 <exitError@plt>
mov    -0x50(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x70(%rbp),%rdi
mov    0x2a1e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    $0x2f,%esi
call   10c0 <strrchr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    15e6 <main+0x3d6>
mov    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    0xaf2(%rip),%rdx
call   1060 <exitError@plt>
mov    -0x50(%rbp),%rdi
mov    -0x68(%rbp),%rdx
add    $0x1,%rdx
lea    0xaf3(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    -0x70(%rbp),%rsi
mov    -0x50(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
call   1110 <printConvertedPath@plt>
mov    -0x50(%rbp),%rdi
lea    0xad7(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    -0x70(%rbp),%rdx
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x24(%rbp),%ecx
call   1080 <convertLinks@plt>
mov    -0x48(%rbp),%rdi
call   1070 <fclose@plt>
jmp    169f <main+0x48f>
mov    -0x48(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1130 <fsetpos@plt>
cmp    $0x0,%rax
je     167c <main+0x46c>
mov    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    0xa54(%rip),%rdx
call   1060 <exitError@plt>
mov    -0x70(%rbp),%rdx
mov    -0x50(%rbp),%rdi
mov    0x2945(%rip),%rax
mov    (%rax),%rsi
mov    -0x24(%rbp),%ecx
call   1080 <convertLinks@plt>
mov    -0x50(%rbp),%rdi
call   1070 <fclose@plt>
lea    0x9c7(%rip),%rdi
call   1030 <remove@plt>
mov    0x2916(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x4(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     12a0 <main+0x60>
mov    0x2d7b(%rip),%rbx
mov    (%rbx),%rcx
lea    0xd91(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
call   1160 <fwrite@plt>
mov    (%rbx),%rdi
mov    (%r14),%rdx
lea    0xd93(%rip),%rsi
xor    %eax,%eax
call   1120 <fprintf@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
jmp    15ed <main+0x3ad>
lea    -0x1(%rbx),%r15d
mov    (%r14,%r15,8),%rdi
call   10b0 <strlen@plt>
mov    %rsp,%r12
add    $0x1,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    (%r14,%r15,8),%rsi
mov    %r13,%rdi
call   1060 <strcpy@plt>
cmp    $0x3,%ebx
jne    149f <main+0x25f>
mov    0x8(%r14),%rdi
call   10b0 <strlen@plt>
mov    %rsp,%r15
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1060 <strcpy@plt>
mov    %rbx,%rdi
call   10f0 <getIndexofElektraRoot@plt>
mov    %eax,%ebx
mov    %r15,%rsp
test   %ebx,%ebx
js     14b0 <main+0x270>
lea    0xd2a(%rip),%rsi
mov    %r13,%rdi
call   1140 <fopen@plt>
test   %rax,%rax
je     14bc <main+0x27c>
mov    %rax,%r15
mov    %r12,-0x40(%rbp)
lea    0xd2d(%rip),%rdi
lea    0xd2b(%rip),%rsi
call   1140 <fopen@plt>
test   %rax,%rax
je     14e3 <main+0x2a3>
mov    %rax,%r12
lea    -0x48(%rbp),%rsi
mov    %r15,%rdi
call   10d0 <fgetpos@plt>
test   %rax,%rax
je     137b <main+0x13b>
lea    0xd29(%rip),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <exitError@plt>
lea    -0x44(%rbp),%rsi
mov    %r12,%rdi
call   10d0 <fgetpos@plt>
test   %rax,%rax
je     139e <main+0x15e>
lea    0xd06(%rip),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <exitError@plt>
mov    %ebx,-0x2c(%rbp)
mov    %ebx,%eax
mov    %rax,-0x38(%rbp)
lea    (%rax,%r13,1),%r14
lea    0xcef(%rip),%rbx
mov    %rbx,%rdi
call   10b0 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
jne    143f <main+0x1ff>
lea    0xccf(%rip),%rdi
call   10b0 <strlen@plt>
cltq
mov    %rax,-0x50(%rbp)
lea    (%r14,%rax,1),%rbx
lea    0xcc6(%rip),%rsi
mov    %rbx,%rdi
call   1110 <strcmp@plt>
test   %rax,%rax
je     143f <main+0x1ff>
lea    0xcbc(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    (%rbx),%al
cmp    $0x2f,%al
je     1433 <main+0x1f3>
mov    -0x50(%rbp),%rcx
add    -0x38(%rbp),%rcx
lea    (%rcx,%r13,1),%rbx
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x2f,%al
jne    1420 <main+0x1e0>
lea    0xcb8(%rip),%rdi
call   1080 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1100 <convertTitle@plt>
test   %eax,%eax
je     151c <main+0x2dc>
mov    %r15,%rdi
call   1090 <fclose@plt>
lea    -0x44(%rbp),%rsi
mov    %r12,%rdi
call   1150 <fsetpos@plt>
test   %rax,%rax
je     147f <main+0x23f>
lea    0xc4f(%rip),%rdx
mov    %r12,%rdi
xor    %esi,%esi
call   1070 <exitError@plt>
mov    0x2b4a(%rip),%rax
mov    (%rax),%rsi
mov    %r12,%rdi
mov    %r13,%rdx
mov    -0x2c(%rbp),%ecx
call   10a0 <convertLinks@plt>
mov    %r12,%r15
jmp    15c9 <main+0x389>
xor    %edi,%edi
call   10f0 <getIndexofElektraRoot@plt>
mov    %eax,%ebx
test   %ebx,%ebx
jns    131a <main+0xda>
mov    0x2b21(%rip),%rax
jmp    15e8 <main+0x3a8>
mov    0x2b1d(%rip),%rax
mov    (%rax),%rdi
lea    0xb80(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1120 <fprintf@plt>
mov    0x2afa(%rip),%rax
jmp    15e8 <main+0x3a8>
mov    %r15,%rdi
call   1090 <fclose@plt>
mov    0x2aee(%rip),%rax
mov    (%rax),%rdi
lea    0xb79(%rip),%rsi
lea    0xb6a(%rip),%rdx
xor    %eax,%eax
call   1120 <fprintf@plt>
mov    0x2ac7(%rip),%rax
mov    (%rax),%eax
mov    -0x40(%rbp),%r12
jmp    15ea <main+0x3aa>
mov    %r14,-0x38(%rbp)
lea    -0x48(%rbp),%rsi
mov    %r15,%rdi
call   1150 <fsetpos@plt>
test   %rax,%rax
je     1543 <main+0x303>
lea    0xb8c(%rip),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <exitError@plt>
mov    %r12,%rdi
call   1090 <fclose@plt>
mov    0x2a7e(%rip),%rax
mov    (%rax),%r12
mov    %r13,%rdi
mov    $0x2f,%esi
call   10e0 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    157b <main+0x33b>
lea    0xb5b(%rip),%rdx
mov    %r15,%rdi
xor    %esi,%esi
call   1070 <exitError@plt>
add    $0x1,%rbx
lea    0xb5f(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1120 <fprintf@plt>
mov    %r12,%rdi
mov    -0x38(%rbp),%rsi
call   1130 <printConvertedPath@plt>
lea    0xb49(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1160 <fwrite@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    -0x2c(%rbp),%ecx
call   10a0 <convertLinks@plt>
mov    -0x40(%rbp),%r12
mov    %r15,%rdi
call   1090 <fclose@plt>
lea    0xa91(%rip),%rdi
call   1040 <remove@plt>
mov    0x29e0(%rip),%rax
mov    (%rax),%eax
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32* null
@.str = [30 x i8] c"Invalid number of arguments.\0A\00"
@.str.1 = [45 x i8] c"Usage: %s [<cmake-cache-file>] <input-file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [32 x i8] c"fopen Error: file %s not found\0A\00"
@.str.4 = [5 x i8] c"temp\00"
@.str.5 = [3 x i8] c"w+\00"
@.str.6 = [36 x i8] c"fopen Error: tempfile %s not found\0A\00"
@.str.7 = [8 x i8] c"fgetpos\00"
@.str.8 = [13 x i8] c"src/plugins/\00"
@.str.9 = [10 x i8] c"README.md\00"
@.str.10 = [12 x i8] c" # Plugin: \00"
@.str.11 = [3 x i8] c"%c\00"
@.str.12 = [4 x i8] c" #\0A\00"
@.str.13 = [8 x i8] c"fsetpos\00"
@stdout = global i32* null
@.str.14 = [25 x i8] c"parsed file path invalid\00"
@.str.15 = [10 x i8] c"# %s # {#\00"
@.str.16 = [3 x i8] c"}\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %23, label %20
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 3
br i1 %22, label %23, label %32
23: ; preds = %20, %2
%24 = load i32*, i32** @stderr
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%26 = load i32*, i32** @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %208
32: ; preds = %20
%33 = load i8**, i8*** %5
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @strlen(i8* %38)
%40 = add nsw i32 %39, 1
%41 = zext i32 %40 to i64
%42 = call i8* @llvm.stacksave()
store i8* %42, i8** %6
%43 = alloca i8, i64 %41
store i64 %41, i64* %7
%44 = load i8**, i8*** %5
%45 = load i32, i32* %4
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %44, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strcpy(i8* %43, i8* %49)
store i32 -1, i32* %8
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 3
br i1 %52, label %53, label %68
53: ; preds = %32
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @strlen(i8* %56)
%58 = add nsw i32 %57, 1
%59 = zext i32 %58 to i64
%60 = call i8* @llvm.stacksave()
store i8* %60, i8** %9
%61 = alloca i8, i64 %59
store i64 %59, i64* %10
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @strcpy(i8* %61, i8* %64)
%66 = call i32 @getIndexofElektraRoot(i8* %61)
store i32 %66, i32* %8
%67 = load i8*, i8** %9
br label %70
68: ; preds = %32
%69 = call i32 @getIndexofElektraRoot(i8* null)
store i32 %69, i32* %8
br label %70
70: ; preds = %68, %53
%71 = load i32, i32* %8
%72 = icmp sgt i32 0, %71
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = load i32, i32* @EXIT_FAILURE
store i32 %74, i32* %3
store i32 1, i32* %11
br label %206
75: ; preds = %70
%76 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %76, i32** %12
%77 = load i32*, i32** %12
%78 = icmp ne i32* %77, null
br i1 %78, label %83, label %79
79: ; preds = %75
%80 = load i32*, i32** @stderr
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%82 = load i32, i32* @EXIT_FAILURE
store i32 %82, i32* %3
store i32 1, i32* %11
br label %206
83: ; preds = %75
%84 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %84, i32** %13
%85 = load i32*, i32** %13
%86 = icmp ne i32* %85, null
br i1 %86, label %93, label %87
87: ; preds = %83
%88 = load i32*, i32** %12
%89 = call i32 @fclose(i32* %88)
%90 = load i32*, i32** @stderr
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
store i32 %92, i32* %3
store i32 1, i32* %11
br label %206
93: ; preds = %83
%94 = load i32*, i32** %12
%95 = call i64 @fgetpos(i32* %94, i32* %14)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %101
97: ; preds = %93
%98 = load i32*, i32** %12
%99 = load i32*, i32** %13
%100 = call i32 @exitError(i32* %98, i32* %99, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %101
101: ; preds = %97, %93
%102 = load i32*, i32** %13
%103 = call i64 @fgetpos(i32* %102, i32* %15)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %101
%106 = load i32*, i32** %12
%107 = load i32*, i32** %13
%108 = call i32 @exitError(i32* %106, i32* %107, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %109
109: ; preds = %105, %101
%110 = load i32, i32* %8
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %43, i64 %111
%113 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%114 = call i32 @strncmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %112, i32 %113)
%115 = icmp ne i32 %114, 0
br i1 %115, label %143, label %116
116: ; preds = %109
%117 = load i32, i32* %8
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %43, i64 %118
%120 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i8, i8* %119, i64 %121
store i8* %122, i8** %16
%123 = load i8*, i8** %16
%124 = call i64 @strcmp(i8* %123, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %142
126: ; preds = %116
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %128
128: ; preds = %133, %126
%129 = load i8*, i8** %16
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = icmp ne i32 %131, 47
br i1 %132, label %133, label %140
133: ; preds = %128
%134 = load i8*, i8** %16
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 %136)
%138 = load i8*, i8** %16
%139 = getelementptr inbounds i8, i8* %138, i32 1
store i8* %139, i8** %16
br label %128
140: ; preds = %128
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
br label %142
142: ; preds = %140, %116
br label %143
143: ; preds = %142, %109
%144 = load i32*, i32** %12
%145 = load i32*, i32** %13
%146 = load i32, i32* %8
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i8, i8* %43, i64 %147
%149 = call i32 @convertTitle(i32* %144, i32* %145, i8* %148)
%150 = icmp ne i32 %149, 0
br i1 %150, label %187, label %151
151: ; preds = %143
%152 = load i32*, i32** %12
%153 = call i64 @fsetpos(i32* %152, i32* %14)
%154 = icmp ne i64 %153, 0
br i1 %154, label %155, label %159
155: ; preds = %151
%156 = load i32*, i32** %12
%157 = load i32*, i32** %13
%158 = call i32 @exitError(i32* %156, i32* %157, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %159
159: ; preds = %155, %151
%160 = load i32*, i32** %13
%161 = call i32 @fclose(i32* %160)
%162 = load i32*, i32** @stdout
store i32* %162, i32** %13
%163 = call i8* @strrchr(i8* %43, i8 signext 47)
store i8* %163, i8** %17
%164 = load i8*, i8** %17
%165 = icmp eq i8* %164, null
br i1 %165, label %166, label %169
166: ; preds = %159
%167 = load i32*, i32** %12
%168 = call i32 @exitError(i32* %167, i32* null, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
br label %169
169: ; preds = %166, %159
%170 = load i32*, i32** %13
%171 = load i8*, i8** %17
%172 = getelementptr inbounds i8, i8* %171, i64 1
%173 = call i32 (i32*, i8*, ...) @fprintf(i32* %170, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* %172)
%174 = load i32*, i32** %13
%175 = load i32, i32* %8
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds i8, i8* %43, i64 %176
%178 = call i32 @printConvertedPath(i32* %174, i8* %177)
%179 = load i32*, i32** %13
%180 = call i32 (i32*, i8*, ...) @fprintf(i32* %179, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%181 = load i32*, i32** %12
%182 = load i32*, i32** %13
%183 = load i32, i32* %8
%184 = call i32 @convertLinks(i32* %181, i32* %182, i8* %43, i32 %183)
%185 = load i32*, i32** %12
%186 = call i32 @fclose(i32* %185)
br label %203
187: ; preds = %143
%188 = load i32*, i32** %12
%189 = call i32 @fclose(i32* %188)
%190 = load i32*, i32** %13
%191 = call i64 @fsetpos(i32* %190, i32* %15)
%192 = icmp ne i64 %191, 0
br i1 %192, label %193, label %196
193: ; preds = %187
%194 = load i32*, i32** %13
%195 = call i32 @exitError(i32* %194, i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %196
196: ; preds = %193, %187
%197 = load i32*, i32** %13
%198 = load i32*, i32** @stdout
%199 = load i32, i32* %8
%200 = call i32 @convertLinks(i32* %197, i32* %198, i8* %43, i32 %199)
%201 = load i32*, i32** %13
%202 = call i32 @fclose(i32* %201)
br label %203
203: ; preds = %196, %169
%204 = call i32 @remove(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%205 = load i32, i32* @EXIT_SUCCESS
store i32 %205, i32* %3
store i32 1, i32* %11
br label %206
206: ; preds = %203, %87, %79, %73
%207 = load i8*, i8** %6
br label %208
208: ; preds = %206, %23
%209 = load i32, i32* %3
ret i32 %209
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [30 x i8] c"Invalid number of arguments.\0A\00"
@.str.1 = [45 x i8] c"Usage: %s [<cmake-cache-file>] <input-file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [32 x i8] c"fopen Error: file %s not found\0A\00"
@.str.4 = [5 x i8] c"temp\00"
@.str.5 = [3 x i8] c"w+\00"
@.str.6 = [36 x i8] c"fopen Error: tempfile %s not found\0A\00"
@.str.7 = [8 x i8] c"fgetpos\00"
@.str.8 = [13 x i8] c"src/plugins/\00"
@.str.9 = [10 x i8] c"README.md\00"
@.str.10 = [12 x i8] c" # Plugin: \00"
@.str.13 = [8 x i8] c"fsetpos\00"
@stdout = global i32* null
@.str.14 = [25 x i8] c"parsed file path invalid\00"
@.str.15 = [10 x i8] c"# %s # {#\00"
@.str.16 = [3 x i8] c"}\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [3 x i8] c" #\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = add i32 %0, -4
%6 = icmp ult i32 %5, -2
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32*, i32** @stderr
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 29, i64 1, i32* %8)
%10 = load i32*, i32** @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
br label %135
14: ; preds = %2
%15 = add nsw i32 %0, -1
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = zext i32 %20 to i64
%22 = tail call i8* @llvm.stacksave()
%23 = alloca i8, i64 %21
%24 = load i8*, i8** %17
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = icmp eq i32 %0, 3
br i1 %26, label %27, label %38
27: ; preds = %14
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strlen(i8* %29)
%31 = add nsw i32 %30, 1
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
%34 = alloca i8, i64 %32
%35 = load i8*, i8** %28
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = call i32 @getIndexofElektraRoot(i8* %34)
br label %40
38: ; preds = %14
%39 = call i32 @getIndexofElektraRoot(i8* null)
br label %40
40: ; preds = %38, %27
%41 = phi i32 [ %37, %27 ], [ %39, %38 ]
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = load i32, i32* @EXIT_FAILURE
br label %133
45: ; preds = %40
%46 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i32*, i32** @stderr
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%51 = load i32, i32* @EXIT_FAILURE
br label %133
52: ; preds = %45
%53 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = call i32 @fclose(i32* %46)
%57 = load i32*, i32** @stderr
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
br label %133
60: ; preds = %52
%61 = bitcast i32* %3 to i8*
%62 = bitcast i32* %4 to i8*
%63 = call i64 @fgetpos(i32* %46, i32* %3)
%64 = icmp eq i64 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %60
%66 = call i32 @exitError(i32* %46, i32* %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %67
67: ; preds = %65, %60
%68 = call i64 @fgetpos(i32* %53, i32* %4)
%69 = icmp eq i64 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %67
%71 = call i32 @exitError(i32* %46, i32* %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %72
72: ; preds = %70, %67
%73 = zext i32 %41 to i64
%74 = getelementptr inbounds i8, i8* %23, i64 %73
%75 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%76 = call i32 @strncmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %74, i32 %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %98
78: ; preds = %72
%79 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %74, i64 %80
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %98, label %84
84: ; preds = %78
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%86 = load i8, i8* %81
%87 = icmp eq i8 %86, 47
br i1 %87, label %96, label %88
88: ; preds = %84, %88
%89 = phi i8 [ %94, %88 ], [ %86, %84 ]
%90 = phi i8* [ %93, %88 ], [ %81, %84 ]
%91 = sext i8 %89 to i32
%92 = call i32 @putchar(i32 %91)
%93 = getelementptr inbounds i8, i8* %90, i64 1
%94 = load i8, i8* %93
%95 = icmp eq i8 %94, 47
br i1 %95, label %96, label %88
96: ; preds = %88, %84
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %98
98: ; preds = %78, %96, %72
%99 = call i32 @convertTitle(i32* %46, i32* %53, i8* %74)
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %119
101: ; preds = %98
%102 = call i64 @fsetpos(i32* %46, i32* %3)
%103 = icmp eq i64 %102, 0
br i1 %103, label %106, label %104
104: ; preds = %101
%105 = call i32 @exitError(i32* %46, i32* %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %106
106: ; preds = %104, %101
%107 = call i32 @fclose(i32* %53)
%108 = load i32*, i32** @stdout
%109 = call i8* @strrchr(i8* %23, i8 signext 47)
%110 = icmp eq i8* %109, null
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = call i32 @exitError(i32* %46, i32* null, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
br label %113
113: ; preds = %111, %106
%114 = getelementptr inbounds i8, i8* %109, i64 1
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %108, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* %114)
%116 = call i32 @printConvertedPath(i32* %108, i8* %74)
%117 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i64 2, i64 1, i32* %108)
%118 = call i32 @convertLinks(i32* %46, i32* %108, i8* %23, i32 %41)
br label %128
119: ; preds = %98
%120 = call i32 @fclose(i32* %46)
%121 = call i64 @fsetpos(i32* %53, i32* %4)
%122 = icmp eq i64 %121, 0
br i1 %122, label %125, label %123
123: ; preds = %119
%124 = call i32 @exitError(i32* %53, i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %125
125: ; preds = %123, %119
%126 = load i32*, i32** @stdout
%127 = call i32 @convertLinks(i32* %53, i32* %126, i8* %23, i32 %41)
br label %128
128: ; preds = %125, %113
%129 = phi i32* [ %53, %125 ], [ %46, %113 ]
%130 = call i32 @fclose(i32* %129)
%131 = call i32 @remove(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%132 = load i32, i32* @EXIT_SUCCESS
br label %133
133: ; preds = %48, %128, %55, %43
%134 = phi i32 [ %44, %43 ], [ %51, %48 ], [ %132, %128 ], [ %59, %55 ]
br label %135
135: ; preds = %133, %7
%136 = phi i32 [ %13, %7 ], [ %134, %133 ]
ret i32 %136
}