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

/* Variables and functions */
scalar_t__ malloc(int);
int merge(int, char **, int, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int sep(int, char **, int, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int error_code = 0;
  int ask_pass = 0, res = 0;
  char *pass;
  pass = (char *)malloc(sizeof(char) * 60);
  if ((strcmp(argv[1], "-m") != 0) && (strcmp(argv[1], "-s") != 0))
    error_code = 1;
  if (argc < 5)
    error_code = 1;
  if ((argc == 6) && (strcmp(argv[5], "-p") != 0))
    error_code = 1;
  if ((argc == 6) && (strcmp(argv[5], "-p") == 0)) {
    ask_pass = 1;
    printf("( password ) : ");
    scanf("%s", pass);
  }
  if (error_code != 1) {
    if (strcmp(argv[1], "-m") == 0)
      res = merge(argc, argv, ask_pass, pass);
    if (strcmp(argv[1], "-s") == 0)
      res = sep(argc, argv, ask_pass, pass);
  } else if (error_code == 1) {
    printf("Syntax Error \n");
    printf("hide-file -m <host_file> <guest_file> <output_file> -p   "
           "//merge\n\t -p can be omitted if you don't want to encrypt "
           "guest_file via password\n");
    printf("\t\t\tOR\n");
    printf("hide-file -s <merged_file> <output_img_file> <output_txt_file> -p  "
           " //separate\n\t -p can be omitted if the merged_file was not "
           "encrypted via password\n");
  }
  if (res == -1)
    printf("Run-time Error\n");
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x3c,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11dc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11dc <main+0x7c>
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11ed <main+0x8d>
movl   $0x1,-0x14(%rbp)
cmpl   $0x6,-0x8(%rbp)
jne    121c <main+0xbc>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xe00(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     121c <main+0xbc>
movl   $0x1,-0x14(%rbp)
cmpl   $0x6,-0x8(%rbp)
jne    1267 <main+0x107>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xdd1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1267 <main+0x107>
movl   $0x1,-0x18(%rbp)
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdb7(%rip),%rdi
call   1070 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
je     12de <main+0x17e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd80(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a5 <main+0x145>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1050 <merge@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12d9 <main+0x179>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1080 <sep@plt>
mov    %eax,-0x1c(%rbp)
jmp    131d <main+0x1bd>
cmpl   $0x1,-0x14(%rbp)
jne    1318 <main+0x1b8>
lea    0xd2d(%rip),%rdi
call   1030 <printf@plt>
lea    0xd30(%rip),%rdi
call   1030 <printf@plt>
lea    0xdaf(%rip),%rdi
call   1030 <printf@plt>
lea    0xdaa(%rip),%rdi
call   1030 <printf@plt>
jmp    131d <main+0x1bd>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1333 <main+0x1d3>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x3c,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    0x8(%rbx),%rdi
lea    0xe67(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r15d,%r15d
mov    $0x0,%ebp
test   %rax,%rax
je     11c4 <main+0x54>
mov    0x8(%rbx),%rdi
lea    0xe4d(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
cmp    $0x5,%r12d
mov    $0x1,%r14d
cmovl  %r14d,%ebp
cmp    $0x6,%r12d
jne    1213 <main+0xa3>
mov    %r13,%r15
mov    0x28(%rbx),%rdi
lea    0xe20(%rip),%r13
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
cmove  %ebp,%r14d
mov    0x28(%rbx),%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     124b <main+0xdb>
mov    %r15,%r13
xor    %r15d,%r15d
test   %r14d,%r14d
jne    121b <main+0xab>
jmp    1274 <main+0x104>
mov    %ebp,%r14d
test   %r14d,%r14d
je     1274 <main+0x104>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
lea    0xdfc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%rdi
jmp    12d9 <main+0x169>
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
lea    0xdbb(%rip),%rdi
mov    %r15,%r13
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    $0x1,%r15d
test   %r14d,%r14d
jne    121b <main+0xab>
mov    0x8(%rbx),%rdi
lea    0xd81(%rip),%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    129e <main+0x12e>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r13,%rcx
call   1060 <merge@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
lea    0xd5a(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12ba <main+0x14a>
cmp    $0xffffffff,%ebp
jne    12de <main+0x16e>
jmp    12d2 <main+0x162>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r13,%rcx
call   1090 <sep@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%ebp
jne    12de <main+0x16e>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-m\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"-p\00"
@.str.3 = [16 x i8] c"( password ) : \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [15 x i8] c"Syntax Error \0A\00"
@.str.6 = [139 x i8] c"hide-file -m <host_file> <guest_file> <output_file> -p //merge\0A\09 -p can be omitted if you don't want to encrypt guest_file via password\0A\00"
@.str.7 = [7 x i8] c"\09\09\09OR\0A\00"
@.str.8 = [150 x i8] c"hide-file -s <merged_file> <output_img_file> <output_txt_file> -p //separate\0A\09 -p can be omitted if the merged_file was not encrypted via password\0A\00"
@.str.9 = [16 x i8] c"Run-time Error\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 i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = call i64 @malloc(i32 60)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %9
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 1, i32* %6
br label %24
24: ; preds = %23, %17, %2
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 5
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 1, i32* %6
br label %28
28: ; preds = %27, %24
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 6
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 5
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %6
br label %38
38: ; preds = %37, %31, %28
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 6
br i1 %40, label %41, label %51
41: ; preds = %38
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 5
%44 = load i8*, i8** %43
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %41
store i32 1, i32* %7
%48 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%49 = load i8*, i8** %9
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %41, %38
%52 = load i32, i32* %6
%53 = icmp ne i32 %52, 1
br i1 %53, label %54, label %79
54: ; preds = %51
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %54
%61 = load i32, i32* %4
%62 = load i8**, i8*** %5
%63 = load i32, i32* %7
%64 = load i8*, i8** %9
%65 = call i32 @merge(i32 %61, i8** %62, i32 %63, i8* %64)
store i32 %65, i32* %8
br label %66
66: ; preds = %60, %54
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %78
72: ; preds = %66
%73 = load i32, i32* %4
%74 = load i8**, i8*** %5
%75 = load i32, i32* %7
%76 = load i8*, i8** %9
%77 = call i32 @sep(i32 %73, i8** %74, i32 %75, i8* %76)
store i32 %77, i32* %8
br label %78
78: ; preds = %72, %66
br label %88
79: ; preds = %51
%80 = load i32, i32* %6
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %87
82: ; preds = %79
%83 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%84 = call i32 @printf(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.6, i64 0, i64 0))
%85 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%86 = call i32 @printf(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.8, i64 0, i64 0))
br label %87
87: ; preds = %82, %79
br label %88
88: ; preds = %87, %78
%89 = load i32, i32* %8
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %93
91: ; preds = %88
%92 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %93
93: ; preds = %91, %88
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-m\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"-p\00"
@.str.3 = [16 x i8] c"( password ) : \00"
@.str.4 = [3 x i8] c"%s\00"
@str = [14 x i8] c"Syntax Error \00"
@str.10 = [138 x i8] c"hide-file -m <host_file> <guest_file> <output_file> -p //merge\0A\09 -p can be omitted if you don't want to encrypt guest_file via password\00"
@str.11 = [6 x i8] c"\09\09\09OR\00"
@str.12 = [149 x i8] c"hide-file -s <merged_file> <output_img_file> <output_txt_file> -p //separate\0A\09 -p can be omitted if the merged_file was not encrypted via password\00"
@str.13 = [15 x i8] c"Run-time Error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i64 @malloc(i32 60)
%4 = inttoptr i64 %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %9, %2
%15 = phi i32 [ 0, %2 ], [ %13, %9 ]
%16 = icmp slt i32 %0, 5
%17 = select i1 %16, i32 1, i32 %15
%18 = icmp eq i32 %0, 6
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = getelementptr inbounds i8*, i8** %1, i64 5
%21 = load i8*, i8** %20
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i32 %17, i32 1
%25 = load i8*, i8** %20
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %19
%29 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%30 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %31
31: ; preds = %14, %28, %19
%32 = phi i32 [ %24, %28 ], [ %24, %19 ], [ %17, %14 ]
%33 = phi i32 [ 1, %28 ], [ 0, %19 ], [ 0, %14 ]
%34 = icmp eq i32 %32, 1
br i1 %34, label %48, label %35
35: ; preds = %31
%36 = load i8*, i8** %5
%37 = tail call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 @merge(i32 %0, i8** %1, i32 %33, i8* %4)
br label %41
41: ; preds = %39, %35
%42 = phi i32 [ %40, %39 ], [ 0, %35 ]
%43 = load i8*, i8** %5
%44 = tail call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %41
%47 = tail call i32 @sep(i32 %0, i8** %1, i32 %33, i8* %4)
br label %52
48: ; preds = %31
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([138 x i8], [138 x i8]* @str.10, i64 0, i64 0))
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.11, i64 0, i64 0))
br label %55
52: ; preds = %41, %46
%53 = phi i32 [ %47, %46 ], [ %42, %41 ]
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %52, %48
%56 = phi i8* [ getelementptr inbounds ([149 x i8], [149 x i8]* @str.12, i64 0, i64 0), %48 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0), %52 ]
%57 = tail call i32 @puts(i8* dereferenceable(1) %56)
br label %58
58: ; preds = %55, %52
ret i32 0
}