#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print(int /*<<< orphan*/ *, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *in = stdin, *out = stdout;
  long in_size;
  if (argc > 3) {
    fprintf(stderr, "Usage: fsimgtoc [IN [OUT]]\n");
    exit(1);
  }
  if (argc > 2 && strcmp(argv[2], "-") != 0 &&
      (out = fopen(argv[2], "wb")) == 0) {
    perror(argv[2]);
    exit(1);
  }
  if (argc > 1 && strcmp(argv[1], "-") != 0 &&
      (in = fopen(argv[1], "rb")) == 0) {
    perror(argv[1]);
    exit(1);
  }
  if (fseek(in, 0, SEEK_END) < 0) {
    perror(argv[1]);
    exit(1);
  }
  in_size = ftell(in);
  if (fseek(in, 0, SEEK_SET) < 0) {
    perror(argv[1]);
    exit(1);
  }
  fprintf(out,
          "#include <linux/autoconf.h>\n#include <linux/version.h>\n#include "
          "<linux/module.h>\n#include <linux/types.h>\n\n");
  print(in, in_size, out);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    11dc <main+0x5c>
mov    0x2e0d(%rip),%rax
mov    (%rax),%rdi
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jle    123d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe27(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     123d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    123d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jle    129e <main+0x11e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     129e <main+0x11e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdad(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    129e <main+0x11e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d3f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
cmp    $0x0,%rax
jge    12d3 <main+0x153>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2cdd(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
cmp    $0x0,%rax
jge    1315 <main+0x195>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xd04(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <print@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x4,%edi
jl     11b7 <main+0x37>
mov    0x2e3c(%rip),%rax
mov    (%rax),%rcx
lea    0xe62(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rsi,%rbx
mov    0x2e1f(%rip),%rax
mov    (%rax),%r15
mov    0x2df5(%rip),%rax
mov    (%rax),%r14
cmp    $0x3,%edi
jne    1206 <main+0x86>
mov    0x10(%rbx),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120b <main+0x8b>
mov    0x10(%rbx),%rdi
lea    0xe2b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    120b <main+0x8b>
mov    0x10(%rbx),%rdi
jmp    1277 <main+0xf7>
cmp    $0x2,%edi
jl     1238 <main+0xb8>
mov    0x8(%rbx),%rdi
lea    0xe06(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1238 <main+0xb8>
mov    0x8(%rbx),%rdi
lea    0xdf6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1273 <main+0xf3>
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
test   %rax,%rax
js     1273 <main+0xf3>
mov    %r15,%rdi
call   1050 <ftell@plt>
mov    %rax,%r12
mov    0x2d66(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
test   %rax,%rax
jns    1286 <main+0x106>
mov    0x8(%rbx),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xd97(%rip),%rdi
mov    $0x6b,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <print@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32* null
@.str = [28 x i8] c"Usage: fsimgtoc [IN [OUT]]\0A\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [108 x i8] c"#include <linux/autoconf.h>\0A#include <linux/version.h>\0A#include <linux/module.h>\0A#include <linux/types.h>\0A\0A\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 i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32*, i32** @stdin
store i32* %9, i32** %6
%10 = load i32*, i32** @stdout
store i32* %10, i32** %7
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 3
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32*, i32** @stderr
%15 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %38
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %7
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %38
32: ; preds = %26
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @perror(i8* %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %26, %20, %17
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 1
br i1 %40, label %41, label %59
41: ; preds = %38
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %59
47: ; preds = %41
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %51, i32** %6
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %59
53: ; preds = %47
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @perror(i8* %56)
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %47, %41, %38
%60 = load i32*, i32** %6
%61 = load i32, i32* @SEEK_END
%62 = call i64 @fseek(i32* %60, i32 0, i32 %61)
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %59
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32 @perror(i8* %67)
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %59
%71 = load i32*, i32** %6
%72 = call i64 @ftell(i32* %71)
store i64 %72, i64* %8
%73 = load i32*, i32** %6
%74 = load i32, i32* @SEEK_SET
%75 = call i64 @fseek(i32* %73, i32 0, i32 %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %83
77: ; preds = %70
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = call i32 @perror(i8* %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %70
%84 = load i32*, i32** %7
%85 = call i32 @fprintf(i32* %84, i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.4, i64 0, i64 0))
%86 = load i32*, i32** %6
%87 = load i64, i64* %8
%88 = load i32*, i32** %7
%89 = call i32 @print(i32* %86, i64 %87, i32* %88)
%90 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32* null
@.str = [28 x i8] c"Usage: fsimgtoc [IN [OUT]]\0A\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [108 x i8] c"#include <linux/autoconf.h>\0A#include <linux/version.h>\0A#include <linux/module.h>\0A#include <linux/types.h>\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32*, i32** @stdin
%4 = load i32*, i32** @stdout
%5 = icmp sgt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i64 27, i64 1, i32* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = icmp eq i32 %0, 3
br i1 %11, label %12, label %25
12: ; preds = %10
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i8*, i8** %13
%23 = tail call i32 @perror(i8* %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %10
%26 = icmp sgt i32 %0, 1
br i1 %26, label %27, label %41
27: ; preds = %12, %17, %25
%28 = phi i32* [ %4, %25 ], [ %4, %12 ], [ %19, %17 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %41, label %33
33: ; preds = %27
%34 = load i8*, i8** %29
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i8*, i8** %29
%39 = tail call i32 @perror(i8* %38)
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %33, %27, %25
%42 = phi i32* [ %28, %33 ], [ %28, %27 ], [ %4, %25 ]
%43 = phi i32* [ %35, %33 ], [ %3, %27 ], [ %3, %25 ]
%44 = load i32, i32* @SEEK_END
%45 = tail call i64 @fseek(i32* %43, i32 0, i32 %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %41
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = tail call i32 @perror(i8* %49)
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %41
%53 = tail call i64 @ftell(i32* %43)
%54 = load i32, i32* @SEEK_SET
%55 = tail call i64 @fseek(i32* %43, i32 0, i32 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %52
%58 = getelementptr inbounds i8*, i8** %1, i64 1
%59 = load i8*, i8** %58
%60 = tail call i32 @perror(i8* %59)
%61 = tail call i32 @exit(i32 1)
unreachable
62: ; preds = %52
%63 = tail call i64 @fwrite(i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.4, i64 0, i64 0), i64 107, i64 1, i32* %42)
%64 = tail call i32 @print(i32* %43, i64 %53, i32* %42)
%65 = tail call i32 @exit(i32 0)
unreachable
}