; LLVM IR from seppo0010/rlite :: src (type_hash)

; 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"

%struct.rl_hashkey = type { i64, i64 }

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

; Function Attrs: nounwind uwtable
declare hidden i32 @rl_hash_get_objects(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare i32 @sha1(ptr noundef, i64 noundef, ptr noundef) #3

declare i32 @rl_btree_find_score(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

declare i32 @rl_multi_string_get(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_hmget(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #1 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i64 %2, ptr %11, align 8, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !11
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store ptr null, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %26 = load i32, ptr %12, align 4, !tbaa !11
  %27 = sext i32 %26 to i64
  %28 = mul i64 8, %27
  %29 = call noalias ptr @malloc(i64 noundef %28) #6
  store ptr %29, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  %30 = load i32, ptr %12, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = mul i64 8, %31
  %33 = call noalias ptr @malloc(i64 noundef %32) #6
  store ptr %33, ptr %24, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load i64, ptr %11, align 8, !tbaa !9
  %37 = call i32 @rl_hash_get_objects(ptr noundef %34, ptr noundef %35, i64 noundef %36, ptr noundef %18, ptr noundef %19, i32 noundef 0, i32 noundef 0)
  store i32 %37, ptr %17, align 4, !tbaa !11
  %38 = load i32, ptr %17, align 4, !tbaa !11
  %39 = icmp ne i32 0, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %8
  br label %112

41:                                               ; preds = %8
  %42 = call noalias ptr @malloc(i64 noundef 20) #6
  store ptr %42, ptr %21, align 8, !tbaa !5
  %43 = load ptr, ptr %21, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 4, ptr %17, align 4, !tbaa !11
  br label %112

46:                                               ; preds = %41
  store i32 0, ptr %25, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %104, %46
  %48 = load i32, ptr %25, align 4, !tbaa !11
  %49 = load i32, ptr %12, align 4, !tbaa !11
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %51, label %107

51:                                               ; preds = %47
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = load i32, ptr %25, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = load i32, ptr %25, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i64, ptr %57, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = load ptr, ptr %21, align 8, !tbaa !5
  %63 = call i32 @sha1(ptr noundef %56, i64 noundef %61, ptr noundef %62)
  store i32 %63, ptr %17, align 4, !tbaa !11
  %64 = load i32, ptr %17, align 4, !tbaa !11
  %65 = icmp ne i32 0, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %51
  br label %112

67:                                               ; preds = %51
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load ptr, ptr %19, align 8, !tbaa !5
  %70 = load ptr, ptr %21, align 8, !tbaa !5
  %71 = call i32 @rl_btree_find_score(ptr noundef %68, ptr noundef %69, ptr noundef %70, ptr noundef %20, ptr noundef null, ptr noundef null)
  store i32 %71, ptr %17, align 4, !tbaa !11
  %72 = load i32, ptr %17, align 4, !tbaa !11
  %73 = icmp eq i32 %72, 2
  br i1 %73, label %74, label %89

74:                                               ; preds = %67
  %75 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %75, ptr %22, align 8, !tbaa !5
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load ptr, ptr %22, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.rl_hashkey, ptr %77, i32 0, i32 1
  %79 = load i64, ptr %78, align 8, !tbaa !13
  %80 = load ptr, ptr %23, align 8, !tbaa !5
  %81 = load i32, ptr %25, align 4, !tbaa !11
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds ptr, ptr %80, i64 %82
  %84 = load ptr, ptr %24, align 8, !tbaa !5
  %85 = load i32, ptr %25, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i64, ptr %84, i64 %86
  %88 = call i32 @rl_multi_string_get(ptr noundef %76, i64 noundef %79, ptr noundef %83, ptr noundef %87)
  br label %103

89:                                               ; preds = %67
  %90 = load i32, ptr %17, align 4, !tbaa !11
  %91 = icmp eq i32 %90, 3
  br i1 %91, label %92, label %101

92:                                               ; preds = %89
  %93 = load ptr, ptr %23, align 8, !tbaa !5
  %94 = load i32, ptr %25, align 4, !tbaa !11
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds ptr, ptr %93, i64 %95
  store ptr null, ptr %96, align 8, !tbaa !5
  %97 = load ptr, ptr %24, align 8, !tbaa !5
  %98 = load i32, ptr %25, align 4, !tbaa !11
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i64, ptr %97, i64 %99
  store i64 -1, ptr %100, align 8, !tbaa !9
  br label %102

101:                                              ; preds = %89
  br label %112

102:                                              ; preds = %92
  br label %103

103:                                              ; preds = %102, %74
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %25, align 4, !tbaa !11
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %25, align 4, !tbaa !11
  br label %47, !llvm.loop !15

107:                                              ; preds = %47
  %108 = load ptr, ptr %23, align 8, !tbaa !5
  %109 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %108, ptr %109, align 8, !tbaa !5
  %110 = load ptr, ptr %24, align 8, !tbaa !5
  %111 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %110, ptr %111, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %112

112:                                              ; preds = %107, %101, %66, %45, %40
  %113 = load i32, ptr %17, align 4, !tbaa !11
  %114 = icmp ne i32 %113, 0
  br i1 %114, label %115, label %118

115:                                              ; preds = %112
  %116 = load ptr, ptr %23, align 8, !tbaa !5
  call void @free(ptr noundef %116) #5
  %117 = load ptr, ptr %24, align 8, !tbaa !5
  call void @free(ptr noundef %117) #5
  br label %118

118:                                              ; preds = %115, %112
  %119 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %119) #5
  %120 = load i32, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  ret i32 %120
}

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 = { nounwind allocsize(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 #3 = { "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 #4 = { 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" }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"rl_hashkey", !10, i64 0, !10, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"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"

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

; Function Attrs: nounwind uwtable
declare hidden i32 @rl_hash_get_objects(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

declare i32 @sha1(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @rl_btree_find_score(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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

declare i32 @rl_multi_string_get(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_hmget(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef writeonly %6, ptr nocapture noundef writeonly %7) local_unnamed_addr #1 {
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  %12 = sext i32 %3 to i64
  %13 = shl nsw i64 %12, 3
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #6
  %15 = tail call noalias ptr @malloc(i64 noundef %13) #6
  %16 = call i32 @rl_hash_get_objects(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %9, ptr noundef nonnull %10, i32 noundef 0, i32 noundef 0)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %17, label %.thread

17:                                               ; preds = %8
  %18 = call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #6
  %.not44 = icmp eq ptr %18, null
  br i1 %.not44, label %.thread, label %.preheader

.preheader:                                       ; preds = %17
  %19 = icmp sgt i32 %3, 0
  br i1 %19, label %.lr.ph.preheader, label %.thread54

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %38
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %38 ]
  %20 = getelementptr inbounds ptr, ptr %4, i64 %indvars.iv
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %5, i64 %indvars.iv
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = call i32 @sha1(ptr noundef %21, i64 noundef %23, ptr noundef nonnull %18) #5
  %.not45 = icmp eq i32 %24, 0
  br i1 %.not45, label %25, label %.thread

25:                                               ; preds = %.lr.ph
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = call i32 @rl_btree_find_score(ptr noundef %0, ptr noundef %26, ptr noundef nonnull %18, ptr noundef nonnull %11, ptr noundef null, ptr noundef null) #5
  switch i32 %27, label %.thread [
    i32 2, label %28
    i32 3, label %35
    i32 0, label %.loopexit
  ]

28:                                               ; preds = %25
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = load i64, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  %33 = getelementptr inbounds i64, ptr %15, i64 %indvars.iv
  %34 = call i32 @rl_multi_string_get(ptr noundef %0, i64 noundef %31, ptr noundef %32, ptr noundef %33) #5
  br label %38

35:                                               ; preds = %25
  %36 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  store ptr null, ptr %36, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr %15, i64 %indvars.iv
  store i64 -1, ptr %37, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %28, %35
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.thread54, label %.lr.ph, !llvm.loop !13

.thread54:                                        ; preds = %38, %.preheader
  store ptr %14, ptr %6, align 8, !tbaa !5
  store ptr %15, ptr %7, align 8, !tbaa !5
  br label %.loopexit

.thread:                                          ; preds = %25, %.lr.ph, %17, %8
  %.03852 = phi i32 [ 4, %17 ], [ %16, %8 ], [ %27, %25 ], [ %24, %.lr.ph ]
  %.03950 = phi ptr [ null, %17 ], [ null, %8 ], [ %18, %.lr.ph ], [ %18, %25 ]
  call void @free(ptr noundef %14) #5
  call void @free(ptr noundef %15) #5
  br label %.loopexit

.loopexit:                                        ; preds = %25, %.thread54, %.thread
  %.03853 = phi i32 [ %.03852, %.thread ], [ 0, %.thread54 ], [ %27, %25 ]
  %.03951 = phi ptr [ %.03950, %.thread ], [ %18, %.thread54 ], [ %18, %25 ]
  call void @free(ptr noundef %.03951) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  ret i32 %.03853
}

attributes #0 = { mustprogress 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"rl_hashkey", !10, i64 0, !10, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass