#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 */
struct student_detail {
  int dummy;
};
struct hashMap {
  int dummy;
};

/* Variables and functions */
struct hashMap *init_hashMap(struct student_detail **);
int /*<<< orphan*/ insert(struct student_detail **, char *);
struct student_detail **malloc(int);
int /*<<< orphan*/ printf(char *, float, ...);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ srand(scalar_t__);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  struct student_detail **record;
  record = malloc(sizeof(struct student_detail *) * 100000);
  struct hashMap *hashMap = init_hashMap(record);
  int collision_count = 0;
  int noCollision = 0;
  int first_coll = 0;
  int input_size = 100000;
  for (int i = 0; i < input_size; i++) {
    char new[512];
    srand(noCollision + collision_count + time(NULL));
    sprintf(new, "%d", rand());
    if (!insert(record, new)) {
      collision_count++;
      if (collision_count == 1)
        first_coll = noCollision;
    } else {
      noCollision++;
    }
  }
  int blank_block = 0;
  for (int i = 0; i < 100000; i++) {
    if (!record[i])
      blank_block++;
  }
  printf("Total collisons: %d,NO collision: %d,first collision at: %d \n",
         collision_count, noCollision, first_coll);
  printf("blank blocks: %d \n", blank_block);
  printf("Hash Index: %f\n", (float)(collision_count) / (input_size));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc3500,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <init_hashMap@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x186a0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1287 <main+0x107>
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
cltq
mov    %rax,-0x258(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    -0x258(%rbp),%rdi
add    %rax,%rdi
call   1040 <srand@plt>
lea    -0x240(%rbp),%rax
mov    %rax,-0x250(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    -0x250(%rbp),%rdi
mov    %eax,%edx
lea    0xdd1(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1070 <insert@plt>
cmp    $0x0,%eax
jne    126b <main+0xeb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1266 <main+0xe6>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1274 <main+0xf4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1279 <main+0xf9>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d7 <main+0x57>
movl   $0x0,-0x244(%rbp)
movl   $0x0,-0x248(%rbp)
cmpl   $0x186a0,-0x248(%rbp)
jge    12e9 <main+0x169>
mov    -0x18(%rbp),%rax
movslq -0x248(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    12d0 <main+0x150>
mov    -0x244(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x244(%rbp)
jmp    12d5 <main+0x155>
mov    -0x248(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x248(%rbp)
jmp    129b <main+0x11b>
cvtsi2ssl -0x24(%rbp),%xmm0
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xd08(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2ssl -0x244(%rbp),%xmm0
ff
lea    0xd30(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2ssl -0x24(%rbp),%xmm0
cvtsi2ssl -0x30(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xd27(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    $0xc3500,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1090 <init_hashMap@plt>
mov    $0x186a0,%ebp
xor    %ecx,%ecx
xor    %r13d,%r13d
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %esi,%r15d
mov    %ecx,%r14d
lea    (%r14,%r15,1),%ebx
xor    %edi,%edi
call   1050 <time@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
lea    0xe12(%rip),%rsi
mov    %eax,%edx
call   1080 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <insert@plt>
xor    %ecx,%ecx
xor    %esi,%esi
test   %eax,%eax
sete   %cl
setne  %sil
add    %r15d,%esi
or     %r14d,%eax
cmove  %r15d,%r13d
add    %r14d,%ecx
add    $0xffffffff,%ebp
jne    11c0 <main+0x40>
xor    %ebx,%ebx
mov    $0x4,%eax
nopw   0x0(%rax,%rax,1)
cmpq   $0x1,-0x20(%r12,%rax,8)
adc    $0x0,%ebx
cmpq   $0x1,-0x18(%r12,%rax,8)
adc    $0x0,%ebx
cmpq   $0x1,-0x10(%r12,%rax,8)
adc    $0x0,%ebx
cmpq   $0x1,-0x8(%r12,%rax,8)
adc    $0x0,%ebx
cmpq   $0x1,(%r12,%rax,8)
adc    $0x0,%ebx
add    $0x5,%rax
cmp    $0x186a4,%rax
jne    1230 <main+0xb0>
cvtsi2ss %ecx,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xd8e(%rip),%rdi
mov    %r13d,%edx
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
lea    0xdb4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
divss  0xd5a(%rip),%xmm0
lea    0xdab(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.student_detail = type { i32 }
%struct.hashMap = type { i32 }
@.str = [3 x i8] c"%d\00"
@.str.1 = [62 x i8] c"Total collisons: %d,NO collision: %d,first collision at: %d \0A\00"
@.str.2 = [19 x i8] c"blank blocks: %d \0A\00"
@.str.3 = [16 x i8] c"Hash Index: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.student_detail**
%7 = alloca %struct.hashMap*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [512 x i8]
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = call %struct.student_detail** @malloc(i32 800000)
store %struct.student_detail** %16, %struct.student_detail*** %6
%17 = load %struct.student_detail**, %struct.student_detail*** %6
%18 = call %struct.hashMap* @init_hashMap(%struct.student_detail** %17)
store %struct.hashMap* %18, %struct.hashMap** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 100000, i32* %11
store i32 0, i32* %12
br label %19
19: ; preds = %50, %2
%20 = load i32, i32* %12
%21 = load i32, i32* %11
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %53
23: ; preds = %19
%24 = load i32, i32* %9
%25 = load i32, i32* %8
%26 = add nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = call i64 @time(i32* null)
%29 = add nsw i64 %27, %28
%30 = call i32 @srand(i64 %29)
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%32 = call i32 (...) @rand()
%33 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load %struct.student_detail**, %struct.student_detail*** %6
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%36 = call i32 @insert(%struct.student_detail** %34, i8* %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %46, label %38
38: ; preds = %23
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = load i32, i32* %9
store i32 %44, i32* %10
br label %45
45: ; preds = %43, %38
br label %49
46: ; preds = %23
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %49
49: ; preds = %46, %45
br label %50
50: ; preds = %49
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
store i32 %52, i32* %12
br label %19
53: ; preds = %19
store i32 0, i32* %14
store i32 0, i32* %15
br label %54
54: ; preds = %68, %53
%55 = load i32, i32* %15
%56 = icmp slt i32 %55, 100000
br i1 %56, label %57, label %71
57: ; preds = %54
%58 = load %struct.student_detail**, %struct.student_detail*** %6
%59 = load i32, i32* %15
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds %struct.student_detail*, %struct.student_detail** %58, i64 %60
%62 = load %struct.student_detail*, %struct.student_detail** %61
%63 = icmp ne %struct.student_detail* %62, null
br i1 %63, label %67, label %64
64: ; preds = %57
%65 = load i32, i32* %14
%66 = add nsw i32 %65, 1
store i32 %66, i32* %14
br label %67
67: ; preds = %64, %57
br label %68
68: ; preds = %67
%69 = load i32, i32* %15
%70 = add nsw i32 %69, 1
store i32 %70, i32* %15
br label %54
71: ; preds = %54
%72 = load i32, i32* %8
%73 = sitofp i32 %72 to float
%74 = load i32, i32* %9
%75 = load i32, i32* %10
%76 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), float %73, i32 %74, i32 %75)
%77 = load i32, i32* %14
%78 = sitofp i32 %77 to float
%79 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), float %78)
%80 = load i32, i32* %8
%81 = sitofp i32 %80 to float
%82 = load i32, i32* %11
%83 = sitofp i32 %82 to float
%84 = fdiv float %81, %83
%85 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), float %84)
ret i32 0
}

LLVM IR (-O2):
%struct.student_detail = type { i32 }
%struct.hashMap = type { i32 }
@.str = [3 x i8] c"%d\00"
@.str.1 = [62 x i8] c"Total collisons: %d,NO collision: %d,first collision at: %d \0A\00"
@.str.2 = [19 x i8] c"blank blocks: %d \0A\00"
@.str.3 = [16 x i8] c"Hash Index: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = tail call %struct.student_detail** @malloc(i32 800000)
%5 = tail call %struct.hashMap* @init_hashMap(%struct.student_detail** %4)
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %29, %7 ]
%9 = phi i32 [ 0, %2 ], [ %28, %7 ]
%10 = phi i32 [ 0, %2 ], [ %26, %7 ]
%11 = phi i32 [ 0, %2 ], [ %24, %7 ]
%12 = add nuw nsw i32 %9, %11
%13 = zext i32 %12 to i64
%14 = call i64 @time(i32* null)
%15 = add nsw i64 %14, %13
%16 = call i32 @srand(i64 %15)
%17 = call i32 (...) @rand()
%18 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @insert(%struct.student_detail** %4, i8* %6)
%20 = icmp eq i32 %19, 0
%21 = icmp eq i32 %9, 0
%22 = xor i1 %20, true
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %11, %23
%25 = select i1 %20, i1 %21, i1 false
%26 = select i1 %25, i32 %11, i32 %10
%27 = zext i1 %20 to i32
%28 = add nuw nsw i32 %9, %27
%29 = add nuw nsw i32 %8, 1
%30 = icmp eq i32 %29, 100000
br i1 %30, label %38, label %7
31: ; preds = %38
%32 = sitofp i32 %28 to float
%33 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), float %32, i32 %24, i32 %26)
%34 = sitofp i32 %69 to float
%35 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), float %34)
%36 = fdiv float %32, 1.000000e+05
%37 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), float %36)
ret i32 0
38: ; preds = %7, %38
%39 = phi i64 [ %70, %38 ], [ 0, %7 ]
%40 = phi i32 [ %69, %38 ], [ 0, %7 ]
%41 = getelementptr inbounds %struct.student_detail*, %struct.student_detail** %4, i64 %39
%42 = load %struct.student_detail*, %struct.student_detail** %41
%43 = icmp eq %struct.student_detail* %42, null
%44 = zext i1 %43 to i32
%45 = add nuw nsw i32 %40, %44
%46 = add nuw nsw i64 %39, 1
%47 = getelementptr inbounds %struct.student_detail*, %struct.student_detail** %4, i64 %46
%48 = load %struct.student_detail*, %struct.student_detail** %47
%49 = icmp eq %struct.student_detail* %48, null
%50 = zext i1 %49 to i32
%51 = add nuw nsw i32 %45, %50
%52 = add nuw nsw i64 %39, 2
%53 = getelementptr inbounds %struct.student_detail*, %struct.student_detail** %4, i64 %52
%54 = load %struct.student_detail*, %struct.student_detail** %53
%55 = icmp eq %struct.student_detail* %54, null
%56 = zext i1 %55 to i32
%57 = add nuw nsw i32 %51, %56
%58 = add nuw nsw i64 %39, 3
%59 = getelementptr inbounds %struct.student_detail*, %struct.student_detail** %4, i64 %58
%60 = load %struct.student_detail*, %struct.student_detail** %59
%61 = icmp eq %struct.student_detail* %60, null
%62 = zext i1 %61 to i32
%63 = add nuw nsw i32 %57, %62
%64 = add nuw nsw i64 %39, 4
%65 = getelementptr inbounds %struct.student_detail*, %struct.student_detail** %4, i64 %64
%66 = load %struct.student_detail*, %struct.student_detail** %65
%67 = icmp eq %struct.student_detail* %66, null
%68 = zext i1 %67 to i32
%69 = add nuw nsw i32 %63, %68
%70 = add nuw nsw i64 %39, 5
%71 = icmp eq i64 %70, 100000
br i1 %71, label %31, label %38
}