#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*/ string;

/* Variables and functions */
int /*<<< orphan*/ SHA1(char *, size_t, unsigned char *);
int SHA_DIGEST_LENGTH;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
void getArchive(void) {
  char *string = "djflsdagfdnkgsvjdfhgldf";
  size_t length = sizeof(string);
  unsigned char hash[SHA_DIGEST_LENGTH];
  char consoleOut[SHA_DIGEST_LENGTH * 2];
  int i = 0;
  SHA1(string, length, hash);
  for (i = 0; i < SHA_DIGEST_LENGTH; i++) {
    sprintf((char *)&(consoleOut[i * 2]), "%02x", hash[i]);
  }
  puts("Done!");
  printf("Here is the information you requested: %s\n", consoleOut);
  return;
}


x86 assembly (clang, -O0):
<getArchive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
movq   $0x8,-0x10(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
add    %eax,%eax
mov    %rax,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rcx
sub    %rsi,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <SHA1@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%eax
jge    120a <getArchive+0xca>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rdi
movslq -0x2c(%rbp),%rcx
lea    0xe25(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1060 <sprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c2 <getArchive+0x82>
lea    0xe0c(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%rsi
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getArchive>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e93(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r12
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
add    %eax,%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
lea    0xe75(%rip),%rdi
mov    $0x8,%esi
mov    %r12,%rdx
call   1050 <SHA1@plt>
cmpl   $0x0,0x0(%r13)
jle    11d1 <getArchive+0x91>
xor    %r14d,%r14d
lea    0xe6f(%rip),%r15
mov    -0x30(%rbp),%rbx
nopl   (%rax)
movzbl (%r12,%r14,1),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <sprintf@plt>
add    $0x1,%r14
movslq 0x0(%r13),%rax
add    $0x2,%rbx
cmp    %rax,%r14
jl     11b0 <getArchive+0x70>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3f(%rip),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <printf@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"djflsdagfdnkgsvjdfhgldf\00"
@SHA_DIGEST_LENGTH = global i32 0
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [6 x i8] c"Done!\00"
@.str.3 = [43 x i8] c"Here is the information you requested: %s\0A\00"
define void @getArchive() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %1
store i64 8, i64* %2
%7 = load i32, i32* @SHA_DIGEST_LENGTH
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i8, i64 %8
store i64 %8, i64* %4
%11 = load i32, i32* @SHA_DIGEST_LENGTH
%12 = mul nsw i32 %11, 2
%13 = zext i32 %12 to i64
%14 = alloca i8, i64 %13
store i64 %13, i64* %5
store i32 0, i32* %6
%15 = load i8*, i8** %1
%16 = load i64, i64* %2
%17 = call i32 @SHA1(i8* %15, i64 %16, i8* %10)
store i32 0, i32* %6
br label %18
18: ; preds = %32, %0
%19 = load i32, i32* %6
%20 = load i32, i32* @SHA_DIGEST_LENGTH
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load i32, i32* %6
%24 = mul nsw i32 %23, 2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %14, i64 %25
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %10, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %30)
br label %32
32: ; preds = %22
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %18
35: ; preds = %18
%36 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%38 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"djflsdagfdnkgsvjdfhgldf\00"
@SHA_DIGEST_LENGTH = global i32 0
@.str.1 = [5 x i8] c"%02x\00"
@.str.2 = [6 x i8] c"Done!\00"
@.str.3 = [43 x i8] c"Here is the information you requested: %s\0A\00"
define void @getArchive() {
%1 = load i32, i32* @SHA_DIGEST_LENGTH
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = shl nsw i32 %1, 1
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = call i32 @SHA1(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i64 8, i8* %3)
%8 = load i32, i32* @SHA_DIGEST_LENGTH
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0, %10
%11 = phi i64 [ %17, %10 ], [ 0, %0 ]
%12 = shl nuw nsw i64 %11, 1
%13 = getelementptr inbounds i8, i8* %6, i64 %12
%14 = getelementptr inbounds i8, i8* %3, i64 %11
%15 = load i8, i8* %14
%16 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %15)
%17 = add nuw nsw i64 %11, 1
%18 = load i32, i32* @SHA_DIGEST_LENGTH
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %10, label %21
21: ; preds = %10, %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %6)
ret void
}