#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;
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();
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 emmc = 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 != 7) {
        fprintf(stderr,
                "ERROR: Missing argument(s): [outbin maxsize] | [outbin, "
                "maxsize, certchain, signature + certifcate(s)]\n");
        return print_usage();
      }
      if (argc == 7 && atoi(argv[6]) == 1) {
        emmc = 1;
      }
      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 || emmc) {
    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;
  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 || emmc == 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 > 7) {
    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;
    }
    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;
    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;
    }
    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 == 7) {
    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;
    }
    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);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%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)
movl   $0x0,-0xd0(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    126b <main+0x6b>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1d72 <main+0xb72>
cmpl   $0x4,-0x8(%rbp)
jne    132f <main+0x12f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd7c(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    129e <main+0x9e>
movl   $0x1,-0x24(%rbp)
jmp    132a <main+0x12a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdc8(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12df <main+0xdf>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1d72 <main+0xb72>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd85(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1320 <main+0x120>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xd75(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1d72 <main+0xb72>
jmp    1325 <main+0x125>
jmp    132a <main+0x12a>
jmp    132f <main+0x12f>
cmpl   $0x4,-0x8(%rbp)
jle    13e4 <main+0x1e4>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd2d(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    13df <main+0x1df>
cmpl   $0x9,-0x8(%rbp)
jge    138e <main+0x18e>
cmpl   $0x7,-0x8(%rbp)
je     138e <main+0x18e>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1d72 <main+0xb72>
cmpl   $0x7,-0x8(%rbp)
jne    13b8 <main+0x1b8>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   10f0 <atoi@plt>
cmp    $0x1,%eax
jne    13b8 <main+0x1b8>
movl   $0x1,-0xd0(%rbp)
movl   $0x1,-0xcc(%rbp)
movl   $0x100,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0xc4(%rbp)
jmp    13e4 <main+0x1e4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%rax
je     1417 <main+0x217>
lea    0xd0f(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1d72 <main+0xb72>
cmpl   $0x0,-0x24(%rbp)
jne    142e <main+0x22e>
cmpl   $0x0,-0xd0(%rbp)
je     1448 <main+0x248>
lea    -0x80(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x50,-0xb4(%rbp)
jmp    1460 <main+0x260>
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    -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)
je     1526 <main+0x326>
cmpl   $0x1,-0xd0(%rbp)
jne    15b2 <main+0x3b2>
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    0x29ff(%rip),%rax
mov    (%rax),%esi
mov    0x2a2e(%rip),%rax
or     (%rax),%esi
mov    0x2a1d(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10c0 <open@plt>
mov    %eax,-0xd4(%rbp)
cmpl   $0x0,-0xd4(%rbp)
jge    160a <main+0x40a>
lea    0xb2f(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1d72 <main+0xb72>
mov    -0xd4(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1050 <write@plt>
cmp    -0xb4(%rbp),%eax
je     165e <main+0x45e>
lea    0xb12(%rip),%rdi
call   10e0 <perror@plt>
mov    -0xd4(%rbp),%edi
call   1080 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1d72 <main+0xb72>
mov    -0xd4(%rbp),%edi
call   1080 <close@plt>
cmpl   $0x0,-0xcc(%rbp)
je     1b6d <main+0x96d>
cmpl   $0x7,-0x8(%rbp)
jle    1b6d <main+0x96d>
movl   $0x1,-0xec(%rbp)
mov    -0xec(%rbp),%eax
mov    %rax,-0x150(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xf8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x148(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x100(%rbp)
movl   $0x0,-0x108(%rbp)
movl   $0x0,-0x10c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0xa75(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe8(%rbp)
cmp    $0x0,%rax
jne    171e <main+0x51e>
lea    0xa5b(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
movl   $0x8,-0x110(%rbp)
mov    -0x110(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1817 <main+0x617>
mov    -0x10(%rbp),%rax
movslq -0x110(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xa2d(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    1785 <main+0x585>
lea    0x9f4(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0x10(%rbp),%rax
movslq -0x110(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x104(%rbp)
mov    -0x104(%rbp),%eax
add    -0x108(%rbp),%eax
mov    %eax,-0x108(%rbp)
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
mov    -0x104(%rbp),%edx
mov    -0xec(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     17f7 <main+0x5f7>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x110(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110(%rbp)
jmp    1728 <main+0x528>
mov    -0x148(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    %eax,%edx
mov    $0xff,%esi
call   1070 <memset@plt>
mov    -0xc4(%rbp),%eax
sub    -0x108(%rbp),%eax
mov    %eax,-0x10c(%rbp)
cmpl   $0x0,-0x10c(%rbp)
jle    1861 <main+0x661>
mov    -0x10c(%rbp),%eax
mov    %eax,-0x154(%rbp)
jmp    186e <main+0x66e>
xor    %eax,%eax
mov    %eax,-0x154(%rbp)
jmp    186e <main+0x66e>
mov    -0x154(%rbp),%eax
mov    %eax,-0x104(%rbp)
cmpl   $0x0,-0x104(%rbp)
je     1905 <main+0x705>
mov    -0xe8(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    18d5 <main+0x6d5>
mov    -0x148(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    %eax,%esi
mov    -0xec(%rbp),%edx
mov    -0xe8(%rbp),%rcx
call   1100 <fwrite@plt>
mov    %rax,%rcx
mov    -0x104(%rbp),%eax
sub    %rcx,%rax
mov    %eax,-0x104(%rbp)
jmp    1900 <main+0x700>
mov    0x26f4(%rip),%rax
mov    (%rax),%edi
lea    0x898(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
jmp    187a <main+0x67a>
mov    -0xe8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0x83b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe8(%rbp)
cmp    $0x0,%rax
jne    1958 <main+0x758>
lea    0x821(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x813(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    199f <main+0x79f>
lea    0x7da(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xec(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     19ec <main+0x7ec>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    0x773(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    1a3f <main+0x83f>
lea    0x73a(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xec(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1a8c <main+0x88c>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0x6d3(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    1adf <main+0x8df>
lea    0x69a(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
mov    -0x108(%rbp),%edx
add    -0x10c(%rbp),%edx
mov    -0xec(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1b24 <main+0x924>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1b46 <main+0x946>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xe8(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x114(%rbp)
mov    -0xf8(%rbp),%rax
mov    %rax,%rsp
mov    -0x114(%rbp),%eax
test   %eax,%eax
je     1b68 <main+0x968>
jmp    1b63 <main+0x963>
jmp    1d72 <main+0xb72>
jmp    1d6b <main+0xb6b>
cmpl   $0x5,-0x8(%rbp)
je     1b81 <main+0x981>
cmpl   $0x7,-0x8(%rbp)
jne    1d66 <main+0xb66>
movl   $0x1,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x138(%rbp)
mov    %rax,-0x140(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0x5aa(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    1be9 <main+0x9e9>
lea    0x590(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1d3f <main+0xb3f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x582(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    1c30 <main+0xa30>
lea    0x549(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1d3f <main+0xb3f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x12c(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1c7d <main+0xa7d>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1d3f <main+0xb3f>
mov    -0x120(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x4e2(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    1cd0 <main+0xad0>
lea    0x4a9(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1d3f <main+0xb3f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x12c(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1d1d <main+0xb1d>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    1d3f <main+0xb3f>
mov    -0x120(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x128(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x114(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,%rsp
mov    -0x114(%rbp),%eax
test   %eax,%eax
je     1d61 <main+0xb61>
jmp    1d5c <main+0xb5c>
jmp    1d72 <main+0xb72>
jmp    1d66 <main+0xb66>
jmp    1d6b <main+0xb6b>
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     122e <main+0x2e>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1110 <print_usage@plt>
mov    %edi,%r12d
cmp    $0x4,%edi
mov    %rsi,-0x40(%rbp)
jne    12b5 <main+0xb5>
mov    0x18(%rsi),%rbx
lea    0xdbb(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1336 <main+0x136>
lea    0xe19(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1889 <main+0x689>
lea    0xe00(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
xor    %r15d,%r15d
mov    $0x0,%r14d
mov    $0x0,%r13d
mov    $0x0,%ebx
mov    $0x0,%ecx
mov    %rcx,-0x38(%rbp)
test   %eax,%eax
jne    1347 <main+0x147>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
jmp    1899 <main+0x699>
xor    %r15d,%r15d
mov    $0x0,%r14d
mov    $0x0,%r13d
mov    $0x0,%ebx
mov    $0x0,%eax
mov    %rax,-0x38(%rbp)
cmp    $0x5,%r12d
jb     1347 <main+0x147>
mov    -0x40(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd8e(%rip),%rdi
call   1090 <strcmp@plt>
xor    %r15d,%r15d
mov    $0x0,%r14d
mov    $0x0,%r13d
mov    $0x0,%ebx
mov    $0x0,%ecx
mov    %rcx,-0x38(%rbp)
test   %eax,%eax
jne    1347 <main+0x147>
cmp    $0x8,%r12d
ja     18c1 <main+0x6c1>
cmp    $0x7,%r12d
je     18c1 <main+0x6c1>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
jmp    1899 <main+0x699>
xor    %r14d,%r14d
mov    $0x1,%r15b
xor    %r13d,%r13d
xor    %ebx,%ebx
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
test   %rax,%rax
jne    18fe <main+0x6fe>
mov    %r13d,-0x48(%rbp)
test   %r14d,%r14d
setne  %r10b
sete   %r8b
or     %r15b,%r10b
not    %r15b
mov    -0x30(%rbp),%esi
lea    (%rsi,%rbx,1),%edx
test   %r10b,%r10b
lea    -0xd0(%rbp),%rdi
lea    -0x70(%rbp),%r14
cmovne %rdi,%r14
mov    $0x50,%edi
mov    %rbx,%r11
mov    $0x28,%r13d
cmovne %edi,%r13d
lea    -0xcc(%rbp),%rdi
lea    -0x6c(%rbp),%rcx
cmovne %rdi,%rcx
movl   $0x5,(%r14)
movl   $0x3,(%rcx)
lea    -0xc8(%rbp),%rcx
lea    -0x68(%rbp),%rdi
cmovne %rcx,%rdi
movl   $0x0,(%rdi)
lea    -0xc4(%rbp),%rcx
lea    -0x64(%rbp),%rdi
cmovne %rcx,%rdi
lea    -0xc0(%rbp),%r9
lea    -0x60(%rbp),%rcx
cmovne %r9,%rcx
mov    -0x38(%rbp),%rax
lea    (%rdx,%rax,1),%ebx
movl   $0x0,(%rdi)
mov    %ebx,(%rcx)
lea    -0xbc(%rbp),%rcx
lea    -0x5c(%rbp),%rdi
cmovne %rcx,%rdi
mov    %esi,(%rdi)
lea    -0xb8(%rbp),%rcx
lea    -0x58(%rbp),%rdi
cmovne %rcx,%rdi
mov    %esi,(%rdi)
lea    -0xb4(%rbp),%rcx
lea    -0x54(%rbp),%rsi
cmovne %rcx,%rsi
lea    -0xb0(%rbp),%rcx
lea    -0x50(%rbp),%rdi
cmovne %rcx,%rdi
mov    %r11d,(%rsi)
mov    %edx,(%rdi)
lea    -0xac(%rbp),%rcx
lea    -0x4c(%rbp),%rdx
cmovne %rcx,%rdx
mov    %eax,(%rdx)
test   %r8b,%r15b
jne    1532 <main+0x332>
lea    -0xa8(%rbp),%rcx
lea    -0x48(%rbp),%rdx
test   %r10b,%r10b
cmovne %rcx,%rdx
movl   $0x33836685,(%rdx)
lea    -0xa4(%rbp),%rax
lea    -0x44(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x1,(%rcx)
lea    -0xa0(%rbp),%rax
lea    -0x40(%rbp),%rcx
cmovne %rax,%rcx
lea    -0x9c(%rbp),%rax
lea    -0x3c(%rbp),%rdx
cmovne %rax,%rdx
movl   $0x2,(%rcx)
movl   $0x0,(%rdx)
lea    -0x98(%rbp),%rax
lea    -0x38(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x94(%rbp),%rax
lea    -0x34(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x90(%rbp),%rax
lea    -0x30(%rbp),%rcx
cmovne %rax,%rcx
lea    -0x8c(%rbp),%rax
lea    -0x2c(%rbp),%rdx
cmovne %rax,%rdx
movl   $0x0,(%rcx)
movl   $0x0,(%rdx)
lea    -0x88(%rbp),%rax
lea    -0x28(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x84(%rbp),%rax
lea    -0x24(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
mov    0x2a87(%rip),%rax
mov    0x2ab8(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    -0x40(%rbp),%r15
mov    0x10(%r15),%rdi
mov    0x2a9d(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10c0 <open@plt>
test   %eax,%eax
js     191e <main+0x71e>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   1050 <write@plt>
cmp    %r13d,%eax
jne    192c <main+0x72c>
mov    %ebx,%edi
call   1080 <close@plt>
cmp    $0x8,%r12d
setb   %al
mov    -0x48(%rbp),%ecx
xor    $0x1,%cl
or     %al,%cl
jne    17ad <main+0x5ad>
mov    %rsp,-0x78(%rbp)
mov    %rsp,%rbx
add    $0xfffffffffffffff0,%rbx
mov    %rbx,%rsp
mov    0x30(%r15),%rdi
lea    0xba7(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     190c <main+0x70c>
mov    %rax,-0x48(%rbp)
xor    %r14d,%r14d
cmp    $0x9,%r12d
jb     1656 <main+0x456>
mov    %r12d,%eax
mov    %rax,-0xd8(%rbp)
xor    %r14d,%r14d
mov    $0x8,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%r13,8),%rdi
lea    0xb7f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     190c <main+0x70c>
mov    %rax,%r12
mov    (%r15,%r13,8),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x30(%rbp),%r15d
mov    %r12,%rdi
mov    -0x48(%rbp),%rsi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
jne    17a4 <main+0x5a4>
add    %r15d,%r14d
mov    %r12,%rdi
call   1060 <fclose@plt>
add    $0x1,%r13
cmp    %r13,-0xd8(%rbp)
mov    -0x40(%rbp),%r15
jne    15f0 <main+0x3f0>
mov    %rbx,%r12
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0x1,%edx
call   1070 <memset@plt>
mov    -0x38(%rbp),%rax
mov    %eax,%ebx
sub    %r14d,%ebx
test   %ebx,%ebx
mov    -0x48(%rbp),%r14
jle    16a9 <main+0x4a9>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
jne    18a3 <main+0x6a3>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
sub    %eax,%ebx
jne    1680 <main+0x480>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    0x20(%r15),%rdi
lea    0xa9f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     190c <main+0x70c>
mov    %rax,%r14
mov    0x8(%r15),%rdi
lea    0xaa2(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     190c <main+0x70c>
mov    %rax,%rbx
mov    0x8(%r15),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
jne    17a4 <main+0x5a4>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    -0x40(%rbp),%rbx
mov    0x38(%rbx),%rdi
lea    0xa51(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     190c <main+0x70c>
mov    %rax,%r15
mov    0x38(%rbx),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
jne    17a4 <main+0x5a4>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    -0x40(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0xa04(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     190c <main+0x70c>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    -0x38(%rbp),%rdx
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
je     196f <main+0x76f>
mov    -0x78(%rbp),%rsp
jmp    1959 <main+0x759>
and    $0xfffffffd,%r12d
xor    %ebx,%ebx
cmp    $0x5,%r12d
jne    195e <main+0x75e>
mov    %r15,%r13
mov    %rsp,%r15
mov    0x20(%r13),%rdi
lea    0x98d(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     194a <main+0x74a>
mov    %rax,%r14
mov    0x10(%r13),%rdi
lea    0x990(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     194a <main+0x74a>
mov    %rax,%r12
mov    0x10(%r13),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
jne    1956 <main+0x756>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x8(%r13),%rdi
lea    0x943(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     194a <main+0x74a>
mov    %rax,%r12
mov    0x8(%r13),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x30(%rbp),%edx
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
jne    1956 <main+0x756>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r15,%rsp
jmp    195e <main+0x75e>
mov    0x2740(%rip),%rax
mov    (%rax),%edi
lea    0x774(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    1219 <main+0x19>
mov    0x2726(%rip),%rax
mov    (%rax),%edi
lea    0x8ca(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x78(%rbp),%rsp
jmp    1959 <main+0x759>
xor    %r14d,%r14d
cmp    $0x7,%r12d
mov    -0x40(%rbp),%rbx
jne    18e1 <main+0x6e1>
mov    0x30(%rbx),%rdi
call   10f0 <atoi@plt>
xor    %r14d,%r14d
cmp    $0x1,%eax
sete   %r14b
mov    0x28(%rbx),%rdi
call   10f0 <atoi@plt>
mov    %rax,-0x38(%rbp)
mov    $0x100,%ebx
mov    $0x1,%r13b
xor    %r15d,%r15d
jmp    1347 <main+0x147>
lea    0x810(%rip),%rdi
call   10e0 <perror@plt>
jmp    1959 <main+0x759>
lea    0x84b(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x78(%rbp),%rsp
jmp    1959 <main+0x759>
lea    0x803(%rip),%rdi
call   10e0 <perror@plt>
jmp    1959 <main+0x759>
lea    0x814(%rip),%rdi
call   10e0 <perror@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    0x10(%r15),%rdi
call   1030 <unlink@plt>
jmp    1959 <main+0x759>
lea    0x80d(%rip),%rdi
call   10e0 <perror@plt>
mov    %r15,%rsp
mov    $0xffffffff,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %ebx,%ebx
mov    -0x78(%rbp),%rsp
jmp    195e <main+0x75e>

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