#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 */
int /*<<< orphan*/ decode(char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
char *strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Error, no input given.\n");
    return (0);
  }
  char *filename = argv[1];
  int filename_size = strlen(filename);
  char *outfile = (char *)malloc(filename_size + 5 * sizeof(char));
  strcpy(outfile, filename);
  outfile = strcat(outfile, ".unhuff");
  decode(filename, outfile);
  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)
cmpl   $0x2,-0x8(%rbp)
jge    1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f8 <main+0x98>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
add    $0x5,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1080 <strcat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <decode@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1167 <main+0x17>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
jmp    11aa <main+0x5a>
mov    0x8(%rsi),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x5(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movabs $0x666675686e752e,%rcx
mov    %rcx,(%rbx,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <decode@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Error, no input given.\0A\00"
@.str.1 = [8 x i8] c".unhuff\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %33
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = add i64 %20, 5
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = load i8*, i8** %6
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %8
%29 = call i8* @strcat(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %29, i8** %8
%30 = load i8*, i8** %6
%31 = load i8*, i8** %8
%32 = call i32 @decode(i8* %30, i8* %31)
store i32 0, i32* %3
br label %33
33: ; preds = %13, %11
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@str = [23 x i8] c"Error, no input given.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %18
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = add i32 %9, 5
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @strcpy(i8* %12, i8* %8)
%14 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %12)
%15 = getelementptr i8, i8* %12, i64 %14
%16 = bitcast i8* %15 to i64*
store i64 28823102073763118, i64* %16
%17 = tail call i32 @decode(i8* %8, i8* %12)
br label %18
18: ; preds = %6, %4
ret i32 0
}