#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*/ unified_boot_magic;
struct stat {
  unsigned int st_size;
};
typedef int /*<<< orphan*/ non_unified_boot_magic;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
unsigned int atoi(char *);
scalar_t__ cat(int /*<<< orphan*/ *, int /*<<< orphan*/ *, unsigned int,
               unsigned int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fwrite(char *, int, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int, int);
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int print_usage();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ unlink(char *);
unsigned int write(int, unsigned int *, unsigned int);
int main(int argc, char *argv[]) {
  struct stat s;
  unsigned size, base;
  int unified_boot = 0;
  unsigned unified_boot_magic[20];
  unsigned non_unified_boot_magic[10];
  unsigned magic_len = 0;
  unsigned *magic;
  unsigned cert_chain_size = 0;
  unsigned signature_size = 0;
  int secure_boot = 0;
  int fd;
  if (argc < 3) {
    return print_usage();
  }
  if (argc == 4) {
    if (!strcmp("unified-boot", argv[3])) {
      unified_boot = 1;
    } else if (!strcmp("secure-boot", argv[3])) {
      fprintf(stderr, "ERROR: Missing arguments: [outbin maxsize] |"
                      " [outbin, maxsize, certchain,"
                      " signature + certifcate(s)]\n");
      return print_usage();
    } else if (!strcmp("unsecure-boot", argv[3])) {
      fprintf(stderr, "ERROR: Missing arguments:"
                      " outbin directory\n");
      return print_usage();
    }
  }
  if (argc > 4) {
    if (!strcmp("secure-boot", argv[3])) {
      if (argc < 9 && argc != 6) {
        fprintf(stderr, "ERROR: Missing argument(s):"
                        " [outbin maxsize] | [outbin, maxsize,"
                        " certchain,"
                        " signature + certifcate(s)]\n");
        return print_usage();
      }
      secure_boot = 1;
      signature_size = 256;
      cert_chain_size = atoi(argv[5]);
    }
  }
  if (stat(argv[1], &s)) {
    perror("cannot stat binary");
    return -1;
  }
  if (unified_boot) {
    magic = unified_boot_magic;
    magic_len = sizeof(unified_boot_magic);
  } else {
    magic = non_unified_boot_magic;
    magic_len = sizeof(non_unified_boot_magic);
  }
  size = s.st_size;
  base = 0;
  printf("Image Destination Pointer: 0x%x\n", base);
  magic[0] = 0x00000005;
  magic[1] = 0x00000003;
  magic[2] = 0x00000000;
  magic[3] = base;
  magic[4] = size + cert_chain_size + signature_size;
  magic[5] = size;
  magic[6] = base + size;
  magic[7] = signature_size;
  magic[8] = size + base + signature_size;
  magic[9] = cert_chain_size;
  if (unified_boot == 1) {
    magic[10] = 0x33836685;
    magic[11] = 0x00000001;
    magic[12] = 0x00000002;
    magic[13] = 0x00000000;
    magic[14] = 0x00000000;
    magic[15] = 0x00000000;
    magic[16] = 0x00000000;
    magic[17] = 0x00000000;
    magic[18] = 0x00000000;
    magic[19] = 0x00000000;
  }
  fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
  if (fd < 0) {
    perror("cannot open header for writing");
    return -1;
  }
  if (write(fd, magic, magic_len) != magic_len) {
    perror("cannot write header");
    close(fd);
    unlink(argv[2]);
    return -1;
  }
  close(fd);
  if (secure_boot && argc > 6) {
    FILE *input_file;
    FILE *output_file;
    unsigned buff_size = 1;
    char buf[buff_size];
    unsigned bytes_left;
    unsigned current_cert_chain_size = 0;
    int padding_size = 0;
    int i;
    if ((output_file = fopen(argv[6], "wb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    printf("Certificate Chain Output File: %s\n", argv[6]);
    for (i = 8; i < argc; i++) {
      if ((input_file = fopen(argv[i], "rb")) == NULL) {
        perror("ERROR: Occured during fopen");
        return -1;
      }
      stat(argv[i], &s);
      bytes_left = s.st_size;
      current_cert_chain_size += bytes_left;
      if (cat(input_file, output_file, bytes_left, buff_size))
        return -1;
      fclose(input_file);
    }
    memset(buf, 0xFF, sizeof(buf));
    padding_size = cert_chain_size - current_cert_chain_size;
    if (padding_size < 0) {
      fprintf(stderr,
              "ERROR: Input certificate chain"
              " (Size=%d) is larger than the maximum"
              " specified (Size=%d)\n",
              current_cert_chain_size, cert_chain_size);
      return -1;
    }
    bytes_left = (padding_size > 0) ? padding_size : 0;
    while (bytes_left) {
      if (!ferror(output_file))
        bytes_left -= fwrite(buf, sizeof(buf), buff_size, output_file);
      else {
        fprintf(stderr, "ERROR: Occured during"
                        " certifcate chain padding\n");
        return -1;
      }
    }
    fclose(output_file);
    if ((output_file = fopen(argv[4], "wb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    printf("Image Output File: %s\n", argv[4]);
    if ((input_file = fopen(argv[2], "rb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    stat(argv[2], &s);
    if (cat(input_file, output_file, s.st_size, buff_size))
      return -1;
    fclose(input_file);
    if ((input_file = fopen(argv[1], "rb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    stat(argv[1], &s);
    if (cat(input_file, output_file, s.st_size, buff_size))
      return -1;
    fclose(input_file);
    if ((input_file = fopen(argv[7], "rb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    stat(argv[7], &s);
    if (cat(input_file, output_file, s.st_size, buff_size))
      return -1;
    fclose(input_file);
    if ((input_file = fopen(argv[6], "rb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    if (cat(input_file, output_file, (current_cert_chain_size + padding_size),
            buff_size))
      return -1;
    fclose(input_file);
    fclose(output_file);
  } else if (argc == 5 || argc == 6) {
    FILE *input_file;
    FILE *output_file;
    unsigned buff_size = 1;
    char buf[buff_size];
    if ((output_file = fopen(argv[4], "wb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    printf("Image Output File: %s\n", argv[4]);
    if ((input_file = fopen(argv[2], "rb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    stat(argv[2], &s);
    if (cat(input_file, output_file, s.st_size, buff_size))
      return -1;
    fclose(input_file);
    if ((input_file = fopen(argv[1], "rb")) == NULL) {
      perror("ERROR: Occured during fopen");
      return -1;
    }
    stat(argv[1], &s);
    if (cat(input_file, output_file, s.st_size, buff_size))
      return -1;
    fclose(input_file);
    fclose(output_file);
  }
  printf("Done execution\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xc4(%rbp)
movl   $0x0,-0xc8(%rbp)
movl   $0x0,-0xcc(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1271 <main+0x61>
mov    $0x0,%al
call   1120 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1e83 <main+0xc73>
cmpl   $0x4,-0x8(%rbp)
jne    1339 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd76(%rip),%rdi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12a4 <main+0x94>
movl   $0x1,-0x24(%rbp)
jmp    1334 <main+0x124>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdc2(%rip),%rdi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12e7 <main+0xd7>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1120 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1e83 <main+0xc73>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd7d(%rip),%rdi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    132a <main+0x11a>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1120 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1e83 <main+0xc73>
jmp    132f <main+0x11f>
jmp    1334 <main+0x124>
jmp    1339 <main+0x129>
cmpl   $0x4,-0x8(%rbp)
jle    13c6 <main+0x1b6>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd23(%rip),%rdi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    13c1 <main+0x1b1>
cmpl   $0x9,-0x8(%rbp)
jge    139a <main+0x18a>
cmpl   $0x6,-0x8(%rbp)
je     139a <main+0x18a>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x0,%al
call   1120 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1e83 <main+0xc73>
movl   $0x1,-0xcc(%rbp)
movl   $0x100,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0xc4(%rbp)
jmp    13c6 <main+0x1b6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
je     13f9 <main+0x1e9>
lea    0xd2d(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1e83 <main+0xc73>
cmpl   $0x0,-0x24(%rbp)
je     141d <main+0x20d>
lea    -0x80(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x50,-0xb4(%rbp)
jmp    1435 <main+0x225>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x28,-0xb4(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc0(%rbp),%rax
movl   $0x5,(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x3,0x4(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x20(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1c(%rbp),%ecx
add    -0xc4(%rbp),%ecx
add    -0xc8(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x20(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc8(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
add    -0xc8(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0xc4(%rbp),%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,0x24(%rax)
cmpl   $0x1,-0x24(%rbp)
jne    158b <main+0x37b>
mov    -0xc0(%rbp),%rax
movl   $0x33836685,0x28(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x1,0x2c(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x2,0x30(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x34(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x38(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x3c(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x40(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x44(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x48(%rax)
mov    -0xc0(%rbp),%rax
movl   $0x0,0x4c(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2a26(%rip),%rax
mov    (%rax),%esi
mov    0x2a55(%rip),%rax
or     (%rax),%esi
mov    0x2a44(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10d0 <open@plt>
mov    %eax,-0xd0(%rbp)
cmpl   $0x0,-0xd0(%rbp)
jge    15e3 <main+0x3d3>
lea    0xb77(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1e83 <main+0xc73>
mov    -0xd0(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1050 <write@plt>
cmp    -0xb4(%rbp),%eax
je     1637 <main+0x427>
lea    0xb5a(%rip),%rdi
call   10f0 <perror@plt>
mov    -0xd0(%rbp),%edi
call   1090 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1e83 <main+0xc73>
mov    -0xd0(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0xcc(%rbp)
je     1c5a <main+0xa4a>
cmpl   $0x6,-0x8(%rbp)
jle    1c5a <main+0xa4a>
movl   $0x1,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    %rax,-0x148(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xf0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x140(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xf8(%rbp)
movl   $0x0,-0x100(%rbp)
movl   $0x0,-0x104(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0xabd(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    16f7 <main+0x4e7>
lea    0xaa3(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rsi
lea    0xa95(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x8,-0x108(%rbp)
mov    -0x108(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1806 <main+0x5f6>
mov    -0x10(%rbp),%rax
movslq -0x108(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xa82(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1774 <main+0x564>
lea    0xa26(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0x10(%rbp),%rax
movslq -0x108(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0xfc(%rbp)
mov    -0xfc(%rbp),%eax
add    -0x100(%rbp),%eax
mov    %eax,-0x100(%rbp)
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0xfc(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     17e6 <main+0x5d6>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x108(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x108(%rbp)
jmp    1717 <main+0x507>
mov    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    %eax,%edx
mov    $0xff,%esi
call   1080 <memset@plt>
mov    -0xc4(%rbp),%eax
sub    -0x100(%rbp),%eax
mov    %eax,-0x104(%rbp)
cmpl   $0x0,-0x104(%rbp)
jge    1878 <main+0x668>
mov    0x278a(%rip),%rax
mov    (%rax),%edi
mov    -0x100(%rbp),%edx
mov    -0xc4(%rbp),%ecx
lea    0x966(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
cmpl   $0x0,-0x104(%rbp)
jle    1896 <main+0x686>
mov    -0x104(%rbp),%eax
mov    %eax,-0x14c(%rbp)
jmp    18a3 <main+0x693>
xor    %eax,%eax
mov    %eax,-0x14c(%rbp)
jmp    18a3 <main+0x693>
mov    -0x14c(%rbp),%eax
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     193c <main+0x72c>
mov    -0xe0(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    190a <main+0x6fa>
mov    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    %eax,%esi
mov    -0xe4(%rbp),%edx
mov    -0xe0(%rbp),%rcx
call   1110 <fwrite@plt>
mov    %rax,%rcx
mov    -0xfc(%rbp),%eax
sub    %rcx,%rax
mov    %eax,-0xfc(%rbp)
jmp    1937 <main+0x727>
mov    0x26bf(%rip),%rax
mov    (%rax),%edi
lea    0x900(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
jmp    18af <main+0x69f>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0x825(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    198f <main+0x77f>
lea    0x80b(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0x8ac(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x80a(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    19ec <main+0x7dc>
lea    0x7ae(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     1a39 <main+0x829>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x76a(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1a8c <main+0x87c>
lea    0x70e(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     1ad9 <main+0x8c9>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    0x6ca(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1b2c <main+0x91c>
lea    0x66e(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     1b79 <main+0x969>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0x62a(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1bcc <main+0x9bc>
lea    0x5ce(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x100(%rbp),%edx
add    -0x104(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     1c11 <main+0xa01>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1c33 <main+0xa23>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x10c(%rbp)
mov    -0xf0(%rbp),%rax
mov    %rax,%rsp
mov    -0x10c(%rbp),%eax
test   %eax,%eax
je     1c55 <main+0xa45>
jmp    1c50 <main+0xa40>
jmp    1e83 <main+0xc73>
jmp    1e6e <main+0xc5e>
cmpl   $0x5,-0x8(%rbp)
je     1c6e <main+0xa5e>
cmpl   $0x6,-0x8(%rbp)
jne    1e69 <main+0xc59>
movl   $0x1,-0x124(%rbp)
mov    -0x124(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x130(%rbp)
mov    %rax,-0x138(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0x4de(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    1cd6 <main+0xac6>
lea    0x4c4(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1e42 <main+0xc32>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0x565(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x4c3(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    1d33 <main+0xb23>
lea    0x467(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1e42 <main+0xc32>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
mov    -0x118(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x124(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     1d80 <main+0xb70>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1e42 <main+0xc32>
mov    -0x118(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x423(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    1dd3 <main+0xbc3>
lea    0x3c7(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1e42 <main+0xc32>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <stat@plt>
mov    -0x118(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x124(%rbp),%ecx
call   1130 <cat@plt>
cmp    $0x0,%rax
je     1e20 <main+0xc10>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1e42 <main+0xc32>
mov    -0x118(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x120(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x10c(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,%rsp
mov    -0x10c(%rbp),%eax
test   %eax,%eax
je     1e64 <main+0xc54>
jmp    1e5f <main+0xc4f>
jmp    1e83 <main+0xc73>
jmp    1e69 <main+0xc59>
jmp    1e6e <main+0xc5e>
lea    0x3ec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
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    $0xb8,%rsp
cmp    $0x2,%edi
jg     124e <main+0x2e>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1130 <print_usage@plt>
mov    %rsi,%r14
mov    %edi,%ebx
cmp    $0x4,%edi
jne    12af <main+0x8f>
mov    0x18(%r14),%r15
lea    0xd9d(%rip),%rdi
mov    %r15,%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
je     1314 <main+0xf4>
lea    0xdfb(%rip),%rdi
mov    %r15,%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
je     1919 <main+0x6f9>
lea    0xde2(%rip),%rdi
mov    %r15,%rsi
call   10b0 <strcmp@plt>
test   %eax,%eax
je     194e <main+0x72e>
movl   $0x0,-0x38(%rbp)
mov    $0x1,%al
mov    %eax,-0x40(%rbp)
jmp    1320 <main+0x100>
movl   $0x0,-0x38(%rbp)
mov    $0x1,%al
mov    %eax,-0x40(%rbp)
cmp    $0x5,%ebx
jb     1320 <main+0x100>
mov    0x18(%r14),%rsi
lea    0xdaa(%rip),%rdi
call   10b0 <strcmp@plt>
movl   $0x0,-0x38(%rbp)
mov    $0x0,%r15d
mov    $0x0,%r13d
mov    $0x0,%r12d
test   %eax,%eax
jne    1329 <main+0x109>
cmp    $0x8,%ebx
ja     196a <main+0x74a>
cmp    $0x6,%ebx
je     196a <main+0x74a>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
jmp    195e <main+0x73e>
movl   $0x0,-0x40(%rbp)
mov    $0x1,%al
mov    %eax,-0x38(%rbp)
xor    %r15d,%r15d
xor    %r13d,%r13d
xor    %r12d,%r12d
mov    %ebx,-0x84(%rbp)
mov    0x8(%r14),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
test   %rax,%rax
jne    1990 <main+0x770>
mov    %r15d,-0x50(%rbp)
mov    %r14,-0x48(%rbp)
mov    -0x30(%rbp),%r15d
lea    0xdd0(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13,%rdi
lea    (%r15,%r13,1),%eax
mov    -0x40(%rbp),%r8d
test   %r8b,%r8b
lea    -0x80(%rbp),%rcx
lea    -0xe0(%rbp),%r14
cmovne %rcx,%r14
mov    $0x28,%ecx
mov    $0x50,%r13d
cmovne %ecx,%r13d
lea    -0x7c(%rbp),%rcx
lea    -0xdc(%rbp),%rdx
cmovne %rcx,%rdx
movl   $0x5,(%r14)
movl   $0x3,(%rdx)
lea    -0x78(%rbp),%rcx
lea    -0xd8(%rbp),%rdx
cmovne %rcx,%rdx
movl   $0x0,(%rdx)
lea    -0x74(%rbp),%rcx
lea    -0xd4(%rbp),%rdx
cmovne %rcx,%rdx
lea    -0x70(%rbp),%rcx
lea    -0xd0(%rbp),%rsi
cmovne %rcx,%rsi
lea    (%rax,%r12,1),%ecx
movl   $0x0,(%rdx)
mov    %ecx,(%rsi)
lea    -0x6c(%rbp),%rcx
lea    -0xcc(%rbp),%rdx
cmovne %rcx,%rdx
mov    %r15d,(%rdx)
lea    -0x68(%rbp),%rcx
lea    -0xc8(%rbp),%rdx
cmovne %rcx,%rdx
mov    %r15d,(%rdx)
lea    -0x64(%rbp),%rcx
lea    -0xc4(%rbp),%rdx
cmovne %rcx,%rdx
lea    -0x60(%rbp),%rcx
lea    -0xc0(%rbp),%rsi
cmovne %rcx,%rsi
mov    %edi,(%rdx)
mov    %eax,(%rsi)
lea    -0x5c(%rbp),%rax
lea    -0xbc(%rbp),%rcx
cmovne %rax,%rcx
mov    %r12,-0x90(%rbp)
mov    %r12d,(%rcx)
cmpb   $0x0,-0x38(%rbp)
je     1526 <main+0x306>
lea    -0x58(%rbp),%rax
lea    -0xb8(%rbp),%rcx
test   %r8b,%r8b
cmovne %rax,%rcx
movl   $0x33836685,(%rcx)
lea    -0x54(%rbp),%rax
lea    -0xb4(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x1,(%rcx)
lea    -0x50(%rbp),%rax
lea    -0xb0(%rbp),%rcx
cmovne %rax,%rcx
lea    -0x4c(%rbp),%rax
lea    -0xac(%rbp),%rdx
cmovne %rax,%rdx
movl   $0x2,(%rcx)
movl   $0x0,(%rdx)
lea    -0x48(%rbp),%rax
lea    -0xa8(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x44(%rbp),%rax
lea    -0xa4(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x40(%rbp),%rax
lea    -0xa0(%rbp),%rcx
cmovne %rax,%rcx
lea    -0x3c(%rbp),%rax
lea    -0x9c(%rbp),%rdx
cmovne %rax,%rdx
movl   $0x0,(%rcx)
movl   $0x0,(%rdx)
lea    -0x38(%rbp),%rax
lea    -0x98(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x34(%rbp),%rax
lea    -0x94(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
mov    0x2a93(%rip),%rax
mov    0x2ac4(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    -0x48(%rbp),%r15
mov    0x10(%r15),%rdi
mov    0x2aa9(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10e0 <open@plt>
test   %eax,%eax
mov    -0x84(%rbp),%r12d
js     19bb <main+0x79b>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   1060 <write@plt>
cmp    %r13d,%eax
jne    19c9 <main+0x7a9>
mov    %ebx,%edi
call   10a0 <close@plt>
cmp    $0x7,%r12d
setb   %al
mov    -0x50(%rbp),%ecx
xor    $0x1,%cl
or     %al,%cl
jne    181a <main+0x5fa>
mov    %rsp,-0x50(%rbp)
mov    %rsp,%rbx
add    $0xfffffffffffffff0,%rbx
mov    %rbx,%rsp
mov    0x30(%r15),%rdi
lea    0xbcd(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %rax,-0x38(%rbp)
mov    0x30(%r15),%rsi
lea    0xbcf(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0x9,%r12d
jb     1653 <main+0x433>
mov    %r12d,%eax
mov    %rax,-0x40(%rbp)
xor    %r14d,%r14d
mov    $0x8,%r13d
nopl   0x0(%rax)
mov    (%r15,%r13,8),%rdi
lea    0xbc3(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %rax,%r12
mov    (%r15,%r13,8),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
mov    -0x30(%rbp),%r15d
mov    %r12,%rdi
mov    -0x38(%rbp),%rsi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1945 <main+0x725>
add    %r15d,%r14d
mov    %r12,%rdi
call   1070 <fclose@plt>
add    $0x1,%r13
cmp    %r13,-0x40(%rbp)
mov    -0x48(%rbp),%r15
jne    15f0 <main+0x3d0>
mov    %rbx,%r12
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0x1,%edx
call   1090 <memset@plt>
mov    -0x90(%rbp),%rcx
mov    %ecx,%ebx
sub    %r14d,%ebx
js     192b <main+0x70b>
mov    -0x38(%rbp),%r14
je     16a9 <main+0x489>
mov    %r14,%rdi
call   1050 <ferror@plt>
test   %eax,%eax
jne    199e <main+0x77e>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1120 <fwrite@plt>
sub    %eax,%ebx
jne    1680 <main+0x460>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    0x20(%r15),%rdi
lea    0xac0(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %r15,%rbx
mov    %rax,%r15
mov    0x20(%rbx),%rsi
lea    0xb6f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rbx),%rdi
lea    0xad1(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1945 <main+0x725>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    -0x48(%rbp),%rbx
mov    0x8(%rbx),%rdi
lea    0xa80(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1945 <main+0x725>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    -0x48(%rbp),%rbx
mov    0x38(%rbx),%rdi
lea    0xa2f(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %rax,%r14
mov    0x38(%rbx),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1945 <main+0x725>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    -0x48(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0x9de(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19e7 <main+0x7c7>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
mov    -0x90(%rbp),%rdx
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1945 <main+0x725>
mov    -0x50(%rbp),%r13
jmp    18f3 <main+0x6d3>
add    $0xfffffffb,%r12d
cmp    $0x1,%r12d
ja     1906 <main+0x6e6>
mov    %rsp,%r13
mov    0x20(%r15),%rdi
lea    0x946(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19f9 <main+0x7d9>
mov    %r15,%r12
mov    %rax,%r15
mov    0x20(%r12),%rsi
lea    0x9f4(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%r12),%rdi
lea    0x955(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19f9 <main+0x7d9>
mov    %rax,%rbx
mov    0x10(%r12),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1a05 <main+0x7e5>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0x8(%r12),%rdi
lea    0x906(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     19f9 <main+0x7d9>
mov    %rax,%r14
mov    0x8(%r12),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%ecx
call   1140 <cat@plt>
test   %rax,%rax
jne    1a05 <main+0x7e5>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %r13,%rsp
lea    0x954(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    1a0d <main+0x7ed>
mov    0x26b0(%rip),%rax
mov    (%rax),%edi
lea    0x6e4(%rip),%rsi
jmp    195e <main+0x73e>
mov    0x269e(%rip),%rax
mov    (%rax),%edi
lea    0x886(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    -0x50(%rbp),%rsp
jmp    1a08 <main+0x7e8>
mov    0x267b(%rip),%rax
mov    (%rax),%edi
lea    0x723(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1239 <main+0x19>
mov    0x28(%r14),%rdi
call   1110 <atoi@plt>
mov    %eax,%r12d
mov    $0x100,%r13d
mov    $0x1,%al
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
mov    $0x1,%r15b
jmp    1329 <main+0x109>
lea    0x77e(%rip),%rdi
call   1100 <perror@plt>
jmp    1a08 <main+0x7e8>
mov    0x262b(%rip),%rax
mov    (%rax),%edi
lea    0x86c(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    -0x50(%rbp),%rsp
jmp    1a08 <main+0x7e8>
lea    0x787(%rip),%rdi
call   1100 <perror@plt>
jmp    1a08 <main+0x7e8>
lea    0x798(%rip),%rdi
call   1100 <perror@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
mov    0x10(%r15),%rdi
call   1030 <unlink@plt>
jmp    1a08 <main+0x7e8>
lea    0x791(%rip),%rdi
call   1100 <perror@plt>
mov    -0x50(%rbp),%rsp
jmp    1a08 <main+0x7e8>
lea    0x77f(%rip),%rdi
call   1100 <perror@plt>
mov    %r13,%rsp
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [13 x i8] c"unified-boot\00"
@.str.1 = [12 x i8] c"secure-boot\00"
@stderr = global i32 0
@.str.2 = [102 x i8] c"ERROR: Missing arguments: [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\0A\00"
@.str.3 = [14 x i8] c"unsecure-boot\00"
@.str.4 = [44 x i8] c"ERROR: Missing arguments: outbin directory\0A\00"
@.str.5 = [104 x i8] c"ERROR: Missing argument(s): [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\0A\00"
@.str.6 = [19 x i8] c"cannot stat binary\00"
@.str.7 = [33 x i8] c"Image Destination Pointer: 0x%x\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.8 = [31 x i8] c"cannot open header for writing\00"
@.str.9 = [20 x i8] c"cannot write header\00"
@.str.10 = [3 x i8] c"wb\00"
@.str.11 = [28 x i8] c"ERROR: Occured during fopen\00"
@.str.12 = [35 x i8] c"Certificate Chain Output File: %s\0A\00"
@.str.13 = [3 x i8] c"rb\00"
@.str.14 = [89 x i8] c"ERROR: Input certificate chain (Size=%d) is larger than the maximum specified (Size=%d)\0A\00"
@.str.15 = [48 x i8] c"ERROR: Occured during certifcate chain padding\0A\00"
@.str.16 = [23 x i8] c"Image Output File: %s\0A\00"
@.str.17 = [16 x i8] c"Done execution\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [20 x i32]
%11 = alloca [10 x i32]
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i64
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32*
%29 = alloca i32*
%30 = alloca i32
%31 = alloca i8*
%32 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %12
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %37
35: ; preds = %2
%36 = call i32 (...) @print_usage()
store i32 %36, i32* %3
br label %497
37: ; preds = %2
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 4
br i1 %39, label %40, label %70
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = call i32 @strcmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %40
store i32 1, i32* %9
br label %69
47: ; preds = %40
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = call i32 @strcmp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %47
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 (...) @print_usage()
store i32 %56, i32* %3
br label %497
57: ; preds = %47
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 3
%60 = load i8*, i8** %59
%61 = call i32 @strcmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %57
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 (...) @print_usage()
store i32 %66, i32* %3
br label %497
67: ; preds = %57
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68, %46
br label %70
70: ; preds = %69, %37
%71 = load i32, i32* %4
%72 = icmp sgt i32 %71, 4
br i1 %72, label %73, label %95
73: ; preds = %70
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 3
%76 = load i8*, i8** %75
%77 = call i32 @strcmp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %76)
%78 = icmp ne i32 %77, 0
br i1 %78, label %94, label %79
79: ; preds = %73
%80 = load i32, i32* %4
%81 = icmp slt i32 %80, 9
br i1 %81, label %82, label %89
82: ; preds = %79
%83 = load i32, i32* %4
%84 = icmp ne i32 %83, 6
br i1 %84, label %85, label %89
85: ; preds = %82
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.5, i64 0, i64 0))
%88 = call i32 (...) @print_usage()
store i32 %88, i32* %3
br label %497
89: ; preds = %82, %79
store i32 1, i32* %16
store i32 256, i32* %15
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 5
%92 = load i8*, i8** %91
%93 = call i32 @atoi(i8* %92)
store i32 %93, i32* %14
br label %94
94: ; preds = %89, %73
br label %95
95: ; preds = %94, %70
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 1
%98 = load i8*, i8** %97
%99 = call i64 @stat(i8* %98, %struct.stat* %6)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %95
%102 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %497
103: ; preds = %95
%104 = load i32, i32* %9
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %103
%107 = getelementptr inbounds [20 x i32], [20 x i32]* %10, i64 0, i64 0
store i32* %107, i32** %13
store i32 80, i32* %12
br label %110
108: ; preds = %103
%109 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 0
store i32* %109, i32** %13
store i32 40, i32* %12
br label %110
110: ; preds = %108, %106
%111 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%112 = load i32, i32* %111
store i32 %112, i32* %7
store i32 0, i32* %8
%113 = load i32, i32* %8
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %113)
%115 = load i32*, i32** %13
%116 = getelementptr inbounds i32, i32* %115, i64 0
store i32 5, i32* %116
%117 = load i32*, i32** %13
%118 = getelementptr inbounds i32, i32* %117, i64 1
store i32 3, i32* %118
%119 = load i32*, i32** %13
%120 = getelementptr inbounds i32, i32* %119, i64 2
store i32 0, i32* %120
%121 = load i32, i32* %8
%122 = load i32*, i32** %13
%123 = getelementptr inbounds i32, i32* %122, i64 3
store i32 %121, i32* %123
%124 = load i32, i32* %7
%125 = load i32, i32* %14
%126 = add i32 %124, %125
%127 = load i32, i32* %15
%128 = add i32 %126, %127
%129 = load i32*, i32** %13
%130 = getelementptr inbounds i32, i32* %129, i64 4
store i32 %128, i32* %130
%131 = load i32, i32* %7
%132 = load i32*, i32** %13
%133 = getelementptr inbounds i32, i32* %132, i64 5
store i32 %131, i32* %133
%134 = load i32, i32* %8
%135 = load i32, i32* %7
%136 = add i32 %134, %135
%137 = load i32*, i32** %13
%138 = getelementptr inbounds i32, i32* %137, i64 6
store i32 %136, i32* %138
%139 = load i32, i32* %15
%140 = load i32*, i32** %13
%141 = getelementptr inbounds i32, i32* %140, i64 7
store i32 %139, i32* %141
%142 = load i32, i32* %7
%143 = load i32, i32* %8
%144 = add i32 %142, %143
%145 = load i32, i32* %15
%146 = add i32 %144, %145
%147 = load i32*, i32** %13
%148 = getelementptr inbounds i32, i32* %147, i64 8
store i32 %146, i32* %148
%149 = load i32, i32* %14
%150 = load i32*, i32** %13
%151 = getelementptr inbounds i32, i32* %150, i64 9
store i32 %149, i32* %151
%152 = load i32, i32* %9
%153 = icmp eq i32 %152, 1
br i1 %153, label %154, label %175
154: ; preds = %110
%155 = load i32*, i32** %13
%156 = getelementptr inbounds i32, i32* %155, i64 10
store i32 864249477, i32* %156
%157 = load i32*, i32** %13
%158 = getelementptr inbounds i32, i32* %157, i64 11
store i32 1, i32* %158
%159 = load i32*, i32** %13
%160 = getelementptr inbounds i32, i32* %159, i64 12
store i32 2, i32* %160
%161 = load i32*, i32** %13
%162 = getelementptr inbounds i32, i32* %161, i64 13
store i32 0, i32* %162
%163 = load i32*, i32** %13
%164 = getelementptr inbounds i32, i32* %163, i64 14
store i32 0, i32* %164
%165 = load i32*, i32** %13
%166 = getelementptr inbounds i32, i32* %165, i64 15
store i32 0, i32* %166
%167 = load i32*, i32** %13
%168 = getelementptr inbounds i32, i32* %167, i64 16
store i32 0, i32* %168
%169 = load i32*, i32** %13
%170 = getelementptr inbounds i32, i32* %169, i64 17
store i32 0, i32* %170
%171 = load i32*, i32** %13
%172 = getelementptr inbounds i32, i32* %171, i64 18
store i32 0, i32* %172
%173 = load i32*, i32** %13
%174 = getelementptr inbounds i32, i32* %173, i64 19
store i32 0, i32* %174
br label %175
175: ; preds = %154, %110
%176 = load i8**, i8*** %5
%177 = getelementptr inbounds i8*, i8** %176, i64 2
%178 = load i8*, i8** %177
%179 = load i32, i32* @O_WRONLY
%180 = load i32, i32* @O_CREAT
%181 = or i32 %179, %180
%182 = load i32, i32* @O_TRUNC
%183 = or i32 %181, %182
%184 = call i32 @open(i8* %178, i32 %183, i32 420)
store i32 %184, i32* %17
%185 = load i32, i32* %17
%186 = icmp slt i32 %185, 0
br i1 %186, label %187, label %189
187: ; preds = %175
%188 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %497
189: ; preds = %175
%190 = load i32, i32* %17
%191 = load i32*, i32** %13
%192 = load i32, i32* %12
%193 = call i32 @write(i32 %190, i32* %191, i32 %192)
%194 = load i32, i32* %12
%195 = icmp ne i32 %193, %194
br i1 %195, label %196, label %204
196: ; preds = %189
%197 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%198 = load i32, i32* %17
%199 = call i32 @close(i32 %198)
%200 = load i8**, i8*** %5
%201 = getelementptr inbounds i8*, i8** %200, i64 2
%202 = load i8*, i8** %201
%203 = call i32 @unlink(i8* %202)
store i32 -1, i32* %3
br label %497
204: ; preds = %189
%205 = load i32, i32* %17
%206 = call i32 @close(i32 %205)
%207 = load i32, i32* %16
%208 = icmp ne i32 %207, 0
br i1 %208, label %209, label %419
209: ; preds = %204
%210 = load i32, i32* %4
%211 = icmp sgt i32 %210, 6
br i1 %211, label %212, label %419
212: ; preds = %209
store i32 1, i32* %20
%213 = load i32, i32* %20
%214 = zext i32 %213 to i64
%215 = call i8* @llvm.stacksave()
store i8* %215, i8** %21
%216 = alloca i8, i64 %214
store i64 %214, i64* %22
store i32 0, i32* %24
store i32 0, i32* %25
%217 = load i8**, i8*** %5
%218 = getelementptr inbounds i8*, i8** %217, i64 6
%219 = load i8*, i8** %218
%220 = call i32* @fopen(i8* %219, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i32* %220, i32** %19
%221 = icmp eq i32* %220, null
br i1 %221, label %222, label %224
222: ; preds = %212
%223 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
224: ; preds = %212
%225 = load i8**, i8*** %5
%226 = getelementptr inbounds i8*, i8** %225, i64 6
%227 = load i8*, i8** %226
%228 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0), i8* %227)
store i32 8, i32* %26
br label %229
229: ; preds = %265, %224
%230 = load i32, i32* %26
%231 = load i32, i32* %4
%232 = icmp slt i32 %230, %231
br i1 %232, label %233, label %268
233: ; preds = %229
%234 = load i8**, i8*** %5
%235 = load i32, i32* %26
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds i8*, i8** %234, i64 %236
%238 = load i8*, i8** %237
%239 = call i32* @fopen(i8* %238, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %239, i32** %18
%240 = icmp eq i32* %239, null
br i1 %240, label %241, label %243
241: ; preds = %233
%242 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
243: ; preds = %233
%244 = load i8**, i8*** %5
%245 = load i32, i32* %26
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds i8*, i8** %244, i64 %246
%248 = load i8*, i8** %247
%249 = call i64 @stat(i8* %248, %struct.stat* %6)
%250 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%251 = load i32, i32* %250
store i32 %251, i32* %23
%252 = load i32, i32* %23
%253 = load i32, i32* %24
%254 = add i32 %253, %252
store i32 %254, i32* %24
%255 = load i32*, i32** %18
%256 = load i32*, i32** %19
%257 = load i32, i32* %23
%258 = load i32, i32* %20
%259 = call i64 @cat(i32* %255, i32* %256, i32 %257, i32 %258)
%260 = icmp ne i64 %259, 0
br i1 %260, label %261, label %262
261: ; preds = %243
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
262: ; preds = %243
%263 = load i32*, i32** %18
%264 = call i32 @fclose(i32* %263)
br label %265
265: ; preds = %262
%266 = load i32, i32* %26
%267 = add nsw i32 %266, 1
store i32 %267, i32* %26
br label %229
268: ; preds = %229
%269 = trunc i64 %214 to i32
%270 = call i32 @memset(i8* %216, i32 255, i32 %269)
%271 = load i32, i32* %14
%272 = load i32, i32* %24
%273 = sub i32 %271, %272
store i32 %273, i32* %25
%274 = load i32, i32* %25
%275 = icmp slt i32 %274, 0
br i1 %275, label %276, label %281
276: ; preds = %268
%277 = load i32, i32* @stderr
%278 = load i32, i32* %24
%279 = load i32, i32* %14
%280 = call i32 (i32, i8*, ...) @fprintf(i32 %277, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.14, i64 0, i64 0), i32 %278, i32 %279)
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
281: ; preds = %268
%282 = load i32, i32* %25
%283 = icmp sgt i32 %282, 0
br i1 %283, label %284, label %286
284: ; preds = %281
%285 = load i32, i32* %25
br label %287
286: ; preds = %281
br label %287
287: ; preds = %286, %284
%288 = phi i32 [ %285, %284 ], [ 0, %286 ]
store i32 %288, i32* %23
br label %289
289: ; preds = %308, %287
%290 = load i32, i32* %23
%291 = icmp ne i32 %290, 0
br i1 %291, label %292, label %309
292: ; preds = %289
%293 = load i32*, i32** %19
%294 = call i32 @ferror(i32* %293)
%295 = icmp ne i32 %294, 0
br i1 %295, label %305, label %296
296: ; preds = %292
%297 = trunc i64 %214 to i32
%298 = load i32, i32* %20
%299 = load i32*, i32** %19
%300 = call i64 @fwrite(i8* %216, i32 %297, i32 %298, i32* %299)
%301 = load i32, i32* %23
%302 = zext i32 %301 to i64
%303 = sub nsw i64 %302, %300
%304 = trunc i64 %303 to i32
store i32 %304, i32* %23
br label %308
305: ; preds = %292
%306 = load i32, i32* @stderr
%307 = call i32 (i32, i8*, ...) @fprintf(i32 %306, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
308: ; preds = %296
br label %289
309: ; preds = %289
%310 = load i32*, i32** %19
%311 = call i32 @fclose(i32* %310)
%312 = load i8**, i8*** %5
%313 = getelementptr inbounds i8*, i8** %312, i64 4
%314 = load i8*, i8** %313
%315 = call i32* @fopen(i8* %314, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i32* %315, i32** %19
%316 = icmp eq i32* %315, null
br i1 %316, label %317, label %319
317: ; preds = %309
%318 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
319: ; preds = %309
%320 = load i8**, i8*** %5
%321 = getelementptr inbounds i8*, i8** %320, i64 4
%322 = load i8*, i8** %321
%323 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i8* %322)
%324 = load i8**, i8*** %5
%325 = getelementptr inbounds i8*, i8** %324, i64 2
%326 = load i8*, i8** %325
%327 = call i32* @fopen(i8* %326, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %327, i32** %18
%328 = icmp eq i32* %327, null
br i1 %328, label %329, label %331
329: ; preds = %319
%330 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
331: ; preds = %319
%332 = load i8**, i8*** %5
%333 = getelementptr inbounds i8*, i8** %332, i64 2
%334 = load i8*, i8** %333
%335 = call i64 @stat(i8* %334, %struct.stat* %6)
%336 = load i32*, i32** %18
%337 = load i32*, i32** %19
%338 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%339 = load i32, i32* %338
%340 = load i32, i32* %20
%341 = call i64 @cat(i32* %336, i32* %337, i32 %339, i32 %340)
%342 = icmp ne i64 %341, 0
br i1 %342, label %343, label %344
343: ; preds = %331
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
344: ; preds = %331
%345 = load i32*, i32** %18
%346 = call i32 @fclose(i32* %345)
%347 = load i8**, i8*** %5
%348 = getelementptr inbounds i8*, i8** %347, i64 1
%349 = load i8*, i8** %348
%350 = call i32* @fopen(i8* %349, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %350, i32** %18
%351 = icmp eq i32* %350, null
br i1 %351, label %352, label %354
352: ; preds = %344
%353 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
354: ; preds = %344
%355 = load i8**, i8*** %5
%356 = getelementptr inbounds i8*, i8** %355, i64 1
%357 = load i8*, i8** %356
%358 = call i64 @stat(i8* %357, %struct.stat* %6)
%359 = load i32*, i32** %18
%360 = load i32*, i32** %19
%361 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%362 = load i32, i32* %361
%363 = load i32, i32* %20
%364 = call i64 @cat(i32* %359, i32* %360, i32 %362, i32 %363)
%365 = icmp ne i64 %364, 0
br i1 %365, label %366, label %367
366: ; preds = %354
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
367: ; preds = %354
%368 = load i32*, i32** %18
%369 = call i32 @fclose(i32* %368)
%370 = load i8**, i8*** %5
%371 = getelementptr inbounds i8*, i8** %370, i64 7
%372 = load i8*, i8** %371
%373 = call i32* @fopen(i8* %372, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %373, i32** %18
%374 = icmp eq i32* %373, null
br i1 %374, label %375, label %377
375: ; preds = %367
%376 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
377: ; preds = %367
%378 = load i8**, i8*** %5
%379 = getelementptr inbounds i8*, i8** %378, i64 7
%380 = load i8*, i8** %379
%381 = call i64 @stat(i8* %380, %struct.stat* %6)
%382 = load i32*, i32** %18
%383 = load i32*, i32** %19
%384 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%385 = load i32, i32* %384
%386 = load i32, i32* %20
%387 = call i64 @cat(i32* %382, i32* %383, i32 %385, i32 %386)
%388 = icmp ne i64 %387, 0
br i1 %388, label %389, label %390
389: ; preds = %377
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
390: ; preds = %377
%391 = load i32*, i32** %18
%392 = call i32 @fclose(i32* %391)
%393 = load i8**, i8*** %5
%394 = getelementptr inbounds i8*, i8** %393, i64 6
%395 = load i8*, i8** %394
%396 = call i32* @fopen(i8* %395, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %396, i32** %18
%397 = icmp eq i32* %396, null
br i1 %397, label %398, label %400
398: ; preds = %390
%399 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
400: ; preds = %390
%401 = load i32*, i32** %18
%402 = load i32*, i32** %19
%403 = load i32, i32* %24
%404 = load i32, i32* %25
%405 = add i32 %403, %404
%406 = load i32, i32* %20
%407 = call i64 @cat(i32* %401, i32* %402, i32 %405, i32 %406)
%408 = icmp ne i64 %407, 0
br i1 %408, label %409, label %410
409: ; preds = %400
store i32 -1, i32* %3
store i32 1, i32* %27
br label %415
410: ; preds = %400
%411 = load i32*, i32** %18
%412 = call i32 @fclose(i32* %411)
%413 = load i32*, i32** %19
%414 = call i32 @fclose(i32* %413)
store i32 0, i32* %27
br label %415
415: ; preds = %410, %409, %398, %389, %375, %366, %352, %343, %329, %317, %305, %276, %261, %241, %222
%416 = load i8*, i8** %21
%417 = load i32, i32* %27
switch i32 %417, label %499 [
i32 0, label %418
i32 1, label %497
]
418: ; preds = %415
br label %495
419: ; preds = %209, %204
%420 = load i32, i32* %4
%421 = icmp eq i32 %420, 5
br i1 %421, label %425, label %422
422: ; preds = %419
%423 = load i32, i32* %4
%424 = icmp eq i32 %423, 6
br i1 %424, label %425, label %494
425: ; preds = %422, %419
store i32 1, i32* %30
%426 = load i32, i32* %30
%427 = zext i32 %426 to i64
%428 = call i8* @llvm.stacksave()
store i8* %428, i8** %31
%429 = alloca i8, i64 %427
store i64 %427, i64* %32
%430 = load i8**, i8*** %5
%431 = getelementptr inbounds i8*, i8** %430, i64 4
%432 = load i8*, i8** %431
%433 = call i32* @fopen(i8* %432, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i32* %433, i32** %29
%434 = icmp eq i32* %433, null
br i1 %434, label %435, label %437
435: ; preds = %425
%436 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %490
437: ; preds = %425
%438 = load i8**, i8*** %5
%439 = getelementptr inbounds i8*, i8** %438, i64 4
%440 = load i8*, i8** %439
%441 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i8* %440)
%442 = load i8**, i8*** %5
%443 = getelementptr inbounds i8*, i8** %442, i64 2
%444 = load i8*, i8** %443
%445 = call i32* @fopen(i8* %444, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %445, i32** %28
%446 = icmp eq i32* %445, null
br i1 %446, label %447, label %449
447: ; preds = %437
%448 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %490
449: ; preds = %437
%450 = load i8**, i8*** %5
%451 = getelementptr inbounds i8*, i8** %450, i64 2
%452 = load i8*, i8** %451
%453 = call i64 @stat(i8* %452, %struct.stat* %6)
%454 = load i32*, i32** %28
%455 = load i32*, i32** %29
%456 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%457 = load i32, i32* %456
%458 = load i32, i32* %30
%459 = call i64 @cat(i32* %454, i32* %455, i32 %457, i32 %458)
%460 = icmp ne i64 %459, 0
br i1 %460, label %461, label %462
461: ; preds = %449
store i32 -1, i32* %3
store i32 1, i32* %27
br label %490
462: ; preds = %449
%463 = load i32*, i32** %28
%464 = call i32 @fclose(i32* %463)
%465 = load i8**, i8*** %5
%466 = getelementptr inbounds i8*, i8** %465, i64 1
%467 = load i8*, i8** %466
%468 = call i32* @fopen(i8* %467, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %468, i32** %28
%469 = icmp eq i32* %468, null
br i1 %469, label %470, label %472
470: ; preds = %462
%471 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %27
br label %490
472: ; preds = %462
%473 = load i8**, i8*** %5
%474 = getelementptr inbounds i8*, i8** %473, i64 1
%475 = load i8*, i8** %474
%476 = call i64 @stat(i8* %475, %struct.stat* %6)
%477 = load i32*, i32** %28
%478 = load i32*, i32** %29
%479 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%480 = load i32, i32* %479
%481 = load i32, i32* %30
%482 = call i64 @cat(i32* %477, i32* %478, i32 %480, i32 %481)
%483 = icmp ne i64 %482, 0
br i1 %483, label %484, label %485
484: ; preds = %472
store i32 -1, i32* %3
store i32 1, i32* %27
br label %490
485: ; preds = %472
%486 = load i32*, i32** %28
%487 = call i32 @fclose(i32* %486)
%488 = load i32*, i32** %29
%489 = call i32 @fclose(i32* %488)
store i32 0, i32* %27
br label %490
490: ; preds = %485, %484, %470, %461, %447, %435
%491 = load i8*, i8** %31
%492 = load i32, i32* %27
switch i32 %492, label %499 [
i32 0, label %493
i32 1, label %497
]
493: ; preds = %490
br label %494
494: ; preds = %493, %422
br label %495
495: ; preds = %494, %418
%496 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %3
br label %497
497: ; preds = %495, %490, %415, %196, %187, %101, %85, %63, %53, %35
%498 = load i32, i32* %3
ret i32 %498
499: ; preds = %490, %415
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [13 x i8] c"unified-boot\00"
@.str.1 = [12 x i8] c"secure-boot\00"
@stderr = global i32 0
@.str.2 = [102 x i8] c"ERROR: Missing arguments: [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\0A\00"
@.str.3 = [14 x i8] c"unsecure-boot\00"
@.str.4 = [44 x i8] c"ERROR: Missing arguments: outbin directory\0A\00"
@.str.5 = [104 x i8] c"ERROR: Missing argument(s): [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\0A\00"
@.str.6 = [19 x i8] c"cannot stat binary\00"
@.str.7 = [33 x i8] c"Image Destination Pointer: 0x%x\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.8 = [31 x i8] c"cannot open header for writing\00"
@.str.9 = [20 x i8] c"cannot write header\00"
@.str.10 = [3 x i8] c"wb\00"
@.str.11 = [28 x i8] c"ERROR: Occured during fopen\00"
@.str.12 = [35 x i8] c"Certificate Chain Output File: %s\0A\00"
@.str.13 = [3 x i8] c"rb\00"
@.str.14 = [89 x i8] c"ERROR: Input certificate chain (Size=%d) is larger than the maximum specified (Size=%d)\0A\00"
@.str.15 = [48 x i8] c"ERROR: Occured during certifcate chain padding\0A\00"
@.str.16 = [23 x i8] c"Image Output File: %s\0A\00"
@str = [15 x i8] c"Done execution\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [20 x i32]
%5 = alloca [10 x i32]
%6 = bitcast %struct.stat* %3 to i8*
%7 = bitcast [20 x i32]* %4 to i8*
%8 = bitcast [10 x i32]* %5 to i8*
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @print_usage()
br label %316
12: ; preds = %2
%13 = icmp eq i32 %0, 4
br i1 %13, label %14, label %33
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @strcmp(i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %52, label %19
19: ; preds = %14
%20 = tail call i32 @strcmp(i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %16)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 (...) @print_usage()
br label %316
26: ; preds = %19
%27 = tail call i32 @strcmp(i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %16)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %52
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%32 = tail call i32 (...) @print_usage()
br label %316
33: ; preds = %12
%34 = icmp ugt i32 %0, 4
br i1 %34, label %35, label %52
35: ; preds = %33
%36 = getelementptr inbounds i8*, i8** %1, i64 3
%37 = load i8*, i8** %36
%38 = tail call i32 @strcmp(i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %37)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %52
40: ; preds = %35
%41 = icmp ult i32 %0, 9
%42 = icmp ne i32 %0, 6
%43 = and i1 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.5, i64 0, i64 0))
%47 = tail call i32 (...) @print_usage()
br label %316
48: ; preds = %40
%49 = getelementptr inbounds i8*, i8** %1, i64 5
%50 = load i8*, i8** %49
%51 = tail call i32 @atoi(i8* %50)
br label %52
52: ; preds = %26, %14, %35, %48, %33
%53 = phi i1 [ false, %35 ], [ false, %48 ], [ false, %33 ], [ true, %14 ], [ false, %26 ]
%54 = phi i1 [ true, %35 ], [ true, %48 ], [ true, %33 ], [ false, %14 ], [ true, %26 ]
%55 = phi i1 [ false, %35 ], [ true, %48 ], [ false, %33 ], [ false, %14 ], [ false, %26 ]
%56 = phi i32 [ 0, %35 ], [ 256, %48 ], [ 0, %33 ], [ 0, %14 ], [ 0, %26 ]
%57 = phi i32 [ 0, %35 ], [ %51, %48 ], [ 0, %33 ], [ 0, %14 ], [ 0, %26 ]
%58 = getelementptr inbounds i8*, i8** %1, i64 1
%59 = load i8*, i8** %58
%60 = call i64 @stat(i8* %59, %struct.stat* %3)
%61 = icmp eq i64 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %52
%63 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %316
64: ; preds = %52
%65 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%67 = select i1 %54, i32* %66, i32* %65
%68 = select i1 %54, i32 40, i32 80
%69 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%70 = load i32, i32* %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 0)
store i32 5, i32* %67
%72 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 1
%73 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 1
%74 = select i1 %54, i32* %72, i32* %73
store i32 3, i32* %74
%75 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 2
%76 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 2
%77 = select i1 %54, i32* %75, i32* %76
store i32 0, i32* %77
%78 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 3
%79 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 3
%80 = select i1 %54, i32* %78, i32* %79
store i32 0, i32* %80
%81 = add i32 %70, %56
%82 = add i32 %81, %57
%83 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 4
%84 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 4
%85 = select i1 %54, i32* %83, i32* %84
store i32 %82, i32* %85
%86 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 5
%87 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 5
%88 = select i1 %54, i32* %86, i32* %87
store i32 %70, i32* %88
%89 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 6
%90 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 6
%91 = select i1 %54, i32* %89, i32* %90
store i32 %70, i32* %91
%92 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 7
%93 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 7
%94 = select i1 %54, i32* %92, i32* %93
store i32 %56, i32* %94
%95 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 8
%96 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 8
%97 = select i1 %54, i32* %95, i32* %96
store i32 %81, i32* %97
%98 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 9
%99 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 9
%100 = select i1 %54, i32* %98, i32* %99
store i32 %57, i32* %100
br i1 %53, label %101, label %132
101: ; preds = %64
%102 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 10
%103 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 10
%104 = select i1 %54, i32* %102, i32* %103
store i32 864249477, i32* %104
%105 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 11
%106 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 11
%107 = select i1 %54, i32* %105, i32* %106
store i32 1, i32* %107
%108 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 12
%109 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 12
%110 = select i1 %54, i32* %108, i32* %109
store i32 2, i32* %110
%111 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 13
%112 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 13
%113 = select i1 %54, i32* %111, i32* %112
store i32 0, i32* %113
%114 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 14
%115 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 14
%116 = select i1 %54, i32* %114, i32* %115
store i32 0, i32* %116
%117 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 15
%118 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 15
%119 = select i1 %54, i32* %117, i32* %118
store i32 0, i32* %119
%120 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 16
%121 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 16
%122 = select i1 %54, i32* %120, i32* %121
store i32 0, i32* %122
%123 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 17
%124 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 17
%125 = select i1 %54, i32* %123, i32* %124
store i32 0, i32* %125
%126 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 18
%127 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 18
%128 = select i1 %54, i32* %126, i32* %127
store i32 0, i32* %128
%129 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 19
%130 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 19
%131 = select i1 %54, i32* %129, i32* %130
store i32 0, i32* %131
br label %132
132: ; preds = %101, %64
%133 = getelementptr inbounds i8*, i8** %1, i64 2
%134 = load i8*, i8** %133
%135 = load i32, i32* @O_WRONLY
%136 = load i32, i32* @O_CREAT
%137 = or i32 %136, %135
%138 = load i32, i32* @O_TRUNC
%139 = or i32 %137, %138
%140 = call i32 @open(i8* %134, i32 %139, i32 420)
%141 = icmp slt i32 %140, 0
br i1 %141, label %142, label %144
142: ; preds = %132
%143 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %316
144: ; preds = %132
%145 = call i32 @write(i32 %140, i32* %67, i32 %68)
%146 = icmp eq i32 %145, %68
br i1 %146, label %152, label %147
147: ; preds = %144
%148 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%149 = call i32 @close(i32 %140)
%150 = load i8*, i8** %133
%151 = call i32 @unlink(i8* %150)
br label %316
152: ; preds = %144
%153 = call i32 @close(i32 %140)
%154 = icmp ugt i32 %0, 6
%155 = and i1 %154, %55
br i1 %155, label %156, label %273
156: ; preds = %152
%157 = call i8* @llvm.stacksave()
%158 = alloca i8
%159 = getelementptr inbounds i8*, i8** %1, i64 6
%160 = load i8*, i8** %159
%161 = call i32* @fopen(i8* %160, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%162 = icmp eq i32* %161, null
br i1 %162, label %163, label %165
163: ; preds = %156
%164 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
165: ; preds = %156
%166 = load i8*, i8** %159
%167 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0), i8* %166)
%168 = icmp ugt i32 %0, 8
br i1 %168, label %169, label %191
169: ; preds = %165
%170 = zext i32 %0 to i64
br label %171
171: ; preds = %169, %186
%172 = phi i64 [ 8, %169 ], [ %189, %186 ]
%173 = phi i32 [ 0, %169 ], [ %187, %186 ]
%174 = getelementptr inbounds i8*, i8** %1, i64 %172
%175 = load i8*, i8** %174
%176 = call i32* @fopen(i8* %175, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%177 = icmp eq i32* %176, null
br i1 %177, label %178, label %180
178: ; preds = %171
%179 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
180: ; preds = %171
%181 = load i8*, i8** %174
%182 = call i64 @stat(i8* %181, %struct.stat* %3)
%183 = load i32, i32* %69
%184 = call i64 @cat(i32* %176, i32* %161, i32 %183, i32 1)
%185 = icmp eq i64 %184, 0
br i1 %185, label %186, label %272
186: ; preds = %180
%187 = add i32 %183, %173
%188 = call i32 @fclose(i32* %176)
%189 = add nuw nsw i64 %172, 1
%190 = icmp eq i64 %189, %170
br i1 %190, label %191, label %171
191: ; preds = %186, %165
%192 = phi i32 [ 0, %165 ], [ %187, %186 ]
%193 = call i32 @memset(i8* %158, i32 255, i32 1)
%194 = sub i32 %57, %192
%195 = icmp slt i32 %194, 0
br i1 %195, label %198, label %196
196: ; preds = %191
%197 = icmp eq i32 %194, 0
br i1 %197, label %213, label %201
198: ; preds = %191
%199 = load i32, i32* @stderr
%200 = call i32 (i32, i8*, ...) @fprintf(i32 %199, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.14, i64 0, i64 0), i32 %192, i32 %57)
br label %272
201: ; preds = %196, %205
%202 = phi i32 [ %208, %205 ], [ %194, %196 ]
%203 = call i32 @ferror(i32* %161)
%204 = icmp eq i32 %203, 0
br i1 %204, label %205, label %210
205: ; preds = %201
%206 = call i64 @fwrite(i8* %158, i32 1, i32 1, i32* %161)
%207 = trunc i64 %206 to i32
%208 = sub i32 %202, %207
%209 = icmp eq i32 %208, 0
br i1 %209, label %213, label %201
210: ; preds = %201
%211 = load i32, i32* @stderr
%212 = call i32 (i32, i8*, ...) @fprintf(i32 %211, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.15, i64 0, i64 0))
br label %272
213: ; preds = %205, %196
%214 = call i32 @fclose(i32* %161)
%215 = getelementptr inbounds i8*, i8** %1, i64 4
%216 = load i8*, i8** %215
%217 = call i32* @fopen(i8* %216, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%218 = icmp eq i32* %217, null
br i1 %218, label %219, label %221
219: ; preds = %213
%220 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
221: ; preds = %213
%222 = load i8*, i8** %215
%223 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i8* %222)
%224 = load i8*, i8** %133
%225 = call i32* @fopen(i8* %224, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%226 = icmp eq i32* %225, null
br i1 %226, label %227, label %229
227: ; preds = %221
%228 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
229: ; preds = %221
%230 = load i8*, i8** %133
%231 = call i64 @stat(i8* %230, %struct.stat* %3)
%232 = load i32, i32* %69
%233 = call i64 @cat(i32* %225, i32* %217, i32 %232, i32 1)
%234 = icmp eq i64 %233, 0
br i1 %234, label %235, label %272
235: ; preds = %229
%236 = call i32 @fclose(i32* %225)
%237 = load i8*, i8** %58
%238 = call i32* @fopen(i8* %237, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%239 = icmp eq i32* %238, null
br i1 %239, label %240, label %242
240: ; preds = %235
%241 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
242: ; preds = %235
%243 = load i8*, i8** %58
%244 = call i64 @stat(i8* %243, %struct.stat* %3)
%245 = load i32, i32* %69
%246 = call i64 @cat(i32* %238, i32* %217, i32 %245, i32 1)
%247 = icmp eq i64 %246, 0
br i1 %247, label %248, label %272
248: ; preds = %242
%249 = call i32 @fclose(i32* %238)
%250 = getelementptr inbounds i8*, i8** %1, i64 7
%251 = load i8*, i8** %250
%252 = call i32* @fopen(i8* %251, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%253 = icmp eq i32* %252, null
br i1 %253, label %254, label %256
254: ; preds = %248
%255 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
256: ; preds = %248
%257 = load i8*, i8** %250
%258 = call i64 @stat(i8* %257, %struct.stat* %3)
%259 = load i32, i32* %69
%260 = call i64 @cat(i32* %252, i32* %217, i32 %259, i32 1)
%261 = icmp eq i64 %260, 0
br i1 %261, label %262, label %272
262: ; preds = %256
%263 = call i32 @fclose(i32* %252)
%264 = load i8*, i8** %159
%265 = call i32* @fopen(i8* %264, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%266 = icmp eq i32* %265, null
br i1 %266, label %267, label %269
267: ; preds = %262
%268 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %272
269: ; preds = %262
%270 = call i64 @cat(i32* %265, i32* %217, i32 %57, i32 1)
%271 = icmp eq i64 %270, 0
br i1 %271, label %308, label %272
272: ; preds = %180, %267, %254, %240, %227, %219, %210, %198, %178, %163, %229, %242, %256, %269
br label %316
273: ; preds = %152
%274 = add nsw i32 %0, -5
%275 = icmp ult i32 %274, 2
br i1 %275, label %276, label %314
276: ; preds = %273
%277 = call i8* @llvm.stacksave()
%278 = getelementptr inbounds i8*, i8** %1, i64 4
%279 = load i8*, i8** %278
%280 = call i32* @fopen(i8* %279, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%281 = icmp eq i32* %280, null
br i1 %281, label %305, label %282
282: ; preds = %276
%283 = load i8*, i8** %278
%284 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i8* %283)
%285 = load i8*, i8** %133
%286 = call i32* @fopen(i8* %285, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%287 = icmp eq i32* %286, null
br i1 %287, label %305, label %288
288: ; preds = %282
%289 = load i8*, i8** %133
%290 = call i64 @stat(i8* %289, %struct.stat* %3)
%291 = load i32, i32* %69
%292 = call i64 @cat(i32* %286, i32* %280, i32 %291, i32 1)
%293 = icmp eq i64 %292, 0
br i1 %293, label %294, label %307
294: ; preds = %288
%295 = call i32 @fclose(i32* %286)
%296 = load i8*, i8** %58
%297 = call i32* @fopen(i8* %296, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%298 = icmp eq i32* %297, null
br i1 %298, label %305, label %299
299: ; preds = %294
%300 = load i8*, i8** %58
%301 = call i64 @stat(i8* %300, %struct.stat* %3)
%302 = load i32, i32* %69
%303 = call i64 @cat(i32* %297, i32* %280, i32 %302, i32 1)
%304 = icmp eq i64 %303, 0
br i1 %304, label %308, label %307
305: ; preds = %294, %282, %276
%306 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0))
br label %307
307: ; preds = %305, %288, %299
br label %316
308: ; preds = %299, %269
%309 = phi i32* [ %265, %269 ], [ %297, %299 ]
%310 = phi i32* [ %217, %269 ], [ %280, %299 ]
%311 = phi i8* [ %157, %269 ], [ %277, %299 ]
%312 = call i32 @fclose(i32* %309)
%313 = call i32 @fclose(i32* %310)
br label %314
314: ; preds = %308, %273
%315 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %316
316: ; preds = %307, %272, %314, %147, %142, %62, %44, %29, %22, %10
%317 = phi i32 [ %11, %10 ], [ -1, %62 ], [ -1, %142 ], [ -1, %147 ], [ 0, %314 ], [ %47, %44 ], [ %32, %29 ], [ %25, %22 ], [ -1, %272 ], [ -1, %307 ]
ret i32 %317
}