#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 */
char *MD5File(char *, char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int EncodeFiles(char *fileList) {
  FILE *filePtr;
  int retval = 0;
  char fileName[1024];
  char buf[33];
  char *p;
  int count = 0;
  printf("char* fileList[] = {\n");
  filePtr = fopen(fileList, "r");
  while (fgets(fileName, 1024, filePtr)) {
    fileName[strlen(fileName) - 1] = 0;
    p = MD5File(fileName, buf);
    if (p)
      printf("\"%s = %s\",\n", fileName, p);
  }
  printf("\"LASTFILE = 0\",\n");
  printf("};\n");
  retval = -1;
  return retval;
}


x86 assembly (clang, -O0):
<EncodeFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x45c(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1213 <EncodeFiles+0xc3>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1070 <MD5File@plt>
mov    %rax,-0x458(%rbp)
cmpq   $0x0,-0x458(%rbp)
je     120e <EncodeFiles+0xbe>
lea    -0x420(%rbp),%rsi
mov    -0x458(%rbp),%rdx
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1192 <EncodeFiles+0x42>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EncodeFiles>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rdi,%rbx
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1206 <EncodeFiles+0xa6>
mov    %rsp,%r15
lea    0xe4f(%rip),%r12
jmp    11d5 <EncodeFiles+0x75>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1206 <EncodeFiles+0xa6>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <MD5File@plt>
test   %rax,%rax
je     11c0 <EncodeFiles+0x60>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c0 <EncodeFiles+0x60>
lea    0xe16(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"char* fileList[] = {\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"\22%s = %s\22,\0A\00"
@.str.3 = [17 x i8] c"\22LASTFILE = 0\22,\0A\00"
@.str.4 = [4 x i8] c"};\0A\00"
define i32 @EncodeFiles(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca [33 x i8]
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %2
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %3
br label %12
12: ; preds = %32, %1
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = load i32*, i32** %3
%15 = call i64 @fgets(i8* %13, i32 1024, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %12
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %21
store i8 0, i8* %22
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%25 = call i8* @MD5File(i8* %23, i8* %24)
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %17
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%30 = load i8*, i8** %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %30)
br label %32
32: ; preds = %28, %17
br label %12
33: ; preds = %12
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %4
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"\22%s = %s\22,\0A\00"
@str = [21 x i8] c"char* fileList[] = {\00"
@str.5 = [16 x i8] c"\22LASTFILE = 0\22,\00"
@str.6 = [3 x i8] c"};\00"
define i32 @EncodeFiles(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca [33 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i64 @fgets(i8* %4, i32 1024, i32* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %1, %19
%11 = call i32 @strlen(i8* %4)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i8* @MD5File(i8* %4, i8* %5)
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %15)
br label %19
19: ; preds = %17, %10
%20 = call i64 @fgets(i8* %4, i32 1024, i32* %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %10
22: ; preds = %19, %1
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.6, i64 0, i64 0))
ret i32 -1
}