#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*/ MD5String(unsigned char *, unsigned char *);
int /*<<< orphan*/ decode_file(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ prng_seed(unsigned char *);
int /*<<< orphan*/ stderr;
int decode_steg(char *file_input, char *file_output, unsigned char *key) {
  FILE *fpi, *fpo;
  unsigned char digest[16];
  if ((fpi = fopen(file_input, "rb")) == NULL) {
    fprintf(stderr, "Cannot open input file!\n");
    return (-1);
  }
  if ((fpo = fopen(file_output, "wb")) == NULL) {
    fprintf(stderr, "Cannot open output file!\n");
    return (-1);
  }
  MD5String(key, digest);
  prng_seed(digest);
  decode_file(fpi, fpo);
  fclose(fpi);
  fclose(fpo);
  return (0);
}


x86 assembly (clang, -O0):
<decode_steg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b3 <decode_steg+0x53>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <decode_steg+0xce>
mov    -0x18(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11f2 <decode_steg+0x92>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <decode_steg+0xce>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <MD5String@plt>
lea    -0x40(%rbp),%rdi
call   1050 <prng_seed@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <decode_file@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_steg>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11d1 <decode_steg+0x71>
mov    %rax,%rbx
lea    0xe90(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11e3 <decode_steg+0x83>
mov    %rax,%r15
mov    %rsp,%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <MD5String@plt>
mov    %r12,%rdi
call   1050 <prng_seed@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <decode_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11fd <decode_steg+0x9d>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
jmp    11f3 <decode_steg+0x93>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Cannot open input file!\0A\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [26 x i8] c"Cannot open output file!\0A\00"
define i32 @decode_steg(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [16 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %37
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %9
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %37
24: ; preds = %17
%25 = load i8*, i8** %7
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%27 = call i32 @MD5String(i8* %25, i8* %26)
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%29 = call i32 @prng_seed(i8* %28)
%30 = load i32*, i32** %8
%31 = load i32*, i32** %9
%32 = call i32 @decode_file(i32* %30, i32* %31)
%33 = load i32*, i32** %8
%34 = call i32 @fclose(i32* %33)
%35 = load i32*, i32** %9
%36 = call i32 @fclose(i32* %35)
store i32 0, i32* %4
br label %37
37: ; preds = %24, %21, %14
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Cannot open input file!\0A\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [26 x i8] c"Cannot open output file!\0A\00"
define i32 @decode_steg(i8* nocapture %0, i8* nocapture %1, i8* %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %23
11: ; preds = %3
%12 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %23
17: ; preds = %11
%18 = call i32 @MD5String(i8* %2, i8* %5)
%19 = call i32 @prng_seed(i8* %5)
%20 = call i32 @decode_file(i32* %6, i32* %12)
%21 = call i32 @fclose(i32* %6)
%22 = call i32 @fclose(i32* %12)
br label %23
23: ; preds = %17, %14, %8
%24 = phi i32 [ -1, %8 ], [ -1, %14 ], [ 0, %17 ]
ret i32 %24
}