#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
char *get_option(char *, char **, int);
int hide(char *, size_t, char *, char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char *);
int hide_stuff(int argc, char **argv) {
  FILE *fp = NULL;
  int exit_code = 1;
  char *option = NULL;
  char *input_buf = NULL;
  char *output_path = NULL;
  char *cover_path = NULL;
  size_t input_buf_size = 0;
  if ((option = get_option("input-file", argv, argc)) != NULL) {
    fp = fopen(option, "rb");
    if (fp == NULL) {
      printf("ERROR: unable to open the file \"%s\".\n", option);
      return 1;
    }
    fseek(fp, 0L, SEEK_END);
    input_buf_size = ftell(fp);
    fseek(fp, 0L, SEEK_SET);
    input_buf = (char *)malloc(input_buf_size + 1);
    if (input_buf == NULL) {
      printf("PANIC: no memory.\n");
      exit(1);
    }
    fread(input_buf, 1, input_buf_size, fp);
  } else if ((input_buf = get_option("input-buf", argv, argc)) != NULL) {
    input_buf_size = strlen(input_buf);
  } else {
    printf("OPTION PARSING ERROR: --input-file=<filepath> or "
           "--input-buf=<data> must be supplied.\n");
    return 1;
  }
  output_path = get_option("output-file", argv, argc);
  if (output_path == NULL) {
    printf(
        "OPTION PARSING ERROR: --output-file=<filepath> must be supplied.\n");
    return 1;
  }
  cover_path = get_option("cover-file", argv, argc);
  if (cover_path == NULL) {
    printf("OPTION PARSING ERROR: --cover-file=<filepath> must be supplied.\n");
    return 1;
  }
  exit_code = hide(input_buf, input_buf_size, cover_path, output_path);
  if (fp != NULL) {
    fclose(fp);
    free(input_buf);
  }
  return exit_code;
}


