#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ output_file(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *rp;
  int i = 0;
  printf("struct DATAPACK datapacks[] = {\n");
  for (i = 1; i < argc; ++i) {
    rp = fopen(argv[i], "rb");
    if (rp != NULL)
      output_file(rp, argv[i]);
    fclose(rp);
  }
  printf("{NULL, NULL, 0}};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cf <main+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b8 <main+0x78>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <output_file@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <main+0x30>
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebx
jl     11a3 <main+0x63>
mov    %ebx,%r12d
mov    $0x1,%ebx
lea    0xe92(%rip),%r14
jmp    1181 <main+0x41>
mov    %r13,%rdi
call   1050 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     11a3 <main+0x63>
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
je     1170 <main+0x30>
mov    (%r15,%rbx,8),%rsi
mov    %r13,%rdi
call   1040 <output_file@plt>
jmp    1170 <main+0x30>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"struct DATAPACK datapacks[] = {\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [19 x i8] c"{NULL, NULL, 0}};\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %7
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %36
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%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 ne i32* %20, null
br i1 %21, label %22, label %30
22: ; preds = %13
%23 = load i32*, i32** %6
%24 = load i8**, i8*** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @output_file(i32* %23, i8* %28)
br label %30
30: ; preds = %22, %13
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %30
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %9
36: ; preds = %9
%37 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@str = [32 x i8] c"struct DATAPACK datapacks[] = {\00"
@str.3 = [18 x i8] c"{NULL, NULL, 0}};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %16
%8 = phi i64 [ 1, %5 ], [ %18, %16 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %7
%14 = load i8*, i8** %9
%15 = tail call i32 @output_file(i32* %11, i8* %14)
br label %16
16: ; preds = %13, %7
%17 = tail call i32 @fclose(i32* %11)
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %16, %2
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}