#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*/ SEEK_END;
int /*<<< orphan*/ SHA1(char *, int /*<<< orphan*/, unsigned char *);
int SHA_DIGEST_LENGTH;
char *encodeInt(int);
char *encodeString(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, ...);
char *infoDict(char *filename) {
  char ans[10000] = "d";
  char tempAns[10000] = "";
  FILE *file = fopen(filename, "r");
  strncat(ans, encodeString("length"), 10000);
  fseek(file, 0, SEEK_END);
  strncat(ans, encodeInt(ftell(file)), 10000);
  rewind(file);
  strncat(ans, encodeString("name"), 10000);
  strncat(ans, encodeString(filename), 10000);
  strncat(ans, encodeString("piece length"), 10000);
  strncat(ans, encodeInt(262144), 10000);
  strncat(ans, encodeString("pieces"), 10000);
  char buffer[262144];
  unsigned char sha[SHA_DIGEST_LENGTH];
  char pieceSHAs[10000] = "";
  while (fread(buffer, 1, 262144, file) == 262144) {
    SHA1(buffer, strlen(buffer), sha);
    strncat(pieceSHAs, sha, 10000);
  }
  SHA1(buffer, strlen(buffer), sha);
  strncat(pieceSHAs, sha, 10000);
  strncat(ans, encodeString(pieceSHAs), 10000);
  strncat(ans, "e", 10000);
  return ans;
}


