#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *in;
  char *fname = argv[1];
  unsigned char c;
  int count = 0;
  if (fname == NULL) {
    printf("input name error\n");
    return -1;
  }
  if ((in = fopen(fname, "rb")) == NULL) {
    printf("open file fails\n");
    return -1;
  }
  printf("const unsigned char vmlrd_lzma[] = {\n");
  while (fread(&c, sizeof(unsigned char), 1, in)) {
    printf("0x%02x, ", c);
    count++;
    if (count % 16 == 0)
      printf("\n");
  }
  printf("0x00};\n");
  printf("const unsigned long vmlrd_lzmaSize = sizeof(vmlrd_lzma);\n");
  fclose(in);
  return 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    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118e <main+0x4e>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1260 <main+0x120>
mov    -0x20(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11c6 <main+0x86>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1260 <main+0x120>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x21(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
je     1234 <main+0xf4>
movzbl -0x21(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    122f <main+0xef>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11d4 <main+0x94>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1232 <main+0xd2>
lea    0xe85(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     123b <main+0xdb>
mov    %rax,%rbx
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
lea    0x7(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     120e <main+0xae>
lea    0xe43(%rip),%r14
lea    0x7(%rsp),%r15
jmp    11ed <main+0x8d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
add    $0x1,%ebp
test   %rax,%rax
je     120e <main+0xae>
movzbl 0x7(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
test   $0xf,%bpl
jne    11d0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11d0 <main+0x70>
lea    0xe1c(%rip),%rdi
call   1040 <puts@plt>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    124c <main+0xec>
lea    0xe48(%rip),%rdi
jmp    1242 <main+0xe2>
lea    0xe2f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"input name error\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [17 x i8] c"open file fails\0A\00"
@.str.3 = [38 x i8] c"const unsigned char vmlrd_lzma[] = {\0A\00"
@.str.4 = [9 x i8] c"0x%02x, \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [8 x i8] c"0x00};\0A\00"
@.str.7 = [58 x i8] c"const unsigned long vmlrd_lzmaSize = sizeof(vmlrd_lzma);\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %7
store i32 0, i32* %9
%13 = load i8*, i8** %7
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %46
17: ; preds = %2
%18 = load i8*, i8** %7
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %46
23: ; preds = %17
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %40, %23
%26 = load i32*, i32** %6
%27 = call i64 @fread(i8* %8, i32 1, i32 1, i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %25
%30 = load i8, i8* %8
%31 = zext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = srem i32 %35, 16
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %29
br label %25
41: ; preds = %25
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%44 = load i32*, i32** %6
%45 = call i32 @fclose(i32* %44)
store i32 0, i32* %3
br label %46
46: ; preds = %41, %21, %15
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.4 = [9 x i8] c"0x%02x, \00"
@str = [37 x i8] c"const unsigned char vmlrd_lzma[] = {\00"
@str.8 = [7 x i8] c"0x00};\00"
@str.9 = [57 x i8] c"const unsigned long vmlrd_lzmaSize = sizeof(vmlrd_lzma);\00"
@str.10 = [16 x i8] c"open file fails\00"
@str.11 = [17 x i8] c"input name error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.11, i64 0, i64 0))
br label %35
9: ; preds = %2
%10 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
br label %35
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%16 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %10)
%17 = icmp eq i64 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %14, %28
%19 = phi i32 [ %23, %28 ], [ 0, %14 ]
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i32 %19, 1
%24 = and i32 %23, 15
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = tail call i32 @putchar(i32 10)
br label %28
28: ; preds = %26, %18
%29 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %10)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %18
31: ; preds = %28, %14
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.8, i64 0, i64 0))
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.9, i64 0, i64 0))
%34 = tail call i32 @fclose(i32* %10)
br label %35
35: ; preds = %31, %12, %7
%36 = phi i32 [ -1, %7 ], [ -1, %12 ], [ 0, %31 ]
ret i32 %36
}