#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();
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;
  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;
    }
    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[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;
    }
    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    $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    1261 <main+0x61>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
cmpl   $0x4,-0x8(%rbp)
jne    1325 <main+0x125>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd86(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1294 <main+0x94>
movl   $0x1,-0x24(%rbp)
jmp    1320 <main+0x120>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdd2(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12d5 <main+0xd5>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xd4c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd8f(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1316 <main+0x116>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
jmp    131b <main+0x11b>
jmp    1320 <main+0x120>
jmp    1325 <main+0x125>
cmpl   $0x4,-0x8(%rbp)
jle    13b0 <main+0x1b0>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd37(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    13ab <main+0x1ab>
cmpl   $0x9,-0x8(%rbp)
jge    1384 <main+0x184>
cmpl   $0x6,-0x8(%rbp)
je     1384 <main+0x184>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   1110 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
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    13b0 <main+0x1b0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%rax
je     13e3 <main+0x1e3>
lea    0xd43(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
cmpl   $0x0,-0x24(%rbp)
je     1407 <main+0x207>
lea    -0x80(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x50,-0xb4(%rbp)
jmp    141f <main+0x21f>
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)
jne    1564 <main+0x364>
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    0x2a4d(%rip),%rax
mov    (%rax),%esi
mov    0x2a7c(%rip),%rax
or     (%rax),%esi
mov    0x2a6b(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10c0 <open@plt>
mov    %eax,-0xd0(%rbp)
cmpl   $0x0,-0xd0(%rbp)
jge    15bc <main+0x3bc>
lea    0xb7d(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
mov    -0xd0(%rbp),%edi
mov    -0xc0(%rbp),%rsi
mov    -0xb4(%rbp),%edx
call   1050 <write@plt>
cmp    -0xb4(%rbp),%eax
je     1610 <main+0x410>
lea    0xb60(%rip),%rdi
call   10e0 <perror@plt>
mov    -0xd0(%rbp),%edi
call   1080 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1dc4 <main+0xbc4>
mov    -0xd0(%rbp),%edi
call   1080 <close@plt>
cmpl   $0x0,-0xcc(%rbp)
je     1bbf <main+0x9bf>
cmpl   $0x6,-0x8(%rbp)
jle    1bbf <main+0x9bf>
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    0xac3(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    16d0 <main+0x4d0>
lea    0xaa9(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
movl   $0x8,-0x108(%rbp)
mov    -0x108(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    17c9 <main+0x5c9>
mov    -0x10(%rbp),%rax
movslq -0x108(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xa7b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1737 <main+0x537>
lea    0xa42(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0x10(%rbp),%rax
movslq -0x108(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <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   1120 <cat@plt>
cmp    $0x0,%rax
je     17a9 <main+0x5a9>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x108(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x108(%rbp)
jmp    16da <main+0x4da>
mov    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    %eax,%edx
mov    $0xff,%esi
call   1070 <memset@plt>
mov    -0xc4(%rbp),%eax
sub    -0x100(%rbp),%eax
mov    %eax,-0x104(%rbp)
cmpl   $0x0,-0x104(%rbp)
jle    1813 <main+0x613>
mov    -0x104(%rbp),%eax
mov    %eax,-0x14c(%rbp)
jmp    1820 <main+0x620>
xor    %eax,%eax
mov    %eax,-0x14c(%rbp)
jmp    1820 <main+0x620>
mov    -0x14c(%rbp),%eax
mov    %eax,-0xfc(%rbp)
cmpl   $0x0,-0xfc(%rbp)
je     18b7 <main+0x6b7>
mov    -0xe0(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
jne    1887 <main+0x687>
mov    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    %eax,%esi
mov    -0xe4(%rbp),%edx
mov    -0xe0(%rbp),%rcx
call   1100 <fwrite@plt>
mov    %rax,%rcx
mov    -0xfc(%rbp),%eax
sub    %rcx,%rax
mov    %eax,-0xfc(%rbp)
jmp    18b2 <main+0x6b2>
mov    0x2742(%rip),%rax
mov    (%rax),%edi
lea    0x8e6(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
jmp    182c <main+0x62c>
mov    -0xe0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0x889(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    190a <main+0x70a>
lea    0x86f(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x861(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1951 <main+0x751>
lea    0x828(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     199e <main+0x79e>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x7c1(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    19f1 <main+0x7f1>
lea    0x788(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1a3e <main+0x83e>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    0x721(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1a91 <main+0x891>
lea    0x6e8(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1ade <main+0x8de>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0xd8(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0x681(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    1b31 <main+0x931>
lea    0x648(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0x100(%rbp),%edx
add    -0x104(%rbp),%edx
mov    -0xe4(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1b76 <main+0x976>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1b98 <main+0x998>
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     1bba <main+0x9ba>
jmp    1bb5 <main+0x9b5>
jmp    1dc4 <main+0xbc4>
jmp    1dbd <main+0xbbd>
cmpl   $0x5,-0x8(%rbp)
je     1bd3 <main+0x9d3>
cmpl   $0x6,-0x8(%rbp)
jne    1db8 <main+0xbb8>
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    0x558(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    1c3b <main+0xa3b>
lea    0x53e(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1d91 <main+0xb91>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x530(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    1c82 <main+0xa82>
lea    0x4f7(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1d91 <main+0xb91>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x118(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x124(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1ccf <main+0xacf>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1d91 <main+0xb91>
mov    -0x118(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0x490(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    1d22 <main+0xb22>
lea    0x457(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1d91 <main+0xb91>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x118(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x124(%rbp),%ecx
call   1120 <cat@plt>
cmp    $0x0,%rax
je     1d6f <main+0xb6f>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1d91 <main+0xb91>
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     1db3 <main+0xbb3>
jmp    1dae <main+0xbae>
jmp    1dc4 <main+0xbc4>
jmp    1db8 <main+0xbb8>
jmp    1dbd <main+0xbbd>
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,-0x38(%rbp)
jne    128b <main+0x8b>
mov    0x18(%rsi),%rbx
lea    0xdbb(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     12eb <main+0xeb>
lea    0xe19(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1892 <main+0x692>
lea    0xe00(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     18a4 <main+0x6a4>
xor    %r13d,%r13d
mov    $0x1,%r14b
jmp    12f1 <main+0xf1>
xor    %r13d,%r13d
mov    $0x1,%r14b
cmp    $0x5,%r12d
jb     12f1 <main+0xf1>
mov    0x18(%rsi),%rsi
lea    0xdd3(%rip),%rdi
call   1090 <strcmp@plt>
xor    %r13d,%r13d
mov    $0x0,%ebx
mov    $0x0,%r15d
mov    $0x0,%ecx
mov    %rcx,-0x40(%rbp)
test   %eax,%eax
jne    12fc <main+0xfc>
cmp    $0x8,%r12d
ja     18dc <main+0x6dc>
cmp    $0x6,%r12d
je     18dc <main+0x6dc>
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
jmp    18b4 <main+0x6b4>
xor    %r14d,%r14d
mov    $0x1,%r13b
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
test   %rax,%rax
jne    1912 <main+0x712>
mov    %ebx,-0x48(%rbp)
mov    -0x30(%rbp),%ecx
lea    (%rcx,%r15,1),%eax
test   %r14b,%r14b
lea    -0x70(%rbp),%rdx
mov    %r14d,%r8d
lea    -0xd0(%rbp),%r14
cmovne %rdx,%r14
mov    $0x28,%edx
mov    %r13d,%r9d
mov    $0x50,%r13d
cmovne %edx,%r13d
lea    -0x6c(%rbp),%rdx
lea    -0xcc(%rbp),%rsi
cmovne %rdx,%rsi
movl   $0x5,(%r14)
movl   $0x3,(%rsi)
lea    -0x68(%rbp),%rdx
lea    -0xc8(%rbp),%rsi
cmovne %rdx,%rsi
movl   $0x0,(%rsi)
lea    -0x64(%rbp),%rdx
lea    -0xc4(%rbp),%rsi
cmovne %rdx,%rsi
lea    -0x60(%rbp),%rdx
lea    -0xc0(%rbp),%rdi
cmovne %rdx,%rdi
mov    -0x40(%rbp),%rbx
lea    (%rax,%rbx,1),%edx
movl   $0x0,(%rsi)
mov    %edx,(%rdi)
lea    -0x5c(%rbp),%rdx
lea    -0xbc(%rbp),%rsi
cmovne %rdx,%rsi
mov    %ecx,(%rsi)
lea    -0x58(%rbp),%rdx
lea    -0xb8(%rbp),%rsi
cmovne %rdx,%rsi
mov    %ecx,(%rsi)
lea    -0x54(%rbp),%rcx
lea    -0xb4(%rbp),%rdx
cmovne %rcx,%rdx
lea    -0x50(%rbp),%rcx
lea    -0xb0(%rbp),%rsi
cmovne %rcx,%rsi
mov    %r15d,(%rdx)
mov    %eax,(%rsi)
lea    -0x4c(%rbp),%rax
lea    -0xac(%rbp),%rcx
cmovne %rax,%rcx
mov    %ebx,(%rcx)
test   %r9b,%r9b
je     14d9 <main+0x2d9>
lea    -0x48(%rbp),%rax
lea    -0xa8(%rbp),%rcx
test   %r8b,%r8b
cmovne %rax,%rcx
movl   $0x33836685,(%rcx)
lea    -0x44(%rbp),%rax
lea    -0xa4(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x1,(%rcx)
lea    -0x40(%rbp),%rax
lea    -0xa0(%rbp),%rcx
cmovne %rax,%rcx
lea    -0x3c(%rbp),%rax
lea    -0x9c(%rbp),%rdx
cmovne %rax,%rdx
movl   $0x2,(%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)
lea    -0x30(%rbp),%rax
lea    -0x90(%rbp),%rcx
cmovne %rax,%rcx
lea    -0x2c(%rbp),%rax
lea    -0x8c(%rbp),%rdx
cmovne %rax,%rdx
movl   $0x0,(%rcx)
movl   $0x0,(%rdx)
lea    -0x28(%rbp),%rax
lea    -0x88(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
lea    -0x24(%rbp),%rax
lea    -0x84(%rbp),%rcx
cmovne %rax,%rcx
movl   $0x0,(%rcx)
mov    0x2ae0(%rip),%rax
mov    0x2b11(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2af6(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10c0 <open@plt>
test   %eax,%eax
js     1920 <main+0x720>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   1050 <write@plt>
cmp    %r13d,%eax
jne    192e <main+0x72e>
mov    %ebx,%edi
call   1080 <close@plt>
cmp    $0x7,%r12d
setb   %al
mov    -0x48(%rbp),%ecx
xor    $0x1,%cl
or     %al,%cl
jne    17b5 <main+0x5b5>
mov    %rsp,-0x78(%rbp)
mov    %rsp,%r14
add    $0xfffffffffffffff0,%r14
mov    %r14,%rsp
mov    -0x38(%rbp),%rbx
mov    0x30(%rbx),%rdi
lea    0xbfc(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
mov    %rax,-0x48(%rbp)
mov    %r14,-0xd8(%rbp)
xor    %r14d,%r14d
cmp    $0x9,%r12d
jb     1606 <main+0x406>
mov    %r12d,%eax
mov    %rax,-0xe0(%rbp)
xor    %r14d,%r14d
mov    $0x8,%r13d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r13,8),%rdi
lea    0xbcf(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
mov    %rax,%r15
mov    (%rbx,%r13,8),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x30(%rbp),%r12d
mov    %r15,%rdi
mov    -0x48(%rbp),%rsi
mov    %r12d,%edx
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
jne    17ac <main+0x5ac>
add    %r12d,%r14d
mov    %r15,%rdi
call   1060 <fclose@plt>
add    $0x1,%r13
cmp    %r13,-0xe0(%rbp)
mov    -0x38(%rbp),%rbx
jne    15a0 <main+0x3a0>
mov    -0xd8(%rbp),%r15
mov    %r15,%rdi
mov    $0xff,%esi
mov    $0x1,%edx
call   1070 <memset@plt>
mov    -0x40(%rbp),%rax
mov    %eax,%ebx
sub    %r14d,%ebx
test   %ebx,%ebx
mov    -0x48(%rbp),%r14
jle    1659 <main+0x459>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
jne    18be <main+0x6be>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
sub    %eax,%ebx
jne    1630 <main+0x430>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rbx
mov    0x20(%rbx),%rdi
lea    0xaeb(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xaee(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
mov    %rbx,%rcx
mov    %rax,%rbx
mov    0x10(%rcx),%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    17ac <main+0x5ac>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rbx
mov    0x8(%rbx),%rdi
lea    0xa9a(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
mov    %rax,%r15
mov    0x8(%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    17ac <main+0x5ac>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rbx
mov    0x38(%rbx),%rdi
lea    0xa49(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
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    17ac <main+0x5ac>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rax
mov    0x30(%rax),%rdi
lea    0x9fc(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1900 <main+0x700>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    -0x40(%rbp),%rdx
mov    $0x1,%ecx
call   1120 <cat@plt>
test   %rax,%rax
je     1975 <main+0x775>
mov    -0x78(%rbp),%rsp
jmp    195f <main+0x75f>
add    $0xfffffffb,%r12d
xor    %ebx,%ebx
cmp    $0x1,%r12d
ja     1964 <main+0x764>
mov    %rsp,%r15
mov    -0x38(%rbp),%r13
mov    0x20(%r13),%rdi
lea    0x984(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1950 <main+0x750>
mov    %rax,%r14
mov    0x10(%r13),%rdi
lea    0x987(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1950 <main+0x750>
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    195c <main+0x75c>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x8(%r13),%rdi
lea    0x93a(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1950 <main+0x750>
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    195c <main+0x75c>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r15,%rsp
jmp    1964 <main+0x764>
mov    0x2737(%rip),%rax
mov    (%rax),%edi
lea    0x76b(%rip),%rsi
jmp    18b4 <main+0x6b4>
mov    0x2725(%rip),%rax
mov    (%rax),%edi
lea    0x7cd(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    1219 <main+0x19>
mov    0x270b(%rip),%rax
mov    (%rax),%edi
lea    0x8af(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x78(%rbp),%rsp
jmp    195f <main+0x75f>
mov    -0x38(%rbp),%rax
mov    0x28(%rax),%rdi
call   10f0 <atoi@plt>
mov    %rax,-0x40(%rbp)
mov    $0x100,%r15d
mov    $0x1,%r14b
xor    %r13d,%r13d
mov    $0x1,%bl
jmp    12fc <main+0xfc>
lea    0x857(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x78(%rbp),%rsp
jmp    195f <main+0x75f>
lea    0x7fc(%rip),%rdi
call   10e0 <perror@plt>
jmp    195f <main+0x75f>
lea    0x801(%rip),%rdi
call   10e0 <perror@plt>
jmp    195f <main+0x75f>
lea    0x812(%rip),%rdi
call   10e0 <perror@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <unlink@plt>
jmp    195f <main+0x75f>
lea    0x807(%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    1964 <main+0x764>

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