x86 assembly (clang, -O0):
<hide_stuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xdec(%rip),%rdi
call   10e0 <get_option@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     12ec <hide_stuff+0x12c>
mov    -0x28(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1264 <hide_stuff+0xa4>
mov    -0x28(%rbp),%rsi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13f1 <hide_stuff+0x231>
mov    -0x18(%rbp),%rdi
mov    0x2d79(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d46(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    -0x48(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12d1 <hide_stuff+0x111>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
jmp    133e <hide_stuff+0x17e>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xd4d(%rip),%rdi
call   10e0 <get_option@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     131f <hide_stuff+0x15f>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x48(%rbp)
jmp    1339 <hide_stuff+0x179>
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13f1 <hide_stuff+0x231>
jmp    133e <hide_stuff+0x17e>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xd5c(%rip),%rdi
call   10e0 <get_option@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    137a <hide_stuff+0x1ba>
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13f1 <hide_stuff+0x231>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xd6e(%rip),%rdi
call   10e0 <get_option@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13b6 <hide_stuff+0x1f6>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13f1 <hide_stuff+0x231>
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
call   1080 <hide@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     13eb <hide_stuff+0x22b>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hide_stuff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r13d
lea    0xe18(%rip),%rdi
mov    %r13d,%edx
call   10f0 <get_option@plt>
test   %rax,%rax
je     126f <hide_stuff+0x9f>
mov    %rax,%rbp
lea    0xe0c(%rip),%rsi
mov    %rax,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12f5 <hide_stuff+0x125>
mov    %rax,%rbx
mov    0x2dce(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %rbx,%rdi
call   10a0 <ftell@plt>
mov    %rax,%r12
mov    0x2da0(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
lea    0x1(%r12),%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     133c <hide_stuff+0x16c>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1050 <fread@plt>
jmp    129a <hide_stuff+0xca>
lea    0xdbe(%rip),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   10f0 <get_option@plt>
test   %rax,%rax
je     131a <hide_stuff+0x14a>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <strlen@plt>
mov    %rax,%r12
xor    %ebx,%ebx
lea    0xd9d(%rip),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   10f0 <get_option@plt>
test   %rax,%rax
je     1308 <hide_stuff+0x138>
mov    %rax,%rbp
lea    0xd8f(%rip),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   10f0 <get_option@plt>
test   %rax,%rax
je     1311 <hide_stuff+0x141>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
mov    %rbp,%rcx
call   1090 <hide@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     132b <hide_stuff+0x15b>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    132b <hide_stuff+0x15b>
lea    0xd12(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1326 <hide_stuff+0x156>
lea    0xddc(%rip),%rdi
jmp    1321 <hide_stuff+0x151>
lea    0xd93(%rip),%rdi
jmp    1321 <hide_stuff+0x151>
lea    0xd34(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"input-file\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [38 x i8] c"ERROR: unable to open the file \22%s\22.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [19 x i8] c"PANIC: no memory.\0A\00"
@.str.4 = [10 x i8] c"input-buf\00"
@.str.5 = [87 x i8] c"OPTION PARSING ERROR: --input-file=<filepath> or --input-buf=<data> must be supplied.\0A\00"
@.str.6 = [12 x i8] c"output-file\00"
@.str.7 = [66 x i8] c"OPTION PARSING ERROR: --output-file=<filepath> must be supplied.\0A\00"
@.str.8 = [11 x i8] c"cover-file\00"
@.str.9 = [65 x i8] c"OPTION PARSING ERROR: --cover-file=<filepath> must be supplied.\0A\00"
define i32 @hide_stuff(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32 1, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i64 0, i64* %12
%13 = load i8**, i8*** %5
%14 = load i32, i32* %4
%15 = call i8* @get_option(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %13, i32 %14)
store i8* %15, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %48
17: ; preds = %2
%18 = load i8*, i8** %8
%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 = load i32*, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %90
25: ; preds = %17
%26 = load i32*, i32** %6
%27 = load i32, i32* @SEEK_END
%28 = call i32 @fseek(i32* %26, i64 0, i32 %27)
%29 = load i32*, i32** %6
%30 = call i64 @ftell(i32* %29)
store i64 %30, i64* %12
%31 = load i32*, i32** %6
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @fseek(i32* %31, i64 0, i32 %32)
%34 = load i64, i64* %12
%35 = add i64 %34, 1
%36 = call i64 @malloc(i64 %35)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %9
%38 = load i8*, i8** %9
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %43
40: ; preds = %25
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %25
%44 = load i8*, i8** %9
%45 = load i64, i64* %12
%46 = load i32*, i32** %6
%47 = call i32 @fread(i8* %44, i32 1, i64 %45, i32* %46)
br label %59
48: ; preds = %2
%49 = load i8**, i8*** %5
%50 = load i32, i32* %4
%51 = call i8* @get_option(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %49, i32 %50)
store i8* %51, i8** %9
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i8*, i8** %9
%55 = call i64 @strlen(i8* %54)
store i64 %55, i64* %12
br label %58
56: ; preds = %48
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %90
58: ; preds = %53
br label %59
59: ; preds = %58, %43
%60 = load i8**, i8*** %5
%61 = load i32, i32* %4
%62 = call i8* @get_option(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8** %60, i32 %61)
store i8* %62, i8** %10
%63 = load i8*, i8** %10
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %67
65: ; preds = %59
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %90
67: ; preds = %59
%68 = load i8**, i8*** %5
%69 = load i32, i32* %4
%70 = call i8* @get_option(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8** %68, i32 %69)
store i8* %70, i8** %11
%71 = load i8*, i8** %11
%72 = icmp eq i8* %71, null
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %90
75: ; preds = %67
%76 = load i8*, i8** %9
%77 = load i64, i64* %12
%78 = load i8*, i8** %11
%79 = load i8*, i8** %10
%80 = call i32 @hide(i8* %76, i64 %77, i8* %78, i8* %79)
store i32 %80, i32* %7
%81 = load i32*, i32** %6
%82 = icmp ne i32* %81, null
br i1 %82, label %83, label %88
83: ; preds = %75
%84 = load i32*, i32** %6
%85 = call i32 @fclose(i32* %84)
%86 = load i8*, i8** %9
%87 = call i32 @free(i8* %86)
br label %88
88: ; preds = %83, %75
%89 = load i32, i32* %7
store i32 %89, i32* %3
br label %90
90: ; preds = %88, %73, %65, %56, %22
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [11 x i8] c"input-file\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [38 x i8] c"ERROR: unable to open the file \22%s\22.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [10 x i8] c"input-buf\00"
@.str.6 = [12 x i8] c"output-file\00"
@.str.8 = [11 x i8] c"cover-file\00"
@str = [86 x i8] c"OPTION PARSING ERROR: --input-file=<filepath> or --input-buf=<data> must be supplied.\00"
@str.10 = [64 x i8] c"OPTION PARSING ERROR: --cover-file=<filepath> must be supplied.\00"
@str.11 = [65 x i8] c"OPTION PARSING ERROR: --output-file=<filepath> must be supplied.\00"
@str.12 = [18 x i8] c"PANIC: no memory.\00"
define i32 @hide_stuff(i32 %0, i8** %1) {
%3 = tail call i8* @get_option(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1, i32 %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %25, label %5
5: ; preds = %2
%6 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %51
10: ; preds = %5
%11 = load i32, i32* @SEEK_END
%12 = tail call i32 @fseek(i32* %6, i64 0, i32 %11)
%13 = tail call i64 @ftell(i32* %6)
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %6, i64 0, i32 %14)
%16 = add i64 %13, 1
%17 = tail call i64 @malloc(i64 %16)
%18 = inttoptr i64 %17 to i8*
%19 = icmp eq i64 %17, 0
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %10
%24 = tail call i32 @fread(i8* %18, i32 1, i64 %13, i32* %6)
br label %32
25: ; preds = %2
%26 = tail call i8* @get_option(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %1, i32 %0)
%27 = icmp eq i8* %26, null
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call i64 @strlen(i8* %26)
br label %32
30: ; preds = %25
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str, i64 0, i64 0))
br label %51
32: ; preds = %28, %23
%33 = phi i32* [ %6, %23 ], [ null, %28 ]
%34 = phi i8* [ %18, %23 ], [ %26, %28 ]
%35 = phi i64 [ %13, %23 ], [ %29, %28 ]
%36 = tail call i8* @get_option(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8** %1, i32 %0)
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.11, i64 0, i64 0))
br label %51
40: ; preds = %32
%41 = tail call i8* @get_option(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8** %1, i32 %0)
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.10, i64 0, i64 0))
br label %51
45: ; preds = %40
%46 = tail call i32 @hide(i8* %34, i64 %35, i8* %41, i8* %36)
%47 = icmp eq i32* %33, null
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = tail call i32 @fclose(i32* %33)
%50 = tail call i32 @free(i8* %34)
br label %51
51: ; preds = %45, %48, %43, %38, %30, %8
%52 = phi i32 [ 1, %8 ], [ 1, %38 ], [ 1, %43 ], [ 1, %30 ], [ %46, %48 ], [ %46, %45 ]
ret i32 %52
}