#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*/ FILE;

/* Variables and functions */
int EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *outfile = stdout;
  FILE *inhigh = NULL;
  FILE *inlow = NULL;
  char *arg = NULL;
  while (--argc) {
    arg = *(++argv);
    if (arg[0] == '-' && arg[1] && arg[2] == '\0') {
      switch (arg[1]) {
      case 'o':
        if (--argc == 0) {
          goto invalid_argument;
        }
        ++argv;
        if (!(outfile = fopen(*argv, "wb"))) {
          goto argument_error;
        }
        break;
      case 'h':
        if (--argc == 0) {
          goto invalid_argument;
        }
        ++argv;
        if (!(inhigh = fopen(*argv, "rb"))) {
          goto argument_error;
        }
        break;
      case 'l':
        if (--argc == 0) {
          goto invalid_argument;
        }
        ++argv;
        if (!(inlow = fopen(*argv, "rb"))) {
          goto argument_error;
        }
        break;
      case '?':
        arg = NULL;
        goto usage;
      default:
        goto invalid_argument;
      }
      continue;
    }
  invalid_argument:
    (void)fprintf(stderr, "Invalid argument: %s\n", arg);
  usage:
    (void)fprintf(stderr, "merge16bit - Copyright (c) 2019 Kimmo Kulovesi\n");
    (void)fprintf(
        stderr,
        "Usage: merge16bit [-o <out.bin>] <-h highfile> <-l lowfile>\n");
    return arg ? EXIT_FAILURE : EXIT_SUCCESS;
  argument_error:
    perror(*argv);
    return EXIT_FAILURE;
  }
  if (!(inhigh && inlow)) {
    arg = "";
    goto usage;
  }
  errno = 0;
  for (;;) {
    int byte = fgetc(inlow);
    if (byte == EOF) {
      break;
    }
    if (fputc(byte, outfile) == EOF) {
      break;
    }
    byte = fgetc(inhigh);
    if (byte == EOF) {
      break;
    }
    if (fputc(byte, outfile) == EOF) {
      break;
    }
  }
  if (errno) {
    perror("Error");
  }
  (void)fclose(inlow);
  (void)fclose(inhigh);
  if (outfile != stdout) {
    (void)fclose(outfile);
  }
  return errno ? EXIT_FAILURE : EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     13e2 <main+0x282>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1344 <main+0x1e4>
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1344 <main+0x1e4>
mov    -0x30(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    1344 <main+0x1e4>
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x38(%rbp)
sub    $0x3f,%eax
je     132d <main+0x1cd>
jmp    1210 <main+0xb0>
mov    -0x38(%rbp),%eax
sub    $0x68,%eax
je     1291 <main+0x131>
jmp    1221 <main+0xc1>
mov    -0x38(%rbp),%eax
sub    $0x6c,%eax
je     12df <main+0x17f>
jmp    1232 <main+0xd2>
mov    -0x38(%rbp),%eax
sub    $0x6f,%eax
jne    133a <main+0x1da>
jmp    1243 <main+0xe3>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    125a <main+0xfa>
jmp    1349 <main+0x1e9>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    128c <main+0x12c>
jmp    13c5 <main+0x265>
jmp    133f <main+0x1df>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    12a8 <main+0x148>
jmp    1349 <main+0x1e9>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd41(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12da <main+0x17a>
jmp    13c5 <main+0x265>
jmp    133f <main+0x1df>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    12f6 <main+0x196>
jmp    1349 <main+0x1e9>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xcf3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1328 <main+0x1c8>
jmp    13c5 <main+0x265>
jmp    133f <main+0x1df>
movq   $0x0,-0x30(%rbp)
jmp    1364 <main+0x204>
jmp    1349 <main+0x1e9>
jmp    119c <main+0x3c>
jmp    1349 <main+0x1e9>
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xca9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
lea    0xcc1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpq   $0x0,-0x30(%rbp)
je     13ae <main+0x24e>
mov    0x2c24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
jmp    13ba <main+0x25a>
mov    0x2c03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1521 <main+0x3c1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <perror@plt>
mov    0x2bf0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1521 <main+0x3c1>
cmpq   $0x0,-0x20(%rbp)
je     13f8 <main+0x298>
cmpq   $0x0,-0x28(%rbp)
jne    1408 <main+0x2a8>
lea    0xc89(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1364 <main+0x204>
mov    0x2bc1(%rip),%rax
movq   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2bbc(%rip),%rcx
cmp    (%rcx),%eax
jne    1439 <main+0x2d9>
jmp    14a1 <main+0x341>
mov    -0x34(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <fputc@plt>
mov    0x2b9c(%rip),%rcx
cmp    (%rcx),%eax
jne    1459 <main+0x2f9>
jmp    14a1 <main+0x341>
mov    -0x20(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2b79(%rip),%rcx
cmp    (%rcx),%eax
jne    147c <main+0x31c>
jmp    14a1 <main+0x341>
mov    -0x34(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <fputc@plt>
mov    0x2b59(%rip),%rcx
cmp    (%rcx),%eax
jne    149c <main+0x33c>
jmp    14a1 <main+0x341>
jmp    1416 <main+0x2b6>
mov    0x2b28(%rip),%rax
cmpq   $0x0,(%rax)
je     14be <main+0x35e>
lea    0xbd0(%rip),%rdi
call   1080 <perror@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    0x2ae5(%rip),%rcx
cmp    (%rcx),%rax
je     14ed <main+0x38d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2adc(%rip),%rax
cmpq   $0x0,(%rax)
je     150f <main+0x3af>
mov    0x2ac3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    151b <main+0x3bb>
mov    0x2aa2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf16(%rip),%r13
cmp    $0x1,%edi
je     1312 <main+0x1b2>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e39(%rip),%rax
mov    (%rax),%r15
xor    %r14d,%r14d
xor    %r12d,%r12d
mov    0x8(%rbx),%r13
cmpb   $0x2d,0x0(%r13)
jne    12f8 <main+0x198>
movsbl 0x1(%r13),%eax
test   %eax,%eax
je     12f8 <main+0x198>
cmpb   $0x0,0x2(%r13)
jne    12f8 <main+0x198>
cmp    $0x6b,%eax
jle    11f0 <main+0x90>
cmp    $0x6c,%eax
je     1220 <main+0xc0>
cmp    $0x6f,%eax
jne    12f8 <main+0x198>
add    $0xfffffffe,%ebp
je     12f8 <main+0x198>
mov    0x10(%rbx),%rdi
add    $0x10,%rbx
lea    0xe1e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
jmp    1240 <main+0xe0>
nopl   0x0(%rax)
cmp    $0x68,%eax
jne    12ee <main+0x18e>
add    $0xfffffffe,%ebp
je     12f8 <main+0x198>
mov    0x10(%rbx),%rdi
add    $0x10,%rbx
lea    0xdf2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
jmp    1240 <main+0xe0>
nopl   0x0(%rax,%rax,1)
add    $0xfffffffe,%ebp
je     12f8 <main+0x198>
mov    0x10(%rbx),%rdi
add    $0x10,%rbx
lea    0xdcb(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1347 <main+0x1e7>
cmp    $0x1,%ebp
jne    1190 <main+0x30>
lea    0xe2f(%rip),%r13
test   %r12,%r12
je     1312 <main+0x1b2>
test   %r14,%r14
je     1312 <main+0x1b2>
mov    0x2d5e(%rip),%rbx
movq   $0x0,(%rbx)
mov    0x2d68(%rip),%rbp
mov    %r14,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     12b8 <main+0x158>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
cmp    0x0(%rbp),%eax
je     12b8 <main+0x158>
mov    %r12,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     12b8 <main+0x158>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
cmp    0x0(%rbp),%eax
jne    1280 <main+0x120>
cmpq   $0x0,(%rbx)
jne    1367 <main+0x207>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x2ce7(%rip),%rax
cmp    (%rax),%r15
je     12e6 <main+0x186>
mov    %r15,%rdi
call   1030 <fclose@plt>
cmpq   $0x0,(%rbx)
je     133e <main+0x1de>
jmp    134f <main+0x1ef>
cmp    $0x3f,%eax
jne    12f8 <main+0x198>
xor    %r13d,%r13d
jmp    1312 <main+0x1b2>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    0xcfe(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2cbf(%rip),%rbx
mov    (%rbx),%edi
lea    0xcfa(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd1a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %r13,%r13
jne    134f <main+0x1ef>
mov    0x2c73(%rip),%rax
jmp    1356 <main+0x1f6>
mov    (%rbx),%rdi
call   1080 <perror@plt>
mov    0x2c72(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd1b(%rip),%rdi
call   1080 <perror@plt>
jmp    12c2 <main+0x162>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [3 x i8] c"wb\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"Invalid argument: %s\0A\00"
@.str.3 = [48 x i8] c"merge16bit - Copyright (c) 2019 Kimmo Kulovesi\0A\00"
@.str.4 = [61 x i8] c"Usage: merge16bit [-o <out.bin>] <-h highfile> <-l lowfile>\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [1 x i8] zeroinitializer
@errno = global i64 0
@EOF = global i32 0
@.str.6 = [6 x i8] c"Error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32*, i32** @stdout
store i32* %11, i32** %6
store i32* null, i32** %7
store i32* null, i32** %8
store i8* null, i8** %9
br label %12
12: ; preds = %86, %2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, -1
store i32 %14, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %110
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i32 1
store i8** %18, i8*** %5
%19 = load i8*, i8** %18
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %87
25: ; preds = %16
%26 = load i8*, i8** %9
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %87
31: ; preds = %25
%32 = load i8*, i8** %9
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %87
37: ; preds = %31
%38 = load i8*, i8** %9
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
switch i32 %41, label %85 [
i32 111, label %42
i32 104, label %56
i32 108, label %70
i32 63, label %84
]
42: ; preds = %37
%43 = load i32, i32* %4
%44 = add nsw i32 %43, -1
store i32 %44, i32* %4
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
br label %88
47: ; preds = %42
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i32 1
store i8** %49, i8*** %5
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %52, i32** %6
%53 = icmp ne i32* %52, null
br i1 %53, label %55, label %54
54: ; preds = %47
br label %105
55: ; preds = %47
br label %86
56: ; preds = %37
%57 = load i32, i32* %4
%58 = add nsw i32 %57, -1
store i32 %58, i32* %4
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %56
br label %88
61: ; preds = %56
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i32 1
store i8** %63, i8*** %5
%64 = load i8**, i8*** %5
%65 = load i8*, i8** %64
%66 = call i32* @fopen(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %66, i32** %7
%67 = icmp ne i32* %66, null
br i1 %67, label %69, label %68
68: ; preds = %61
br label %105
69: ; preds = %61
br label %86
70: ; preds = %37
%71 = load i32, i32* %4
%72 = add nsw i32 %71, -1
store i32 %72, i32* %4
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %70
br label %88
75: ; preds = %70
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i32 1
store i8** %77, i8*** %5
%78 = load i8**, i8*** %5
%79 = load i8*, i8** %78
%80 = call i32* @fopen(i8* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %80, i32** %8
%81 = icmp ne i32* %80, null
br i1 %81, label %83, label %82
82: ; preds = %75
br label %105
83: ; preds = %75
br label %86
84: ; preds = %37
store i8* null, i8** %9
br label %92
85: ; preds = %37
br label %88
86: ; preds = %83, %69, %55
br label %12
87: ; preds = %31, %25, %16
br label %88
88: ; preds = %87, %85, %74, %60, %46
%89 = load i32, i32* @stderr
%90 = load i8*, i8** %9
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %90)
br label %92
92: ; preds = %116, %88, %84
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%95 = load i32, i32* @stderr
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
%97 = load i8*, i8** %9
%98 = icmp ne i8* %97, null
br i1 %98, label %99, label %101
99: ; preds = %92
%100 = load i32, i32* @EXIT_FAILURE
br label %103
101: ; preds = %92
%102 = load i32, i32* @EXIT_SUCCESS
br label %103
103: ; preds = %101, %99
%104 = phi i32 [ %100, %99 ], [ %102, %101 ]
store i32 %104, i32* %3
br label %172
105: ; preds = %82, %68, %54
%106 = load i8**, i8*** %5
%107 = load i8*, i8** %106
%108 = call i32 @perror(i8* %107)
%109 = load i32, i32* @EXIT_FAILURE
store i32 %109, i32* %3
br label %172
110: ; preds = %12
%111 = load i32*, i32** %7
%112 = icmp ne i32* %111, null
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32*, i32** %8
%115 = icmp ne i32* %114, null
br i1 %115, label %117, label %116
116: ; preds = %113, %110
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8** %9
br label %92
117: ; preds = %113
store i64 0, i64* @errno
br label %118
118: ; preds = %146, %117
%119 = load i32*, i32** %8
%120 = call i32 @fgetc(i32* %119)
store i32 %120, i32* %10
%121 = load i32, i32* %10
%122 = load i32, i32* @EOF
%123 = icmp eq i32 %121, %122
br i1 %123, label %124, label %125
124: ; preds = %118
br label %147
125: ; preds = %118
%126 = load i32, i32* %10
%127 = load i32*, i32** %6
%128 = call i32 @fputc(i32 %126, i32* %127)
%129 = load i32, i32* @EOF
%130 = icmp eq i32 %128, %129
br i1 %130, label %131, label %132
131: ; preds = %125
br label %147
132: ; preds = %125
%133 = load i32*, i32** %7
%134 = call i32 @fgetc(i32* %133)
store i32 %134, i32* %10
%135 = load i32, i32* %10
%136 = load i32, i32* @EOF
%137 = icmp eq i32 %135, %136
br i1 %137, label %138, label %139
138: ; preds = %132
br label %147
139: ; preds = %132
%140 = load i32, i32* %10
%141 = load i32*, i32** %6
%142 = call i32 @fputc(i32 %140, i32* %141)
%143 = load i32, i32* @EOF
%144 = icmp eq i32 %142, %143
br i1 %144, label %145, label %146
145: ; preds = %139
br label %147
146: ; preds = %139
br label %118
147: ; preds = %145, %138, %131, %124
%148 = load i64, i64* @errno
%149 = icmp ne i64 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %147
%151 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %152
152: ; preds = %150, %147
%153 = load i32*, i32** %8
%154 = call i32 @fclose(i32* %153)
%155 = load i32*, i32** %7
%156 = call i32 @fclose(i32* %155)
%157 = load i32*, i32** %6
%158 = load i32*, i32** @stdout
%159 = icmp ne i32* %157, %158
br i1 %159, label %160, label %163
160: ; preds = %152
%161 = load i32*, i32** %6
%162 = call i32 @fclose(i32* %161)
br label %163
163: ; preds = %160, %152
%164 = load i64, i64* @errno
%165 = icmp ne i64 %164, 0
br i1 %165, label %166, label %168
166: ; preds = %163
%167 = load i32, i32* @EXIT_FAILURE
br label %170
168: ; preds = %163
%169 = load i32, i32* @EXIT_SUCCESS
br label %170
170: ; preds = %168, %166
%171 = phi i32 [ %167, %166 ], [ %169, %168 ]
store i32 %171, i32* %3
br label %172
172: ; preds = %170, %105, %103
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [3 x i8] c"wb\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [22 x i8] c"Invalid argument: %s\0A\00"
@.str.3 = [48 x i8] c"merge16bit - Copyright (c) 2019 Kimmo Kulovesi\0A\00"
@.str.4 = [61 x i8] c"Usage: merge16bit [-o <out.bin>] <-h highfile> <-l lowfile>\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [1 x i8] zeroinitializer
@errno = global i64 0
@EOF = global i32 0
@.str.6 = [6 x i8] c"Error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %60, label %4
4: ; preds = %2
%5 = load i32*, i32** @stdout
br label %6
6: ; preds = %4, %50
%7 = phi i32* [ %55, %50 ], [ null, %4 ]
%8 = phi i32* [ %54, %50 ], [ null, %4 ]
%9 = phi i32* [ %53, %50 ], [ %5, %4 ]
%10 = phi i8** [ %52, %50 ], [ %1, %4 ]
%11 = phi i32 [ %51, %50 ], [ %0, %4 ]
%12 = getelementptr inbounds i8*, i8** %10, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %57
16: ; preds = %6
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i8 %18, 0
br i1 %20, label %57, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %13, i64 2
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %57
25: ; preds = %21
switch i32 %19, label %57 [
i32 111, label %26
i32 104, label %34
i32 108, label %42
i32 63, label %60
]
26: ; preds = %25
%27 = add nsw i32 %11, -2
%28 = icmp eq i32 %27, 0
br i1 %28, label %57, label %29
29: ; preds = %26
%30 = getelementptr inbounds i8*, i8** %10, i64 2
%31 = load i8*, i8** %30
%32 = tail call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %70, label %50
34: ; preds = %25
%35 = add nsw i32 %11, -2
%36 = icmp eq i32 %35, 0
br i1 %36, label %57, label %37
37: ; preds = %34
%38 = getelementptr inbounds i8*, i8** %10, i64 2
%39 = load i8*, i8** %38
%40 = tail call i32* @fopen(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i32* %40, null
br i1 %41, label %70, label %50
42: ; preds = %25
%43 = add nsw i32 %11, -2
%44 = icmp eq i32 %43, 0
br i1 %44, label %57, label %45
45: ; preds = %42
%46 = getelementptr inbounds i8*, i8** %10, i64 2
%47 = load i8*, i8** %46
%48 = tail call i32* @fopen(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %70, label %50
50: ; preds = %45, %37, %29
%51 = phi i32 [ %43, %45 ], [ %35, %37 ], [ %27, %29 ]
%52 = phi i8** [ %46, %45 ], [ %38, %37 ], [ %30, %29 ]
%53 = phi i32* [ %9, %45 ], [ %9, %37 ], [ %32, %29 ]
%54 = phi i32* [ %8, %45 ], [ %40, %37 ], [ %8, %29 ]
%55 = phi i32* [ %48, %45 ], [ %7, %37 ], [ %7, %29 ]
%56 = icmp eq i32 %51, 1
br i1 %56, label %75, label %6
57: ; preds = %6, %16, %21, %25, %42, %34, %26
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %60
60: ; preds = %25, %2, %75, %57
%61 = phi i8* [ %13, %57 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %75 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %2 ], [ null, %25 ]
%62 = load i32, i32* @stderr
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%64 = load i32, i32* @stderr
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
%66 = icmp eq i8* %61, null
%67 = load i32, i32* @EXIT_FAILURE
%68 = load i32, i32* @EXIT_SUCCESS
%69 = select i1 %66, i32 %68, i32 %67
br label %114
70: ; preds = %45, %37, %29
%71 = phi i8** [ %46, %45 ], [ %38, %37 ], [ %30, %29 ]
%72 = load i8*, i8** %71
%73 = tail call i32 @perror(i8* %72)
%74 = load i32, i32* @EXIT_FAILURE
br label %114
75: ; preds = %50
%76 = icmp ne i32* %54, null
%77 = icmp ne i32* %55, null
%78 = select i1 %76, i1 %77, i1 false
br i1 %78, label %79, label %60
79: ; preds = %75
store i64 0, i64* @errno
br label %80
80: ; preds = %92, %79
%81 = tail call i32 @fgetc(i32* %55)
%82 = load i32, i32* @EOF
%83 = icmp eq i32 %81, %82
br i1 %83, label %96, label %84
84: ; preds = %80
%85 = tail call i32 @fputc(i32 %81, i32* %53)
%86 = load i32, i32* @EOF
%87 = icmp eq i32 %85, %86
br i1 %87, label %96, label %88
88: ; preds = %84
%89 = tail call i32 @fgetc(i32* %54)
%90 = load i32, i32* @EOF
%91 = icmp eq i32 %89, %90
br i1 %91, label %96, label %92
92: ; preds = %88
%93 = tail call i32 @fputc(i32 %89, i32* %53)
%94 = load i32, i32* @EOF
%95 = icmp eq i32 %93, %94
br i1 %95, label %96, label %80
96: ; preds = %92, %80, %84, %88
%97 = load i64, i64* @errno
%98 = icmp eq i64 %97, 0
br i1 %98, label %101, label %99
99: ; preds = %96
%100 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %101
101: ; preds = %99, %96
%102 = tail call i32 @fclose(i32* %55)
%103 = tail call i32 @fclose(i32* %54)
%104 = load i32*, i32** @stdout
%105 = icmp eq i32* %53, %104
br i1 %105, label %108, label %106
106: ; preds = %101
%107 = tail call i32 @fclose(i32* %53)
br label %108
108: ; preds = %106, %101
%109 = load i64, i64* @errno
%110 = icmp eq i64 %109, 0
%111 = load i32, i32* @EXIT_FAILURE
%112 = load i32, i32* @EXIT_SUCCESS
%113 = select i1 %110, i32 %112, i32 %111
br label %114
114: ; preds = %108, %70, %60
%115 = phi i32 [ %69, %60 ], [ %74, %70 ], [ %113, %108 ]
ret i32 %115
}