; 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 }
%struct.rl_btree_iterator = type { ptr, ptr, i64, i64, [0 x %struct.rl_btree_iterator_nodes] }
%struct.rl_btree_iterator_nodes = type { i64, ptr }

@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [44 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: nounwind
declare void @free(ptr noundef) #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_hash_iterator_next(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #3 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %20 = load ptr, ptr %14, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %28

22:                                               ; preds = %7
  %23 = load ptr, ptr %15, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %28, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.3) #4
  store i32 6, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %102

28:                                               ; preds = %22, %7
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %37

31:                                               ; preds = %28
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %37, label %34

34:                                               ; preds = %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str.4) #4
  store i32 6, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %102

37:                                               ; preds = %31, %28
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = call i32 @rl_btree_iterator_next(ptr noundef %38, ptr noundef null, ptr noundef %16)
  store i32 %39, ptr %18, align 4, !tbaa !9
  %40 = load i32, ptr %18, align 4, !tbaa !9
  %41 = icmp ne i32 0, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  br label %99

43:                                               ; preds = %37
  %44 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %44, ptr %17, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %52

47:                                               ; preds = %43
  %48 = load ptr, ptr %17, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.rl_hashkey, ptr %48, i32 0, i32 0
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  store i64 %50, ptr %51, align 8, !tbaa !14
  br label %52

52:                                               ; preds = %47, %43
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %71

55:                                               ; preds = %52
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.rl_btree_iterator, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.rl_hashkey, ptr %59, i32 0, i32 0
  %61 = load i64, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = call i32 @rl_multi_string_get(ptr noundef %58, i64 noundef %61, ptr noundef %62, ptr noundef %63)
  store i32 %64, ptr %18, align 4, !tbaa !9
  %65 = load i32, ptr %18, align 4, !tbaa !9
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %70

67:                                               ; preds = %55
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = call i32 @rl_btree_iterator_destroy(ptr noundef %68)
  br label %99

70:                                               ; preds = %55
  br label %71

71:                                               ; preds = %70, %52
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %79

74:                                               ; preds = %71
  %75 = load ptr, ptr %17, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.rl_hashkey, ptr %75, i32 0, i32 1
  %77 = load i64, ptr %76, align 8, !tbaa !15
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %77, ptr %78, align 8, !tbaa !14
  br label %79

79:                                               ; preds = %74, %71
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %98

82:                                               ; preds = %79
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.rl_btree_iterator, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !5
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.rl_hashkey, ptr %86, i32 0, i32 1
  %88 = load i64, ptr %87, align 8, !tbaa !15
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = load ptr, ptr %15, align 8, !tbaa !5
  %91 = call i32 @rl_multi_string_get(ptr noundef %85, i64 noundef %88, ptr noundef %89, ptr noundef %90)
  store i32 %91, ptr %18, align 4, !tbaa !9
  %92 = load i32, ptr %18, align 4, !tbaa !9
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %82
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = call i32 @rl_btree_iterator_destroy(ptr noundef %95)
  br label %99

97:                                               ; preds = %82
  br label %98

98:                                               ; preds = %97, %79
  br label %99

99:                                               ; preds = %98, %94, %67, %42
  %100 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %100) #4
  %101 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %101, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %102

102:                                              ; preds = %99, %34, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  %103 = load i32, ptr %8, align 4
  ret i32 %103
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare i32 @rl_btree_iterator_next(ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @rl_btree_iterator_destroy(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"rl_hashkey", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 8}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [44 x i8], align 1

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

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

; 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 #2

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_hash_iterator_next(ptr noundef %0, ptr noundef writeonly %1, ptr noundef %2, ptr noundef %3, ptr noundef writeonly %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #3 {
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %9 = icmp eq ptr %5, null
  %10 = icmp ne ptr %6, null
  %or.cond = or i1 %9, %10
  br i1 %or.cond, label %14, label %11

11:                                               ; preds = %7
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.3) #6
  br label %43

14:                                               ; preds = %7
  %15 = icmp eq ptr %2, null
  %16 = icmp ne ptr %3, null
  %or.cond3 = or i1 %15, %16
  br i1 %or.cond3, label %20, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.4) #6
  br label %43

20:                                               ; preds = %14
  %21 = call i32 @rl_btree_iterator_next(ptr noundef %0, ptr noundef null, ptr noundef nonnull %8) #5
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %22, label %42

22:                                               ; preds = %20
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %.not43 = icmp eq ptr %1, null
  br i1 %.not43, label %26, label %24

24:                                               ; preds = %22
  %25 = load i64, ptr %23, align 8, !tbaa !9
  store i64 %25, ptr %1, align 8, !tbaa !12
  br label %26

26:                                               ; preds = %24, %22
  br i1 %16, label %27, label %31

27:                                               ; preds = %26
  %28 = load ptr, ptr %0, align 8, !tbaa !5
  %29 = load i64, ptr %23, align 8, !tbaa !9
  %30 = call i32 @rl_multi_string_get(ptr noundef %28, i64 noundef %29, ptr noundef %2, ptr noundef nonnull %3) #5
  %.not44 = icmp eq i32 %30, 0
  br i1 %.not44, label %31, label %.sink.split

31:                                               ; preds = %27, %26
  %.not45 = icmp eq ptr %4, null
  br i1 %.not45, label %35, label %32

32:                                               ; preds = %31
  %33 = getelementptr inbounds i8, ptr %23, i64 8
  %34 = load i64, ptr %33, align 8, !tbaa !13
  store i64 %34, ptr %4, align 8, !tbaa !12
  br label %35

35:                                               ; preds = %32, %31
  br i1 %10, label %36, label %42

36:                                               ; preds = %35
  %37 = load ptr, ptr %0, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %23, i64 8
  %39 = load i64, ptr %38, align 8, !tbaa !13
  %40 = call i32 @rl_multi_string_get(ptr noundef %37, i64 noundef %39, ptr noundef %5, ptr noundef nonnull %6) #5
  %.not46 = icmp eq i32 %40, 0
  br i1 %.not46, label %42, label %.sink.split

.sink.split:                                      ; preds = %36, %27
  %.1.ph = phi i32 [ %30, %27 ], [ %40, %36 ]
  %41 = call i32 @rl_btree_iterator_destroy(ptr noundef nonnull %0) #5
  br label %42

42:                                               ; preds = %.sink.split, %35, %36, %20
  %.031 = phi ptr [ null, %20 ], [ %23, %36 ], [ %23, %35 ], [ %23, %.sink.split ]
  %.1 = phi i32 [ %21, %20 ], [ 0, %36 ], [ 0, %35 ], [ %.1.ph, %.sink.split ]
  call void @free(ptr noundef %.031) #5
  br label %43

43:                                               ; preds = %42, %17, %11
  %.032 = phi i32 [ %.1, %42 ], [ 6, %17 ], [ 6, %11 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  ret i32 %.032
}

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

declare i32 @rl_btree_iterator_next(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @rl_btree_iterator_destroy(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #4 = { 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" }
attributes #5 = { nounwind }
attributes #6 = { cold 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"rl_hashkey", !11, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass