; LLVM IR from AlgoGenesis/C :: Hash/Single Hash (program)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@hashTable = external dso_local global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @hashFunction(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @insert(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = call i32 @hashFunction(i32 noundef %6)
  store i32 %7, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %27, %1
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = mul nsw i32 %10, %11
  %13 = add nsw i32 %9, %12
  %14 = srem i32 %13, 10
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp ne i32 %17, -1
  br i1 %18, label %19, label %28

19:                                               ; preds = %8
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 10
  br i1 %23, label %24, label %27

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %25)
  store i32 1, ptr %5, align 4
  br label %38

27:                                               ; preds = %19
  br label %8, !llvm.loop !9

28:                                               ; preds = %8
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = mul nsw i32 %31, %32
  %34 = add nsw i32 %30, %33
  %35 = srem i32 %34, 10
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %36
  store i32 %29, ptr %37, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  br label %38

38:                                               ; preds = %28, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %39 = load i32, ptr %5, align 4
  switch i32 %39, label %41 [
    i32 0, label %40
    i32 1, label %40
  ]

40:                                               ; preds = %38, %38
  ret void

41:                                               ; preds = %38
  unreachable
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@hashTable = external dso_local local_unnamed_addr global [10 x i32], align 16
@.str = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @hashFunction(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @insert(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @hashFunction(i32 noundef %0)
  %3 = srem i32 %2, 10
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, -1
  br i1 %.not, label %63, label %7

7:                                                ; preds = %1
  %8 = add nsw i32 %2, 1
  %9 = srem i32 %8, 10
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %.not.1 = icmp eq i32 %12, -1
  br i1 %.not.1, label %63, label %13

13:                                               ; preds = %7
  %14 = add nsw i32 %2, 4
  %15 = srem i32 %14, 10
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not.2 = icmp eq i32 %18, -1
  br i1 %.not.2, label %63, label %19

19:                                               ; preds = %13
  %20 = add nsw i32 %2, 9
  %21 = srem i32 %20, 10
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %.not.3 = icmp eq i32 %24, -1
  br i1 %.not.3, label %63, label %25

25:                                               ; preds = %19
  %26 = add nsw i32 %2, 16
  %27 = srem i32 %26, 10
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %.not.4 = icmp eq i32 %30, -1
  br i1 %.not.4, label %63, label %31

31:                                               ; preds = %25
  %32 = add nsw i32 %2, 25
  %33 = srem i32 %32, 10
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %.not.5 = icmp eq i32 %36, -1
  br i1 %.not.5, label %63, label %37

37:                                               ; preds = %31
  %38 = add nsw i32 %2, 36
  %39 = srem i32 %38, 10
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %.not.6 = icmp eq i32 %42, -1
  br i1 %.not.6, label %63, label %43

43:                                               ; preds = %37
  %44 = add nsw i32 %2, 49
  %45 = srem i32 %44, 10
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %.not.7 = icmp eq i32 %48, -1
  br i1 %.not.7, label %63, label %49

49:                                               ; preds = %43
  %50 = add nsw i32 %2, 64
  %51 = srem i32 %50, 10
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %.not.8 = icmp eq i32 %54, -1
  br i1 %.not.8, label %63, label %55

55:                                               ; preds = %49
  %56 = add nsw i32 %2, 81
  %57 = srem i32 %56, 10
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %.not.9 = icmp eq i32 %60, -1
  br i1 %.not.9, label %63, label %61

61:                                               ; preds = %55
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
  br label %65

63:                                               ; preds = %55, %49, %43, %37, %31, %25, %19, %13, %7, %1
  %.lcssa = phi i64 [ %4, %1 ], [ %10, %7 ], [ %16, %13 ], [ %22, %19 ], [ %28, %25 ], [ %34, %31 ], [ %40, %37 ], [ %46, %43 ], [ %52, %49 ], [ %58, %55 ]
  %64 = getelementptr inbounds [10 x i32], ptr @hashTable, i64 0, i64 %.lcssa
  store i32 %0, ptr %64, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %63, %61
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass