#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 EXIT_SUCCESS;
scalar_t__ ftl_unpak(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *std_files[] = {"data.dat", "resource.dat", NULL};
  char **files = std_files;
  int num_written = 0;
  if (argc > 1)
    files = &argv[1];
  while (*files) {
    printf("<<%s\n", *files);
    num_written += ftl_unpak(files[0]);
    ++files;
  }
  printf("%d file(s) written.\n", num_written);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2cc3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cbd(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117c <main+0x5c>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    1181 <main+0x61>
mov    -0x38(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ce <main+0xae>
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1030 <ftl_unpak@plt>
mov    %rax,%rcx
movslq -0x3c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    1181 <main+0x61>
mov    -0x3c(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2ce1(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2cc5(%rip),%xmm0
movaps %xmm0,(%rsp)
add    $0x8,%rsi
cmp    $0x2,%edi
mov    %rsp,%rbx
cmovge %rsi,%rbx
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1193 <main+0x73>
add    $0x8,%rbx
lea    0xeb6(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x8(%rbx),%rdi
call   1030 <ftl_unpak@plt>
add    %eax,%ebp
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1170 <main+0x50>
jmp    1195 <main+0x75>
xor    %ebp,%ebp
lea    0xe80(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"data.dat\00"
@.str.1 = [13 x i8] c"resource.dat\00"
@__const.main.std_files = [3 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [6 x i8] c"<<%s\0A\00"
@.str.3 = [21 x i8] c"%d file(s) written.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i8*]
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [3 x i8*]* %6 to i8*
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %6, i64 0, i64 0
store i8** %10, i8*** %7
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
store i8** %15, i8*** %7
br label %16
16: ; preds = %13, %2
br label %17
17: ; preds = %21, %16
%18 = load i8**, i8*** %7
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i8**, i8*** %7
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8**, i8*** %7
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i64 @ftl_unpak(i8* %27)
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = add nsw i64 %30, %28
%32 = trunc i64 %31 to i32
store i32 %32, i32* %8
%33 = load i8**, i8*** %7
%34 = getelementptr inbounds i8*, i8** %33, i32 1
store i8** %34, i8*** %7
br label %17
35: ; preds = %17
%36 = load i32, i32* %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
@.str = [9 x i8] c"data.dat\00"
@.str.1 = [13 x i8] c"resource.dat\00"
@__const.main.std_files = [3 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [6 x i8] c"<<%s\0A\00"
@.str.3 = [21 x i8] c"%d file(s) written.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i8*]
%4 = bitcast [3 x i8*]* %3 to i8*
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
%6 = icmp sgt i32 %0, 1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = select i1 %6, i8** %7, i8** %5
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %23, label %11
11: ; preds = %2, %11
%12 = phi i8* [ %21, %11 ], [ %9, %2 ]
%13 = phi i32 [ %19, %11 ], [ 0, %2 ]
%14 = phi i8** [ %20, %11 ], [ %8, %2 ]
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%16 = load i8*, i8** %14
%17 = tail call i64 @ftl_unpak(i8* %16)
%18 = trunc i64 %17 to i32
%19 = add i32 %13, %18
%20 = getelementptr inbounds i8*, i8** %14, i64 1
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %11
23: ; preds = %11, %2
%24 = phi i32 [ 0, %2 ], [ %19, %11 ]
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}