x86 assembly (clang, -O0):
<infoDict>:
push   %rbp
mov    %rsp,%rbp
sub    $0x475a0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x2720(%rbp),%rdi
mov    %rdi,-0x47578(%rbp)
xor    %esi,%esi
mov    %esi,-0x4757c(%rbp)
mov    $0x2710,%edx
mov    %rdx,-0x47588(%rbp)
call   1070 <memset@plt>
mov    -0x47588(%rbp),%rdx
mov    -0x4757c(%rbp),%esi
movb   $0x64,-0x2720(%rbp)
lea    -0x4e30(%rbp),%rdi
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x4e38(%rbp)
lea    0xde9(%rip),%rdi
call   1040 <encodeString@plt>
mov    -0x47578(%rbp),%rdi
mov    %rax,%rsi
mov    -0x4757c(%rbp),%eax
mov    %al,-0x47569(%rbp)
mov    $0x2710,%edx
mov    %edx,-0x47570(%rbp)
call   1080 <strncat@plt>
mov    -0x4757c(%rbp),%esi
mov    -0x4e38(%rbp),%rdi
mov    0x2d85(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
mov    -0x4e38(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,%edi
call   10a0 <encodeInt@plt>
mov    -0x47578(%rbp),%rdi
mov    -0x47570(%rbp),%edx
mov    %rax,%rsi
mov    -0x47569(%rbp),%al
call   1080 <strncat@plt>
mov    -0x4e38(%rbp),%rdi
call   1060 <rewind@plt>
lea    0xd57(%rip),%rdi
call   1040 <encodeString@plt>
mov    -0x47578(%rbp),%rdi
mov    -0x47570(%rbp),%edx
mov    %rax,%rsi
mov    -0x47569(%rbp),%al
call   1080 <strncat@plt>
mov    -0x8(%rbp),%rdi
call   1040 <encodeString@plt>
mov    -0x47578(%rbp),%rdi
mov    -0x47570(%rbp),%edx
mov    %rax,%rsi
mov    -0x47569(%rbp),%al
call   1080 <strncat@plt>
lea    0xd11(%rip),%rdi
call   1040 <encodeString@plt>
mov    -0x47578(%rbp),%rdi
mov    -0x47570(%rbp),%edx
mov    %rax,%rsi
mov    -0x47569(%rbp),%al
call   1080 <strncat@plt>
mov    $0x40000,%edi
call   10a0 <encodeInt@plt>
mov    -0x47578(%rbp),%rdi
mov    -0x47570(%rbp),%edx
mov    %rax,%rsi
mov    -0x47569(%rbp),%al
call   1080 <strncat@plt>
lea    0xcd2(%rip),%rdi
call   1040 <encodeString@plt>
mov    -0x47578(%rbp),%rdi
mov    -0x47570(%rbp),%edx
mov    %rax,%rsi
mov    -0x47569(%rbp),%al
call   1080 <strncat@plt>
mov    0x2c77(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x44e48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x47568(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x44e50(%rbp)
lea    -0x47560(%rbp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1070 <memset@plt>
lea    -0x44e40(%rbp),%rdi
mov    -0x4e38(%rbp),%rcx
mov    $0x1,%esi
mov    $0x40000,%edx
call   1030 <fread@plt>
cmp    $0x40000,%eax
jne    1420 <infoDict+0x270>
lea    -0x44e40(%rbp),%rax
mov    %rax,-0x47590(%rbp)
lea    -0x44e40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x47590(%rbp),%rdi
mov    -0x47568(%rbp),%rdx
mov    %eax,%esi
call   10c0 <SHA1@plt>
mov    -0x47568(%rbp),%rsi
lea    -0x47560(%rbp),%rdi
mov    $0x2710,%edx
mov    $0x0,%al
call   1080 <strncat@plt>
jmp    13aa <infoDict+0x1fa>
lea    -0x44e40(%rbp),%rax
mov    %rax,-0x475a0(%rbp)
lea    -0x44e40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x475a0(%rbp),%rdi
mov    -0x47568(%rbp),%rdx
mov    %eax,%esi
call   10c0 <SHA1@plt>
mov    -0x47568(%rbp),%rsi
lea    -0x47560(%rbp),%rdi
mov    $0x2710,%edx
mov    $0x0,%al
call   1080 <strncat@plt>
lea    -0x2720(%rbp),%rax
mov    %rax,-0x47598(%rbp)
lea    -0x47560(%rbp),%rdi
call   1040 <encodeString@plt>
mov    -0x47598(%rbp),%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
mov    $0x0,%al
call   1080 <strncat@plt>
lea    -0x2720(%rbp),%rdi
lea    0xb5e(%rip),%rsi
mov    $0x2710,%edx
mov    $0x0,%al
call   1080 <strncat@plt>
lea    -0x2720(%rbp),%rax
mov    -0x44e48(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<infoDict>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x44e28,%rsp
mov    %rdi,%rbx
lea    -0x4e50(%rbp),%r14
mov    $0x2710,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
movb   $0x64,-0x4e50(%rbp)
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
mov    %rax,%r15
lea    0xe10(%rip),%rdi
call   1040 <encodeString@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r15,%rdi
call   1090 <ftell@plt>
mov    %eax,%edi
call   10a0 <encodeInt@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    %r15,%rdi
call   1060 <rewind@plt>
lea    0xdab(%rip),%rdi
call   1040 <encodeString@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    %rbx,%rdi
call   1040 <encodeString@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
lea    0xd78(%rip),%rdi
call   1040 <encodeString@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    $0x40000,%edi
call   10a0 <encodeInt@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
lea    0xd4b(%rip),%rdi
call   1040 <encodeString@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    %rsp,%r13
mov    0x2cf6(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    -0x2740(%rbp),%rdi
mov    $0x2710,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    -0x44e50(%rbp),%rdi
mov    $0x1,%esi
mov    $0x40000,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x40000,%eax
jne    1383 <infoDict+0x1d3>
lea    -0x44e50(%rbp),%rbx
lea    -0x2740(%rbp),%r12
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   10c0 <SHA1@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x40000,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x40000,%eax
je     1340 <infoDict+0x190>
lea    -0x44e50(%rbp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   10c0 <SHA1@plt>
lea    -0x2740(%rbp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    %rbx,%rdi
call   1040 <encodeString@plt>
lea    -0x4e50(%rbp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
lea    0xc25(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2710,%edx
xor    %eax,%eax
call   1080 <strncat@plt>
mov    %r13,%rsp
mov    %rbx,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"length\00"
@SEEK_END = global i32 0
@.str.2 = [5 x i8] c"name\00"
@.str.3 = [13 x i8] c"piece length\00"
@.str.4 = [7 x i8] c"pieces\00"
@SHA_DIGEST_LENGTH = global i32 0
@.str.5 = [2 x i8] c"e\00"
define i8* @infoDict(i8* %0) {
%2 = alloca i8*
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = alloca i32*
%6 = alloca [262144 x i8]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca [10000 x i8]
store i8* %0, i8** %2
%10 = bitcast [10000 x i8]* %3 to i8*
%11 = bitcast i8* %10 to [10000 x i8]*
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %11, i32 0, i32 0
store i8 100, i8* %12
%13 = bitcast [10000 x i8]* %4 to i8*
%14 = load i8*, i8** %2
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %5
%16 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%17 = call i8* @encodeString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (i8*, ...) @strncat(i8* %16, i8* %17, i32 10000)
%19 = load i32*, i32** %5
%20 = load i32, i32* @SEEK_END
%21 = call i32 @fseek(i32* %19, i32 0, i32 %20)
%22 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%23 = load i32*, i32** %5
%24 = call i32 @ftell(i32* %23)
%25 = call i8* @encodeInt(i32 %24)
%26 = call i32 (i8*, ...) @strncat(i8* %22, i8* %25, i32 10000)
%27 = load i32*, i32** %5
%28 = call i32 @rewind(i32* %27)
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%30 = call i8* @encodeString(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 (i8*, ...) @strncat(i8* %29, i8* %30, i32 10000)
%32 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%33 = load i8*, i8** %2
%34 = call i8* @encodeString(i8* %33)
%35 = call i32 (i8*, ...) @strncat(i8* %32, i8* %34, i32 10000)
%36 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%37 = call i8* @encodeString(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 (i8*, ...) @strncat(i8* %36, i8* %37, i32 10000)
%39 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%40 = call i8* @encodeInt(i32 262144)
%41 = call i32 (i8*, ...) @strncat(i8* %39, i8* %40, i32 10000)
%42 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%43 = call i8* @encodeString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 (i8*, ...) @strncat(i8* %42, i8* %43, i32 10000)
%45 = load i32, i32* @SHA_DIGEST_LENGTH
%46 = zext i32 %45 to i64
%47 = call i8* @llvm.stacksave()
store i8* %47, i8** %7
%48 = alloca i8, i64 %46
store i64 %46, i64* %8
%49 = bitcast [10000 x i8]* %9 to i8*
br label %50
50: ; preds = %55, %1
%51 = getelementptr inbounds [262144 x i8], [262144 x i8]* %6, i64 0, i64 0
%52 = load i32*, i32** %5
%53 = call i32 @fread(i8* %51, i32 1, i32 262144, i32* %52)
%54 = icmp eq i32 %53, 262144
br i1 %54, label %55, label %62
55: ; preds = %50
%56 = getelementptr inbounds [262144 x i8], [262144 x i8]* %6, i64 0, i64 0
%57 = getelementptr inbounds [262144 x i8], [262144 x i8]* %6, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = call i32 @SHA1(i8* %56, i32 %58, i8* %48)
%60 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%61 = call i32 (i8*, ...) @strncat(i8* %60, i8* %48, i32 10000)
br label %50
62: ; preds = %50
%63 = getelementptr inbounds [262144 x i8], [262144 x i8]* %6, i64 0, i64 0
%64 = getelementptr inbounds [262144 x i8], [262144 x i8]* %6, i64 0, i64 0
%65 = call i32 @strlen(i8* %64)
%66 = call i32 @SHA1(i8* %63, i32 %65, i8* %48)
%67 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%68 = call i32 (i8*, ...) @strncat(i8* %67, i8* %48, i32 10000)
%69 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%70 = getelementptr inbounds [10000 x i8], [10000 x i8]* %9, i64 0, i64 0
%71 = call i8* @encodeString(i8* %70)
%72 = call i32 (i8*, ...) @strncat(i8* %69, i8* %71, i32 10000)
%73 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%74 = call i32 (i8*, ...) @strncat(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 10000)
%75 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%76 = load i8*, i8** %7
ret i8* %75
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"length\00"
@SEEK_END = global i32 0
@.str.2 = [5 x i8] c"name\00"
@.str.3 = [13 x i8] c"piece length\00"
@.str.4 = [7 x i8] c"pieces\00"
@SHA_DIGEST_LENGTH = global i32 0
@.str.5 = [2 x i8] c"e\00"
define i8* @infoDict(i8* %0) {
%2 = alloca [10000 x i8]
%3 = alloca [262144 x i8]
%4 = alloca [10000 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
store i8 100, i8* %5
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @encodeString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @strncat(i8* %5, i8* %7, i32 10000)
%9 = load i32, i32* @SEEK_END
%10 = call i32 @fseek(i32* %6, i32 0, i32 %9)
%11 = call i32 @ftell(i32* %6)
%12 = call i8* @encodeInt(i32 %11)
%13 = call i32 (i8*, ...) @strncat(i8* %5, i8* %12, i32 10000)
%14 = call i32 @rewind(i32* %6)
%15 = call i8* @encodeString(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @strncat(i8* %5, i8* %15, i32 10000)
%17 = call i8* @encodeString(i8* %0)
%18 = call i32 (i8*, ...) @strncat(i8* %5, i8* %17, i32 10000)
%19 = call i8* @encodeString(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @strncat(i8* %5, i8* %19, i32 10000)
%21 = call i8* @encodeInt(i32 262144)
%22 = call i32 (i8*, ...) @strncat(i8* %5, i8* %21, i32 10000)
%23 = call i8* @encodeString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 (i8*, ...) @strncat(i8* %5, i8* %23, i32 10000)
%25 = getelementptr inbounds [262144 x i8], [262144 x i8]* %3, i64 0, i64 0
%26 = load i32, i32* @SHA_DIGEST_LENGTH
%27 = zext i32 %26 to i64
%28 = call i8* @llvm.stacksave()
%29 = alloca i8, i64 %27
%30 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%31 = call i32 @fread(i8* %25, i32 1, i32 262144, i32* %6)
%32 = icmp eq i32 %31, 262144
br i1 %32, label %33, label %39
33: ; preds = %1, %33
%34 = call i32 @strlen(i8* %25)
%35 = call i32 @SHA1(i8* %25, i32 %34, i8* %29)
%36 = call i32 (i8*, ...) @strncat(i8* %30, i8* %29, i32 10000)
%37 = call i32 @fread(i8* %25, i32 1, i32 262144, i32* %6)
%38 = icmp eq i32 %37, 262144
br i1 %38, label %33, label %39
39: ; preds = %33, %1
%40 = call i32 @strlen(i8* %25)
%41 = call i32 @SHA1(i8* %25, i32 %40, i8* %29)
%42 = call i32 (i8*, ...) @strncat(i8* %30, i8* %29, i32 10000)
%43 = call i8* @encodeString(i8* %30)
%44 = call i32 (i8*, ...) @strncat(i8* %5, i8* %43, i32 10000)
%45 = call i32 (i8*, ...) @strncat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 10000)
ret i8* %5
}