#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 atoi(char *);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ hash(char *, int, void *);
int /*<<< orphan*/ hash_to_hex(void *, char *);
int /*<<< orphan*/ init_str(char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand(time(NULL));
  void *hval = (void *)calloc(128, 1);
  int len = atoi(argv[1]);
  char *s = (char *)malloc(sizeof(char) * len);
  char hex[32];
  init_str(s, len);
  hash(s, sizeof(char) * len, hval);
  hash_to_hex(hval, hex);
  printf("%s\n", hex);
  free(hval);
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x80,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1070 <init_str@plt>
mov    -0x28(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
call   1040 <hash@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10c0 <hash_to_hex@plt>
lea    -0x50(%rbp),%rsi
lea    0xdc9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x80,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r15
mov    0x8(%r14),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
call   1070 <init_str@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
call   1040 <hash@plt>
mov    %rsp,%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   10c0 <hash_to_hex@plt>
lea    0xdf2(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = call i64 @calloc(i32 128, i32 1)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = mul i64 1, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = load i32, i32* %7
%26 = call i32 @init_str(i8* %24, i32 %25)
%27 = load i8*, i8** %8
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = mul i64 1, %29
%31 = trunc i64 %30 to i32
%32 = load i8*, i8** %6
%33 = call i32 @hash(i8* %27, i32 %31, i8* %32)
%34 = load i8*, i8** %6
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%36 = call i32 @hash_to_hex(i8* %34, i8* %35)
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
%41 = load i8*, i8** %8
%42 = call i32 @free(i8* %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i64 @calloc(i32 128, i32 1)
%7 = inttoptr i64 %6 to i8*
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%14 = tail call i32 @init_str(i8* %12, i32 %10)
%15 = tail call i32 @hash(i8* %12, i32 %10, i8* %7)
%16 = call i32 @hash_to_hex(i8* %7, i8* %13)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
%18 = call i32 @free(i8* %7)
%19 = call i32 @free(i8* %12)
ret i32 0
}