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

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

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

24:                                               ; preds = %7
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = call i32 @rl_key_get_or_create(ptr noundef %25, ptr noundef %26, i64 noundef %27, i8 noundef zeroext 83, ptr noundef %16, ptr noundef %17)
  store i32 %28, ptr %18, align 4, !tbaa !11
  %29 = load i32, ptr %18, align 4, !tbaa !11
  %30 = icmp ne i32 %29, 2
  br i1 %30, label %31, label %35

31:                                               ; preds = %24
  %32 = load i32, ptr %18, align 4, !tbaa !11
  %33 = icmp ne i32 %32, 3
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %96

35:                                               ; preds = %31, %24
  %36 = load i32, ptr %18, align 4, !tbaa !11
  %37 = icmp eq i32 %36, 3
  br i1 %37, label %38, label %43

38:                                               ; preds = %35
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i64, ptr %16, align 8, !tbaa !9
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = call i32 @rl_set_create(ptr noundef %39, i64 noundef %40, ptr noundef %41)
  store i32 %42, ptr %18, align 4, !tbaa !11
  br label %96

43:                                               ; preds = %35
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i64, ptr %16, align 8, !tbaa !9
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = call i32 @rl_set_read(ptr noundef %44, i64 noundef %45, ptr noundef %46)
  store i32 %47, ptr %18, align 4, !tbaa !11
  %48 = load i32, ptr %18, align 4, !tbaa !11
  %49 = icmp ne i32 0, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %43
  br label %96

51:                                               ; preds = %43
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  br label %79

54:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #3
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load i64, ptr %11, align 8, !tbaa !9
  %58 = call i32 @rl_key_get(ptr noundef %55, ptr noundef %56, i64 noundef %57, ptr noundef %20, ptr noundef null, ptr noundef %16, ptr noundef null, ptr noundef %17)
  store i32 %58, ptr %18, align 4, !tbaa !11
  %59 = load i32, ptr %18, align 4, !tbaa !11
  %60 = icmp ne i32 %59, 2
  br i1 %60, label %61, label %62

61:                                               ; preds = %54
  store i32 2, ptr %21, align 4
  br label %76

62:                                               ; preds = %54
  %63 = load i8, ptr %20, align 1, !tbaa !15
  %64 = zext i8 %63 to i32
  %65 = icmp ne i32 %64, 83
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  store i32 8, ptr %18, align 4, !tbaa !11
  store i32 2, ptr %21, align 4
  br label %76

67:                                               ; preds = %62
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load i64, ptr %16, align 8, !tbaa !9
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = call i32 @rl_set_read(ptr noundef %68, i64 noundef %69, ptr noundef %70)
  store i32 %71, ptr %18, align 4, !tbaa !11
  %72 = load i32, ptr %18, align 4, !tbaa !11
  %73 = icmp ne i32 0, %72
  br i1 %73, label %74, label %75

74:                                               ; preds = %67
  store i32 2, ptr %21, align 4
  br label %76

75:                                               ; preds = %67
  store i32 0, ptr %21, align 4
  br label %76

76:                                               ; preds = %75, %74, %66, %61
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #3
  %77 = load i32, ptr %21, align 4
  switch i32 %77, label %104 [
    i32 0, label %78
    i32 2, label %96
  ]

78:                                               ; preds = %76
  br label %79

79:                                               ; preds = %78, %53
  %80 = load i32, ptr %14, align 4, !tbaa !11
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %95

82:                                               ; preds = %79
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = load i64, ptr %11, align 8, !tbaa !9
  %86 = load i64, ptr %16, align 8, !tbaa !9
  %87 = load i64, ptr %19, align 8, !tbaa !13
  %88 = load i64, ptr %17, align 8, !tbaa !9
  %89 = add nsw i64 %88, 1
  %90 = call i32 @rl_key_set(ptr noundef %83, ptr noundef %84, i64 noundef %85, i8 noundef zeroext 83, i64 noundef %86, i64 noundef %87, i64 noundef %89)
  store i32 %90, ptr %18, align 4, !tbaa !11
  %91 = load i32, ptr %18, align 4, !tbaa !11
  %92 = icmp ne i32 0, %91
  br i1 %92, label %93, label %94

93:                                               ; preds = %82
  br label %96

94:                                               ; preds = %82
  br label %95

95:                                               ; preds = %94, %79
  br label %96

96:                                               ; preds = %95, %93, %76, %50, %38, %34
  %97 = load ptr, ptr %12, align 8, !tbaa !5
  %98 = icmp ne ptr %97, null
  br i1 %98, label %99, label %102

99:                                               ; preds = %96
  %100 = load i64, ptr %16, align 8, !tbaa !9
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %100, ptr %101, align 8, !tbaa !9
  br label %102

102:                                              ; preds = %99, %96
  %103 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %103, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %104

104:                                              ; preds = %102, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %105 = load i32, ptr %8, align 4
  ret i32 %105
}

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

declare i32 @rl_key_get_or_create(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, ptr noundef, ptr noundef) #2

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

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

declare i32 @rl_key_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

declare i32 @rl_key_set(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, i64 noundef, i64 noundef, i64 noundef) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!7, !7, i64 0}


; 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: nounwind uwtable
define dso_local i32 @rl_set_get_objects(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef writeonly %3, ptr noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #3
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %23, label %11

11:                                               ; preds = %7
  %12 = call i32 @rl_key_get_or_create(ptr noundef %0, ptr noundef %1, i64 noundef %2, i8 noundef zeroext 83, ptr noundef nonnull %8, ptr noundef nonnull %9) #3
  %13 = add i32 %12, -4
  %or.cond = icmp ult i32 %13, -2
  br i1 %or.cond, label %35, label %14

14:                                               ; preds = %11
  %15 = icmp eq i32 %12, 3
  %16 = load i64, ptr %8, align 8, !tbaa !5
  br i1 %15, label %17, label %19

17:                                               ; preds = %14
  %18 = call i32 @rl_set_create(ptr noundef %0, i64 noundef %16, ptr noundef %4)
  br label %35

19:                                               ; preds = %14
  %20 = call i32 @rl_set_read(ptr noundef %0, i64 noundef %16, ptr noundef %4)
  %21 = icmp eq i32 %20, 0
  %22 = icmp ne i32 %5, 0
  %or.cond3 = and i1 %22, %21
  br i1 %or.cond3, label %30, label %35

23:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #3
  %24 = call i32 @rl_key_get(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %10, ptr noundef null, ptr noundef nonnull %8, ptr noundef null, ptr noundef nonnull %9) #3
  %.not39 = icmp eq i32 %24, 2
  br i1 %.not39, label %25, label %.thread

25:                                               ; preds = %23
  %26 = load i8, ptr %10, align 1, !tbaa !9
  %.not40 = icmp eq i8 %26, 83
  br i1 %.not40, label %27, label %.thread

.thread:                                          ; preds = %23, %25
  %.033.ph = phi i32 [ 8, %25 ], [ %24, %23 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #3
  br label %35

27:                                               ; preds = %25
  %28 = load i64, ptr %8, align 8, !tbaa !5
  %29 = call i32 @rl_set_read(ptr noundef %0, i64 noundef %28, ptr noundef %4)
  %.not41 = icmp ne i32 %29, 0
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #3
  %.old2.not = icmp eq i32 %5, 0
  %or.cond45 = or i1 %.old2.not, %.not41
  br i1 %or.cond45, label %35, label %30

30:                                               ; preds = %27, %19
  %31 = load i64, ptr %8, align 8, !tbaa !5
  %32 = load i64, ptr %9, align 8, !tbaa !5
  %33 = add nsw i64 %32, 1
  %34 = call i32 @rl_key_set(ptr noundef %0, ptr noundef %1, i64 noundef %2, i8 noundef zeroext 83, i64 noundef %31, i64 noundef 0, i64 noundef %33) #3
  br label %35

35:                                               ; preds = %.thread, %27, %30, %19, %11, %17
  %.1 = phi i32 [ %12, %11 ], [ %18, %17 ], [ %34, %30 ], [ %20, %19 ], [ %29, %27 ], [ %.033.ph, %.thread ]
  %.not42 = icmp eq ptr %3, null
  br i1 %.not42, label %38, label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %8, align 8, !tbaa !5
  store i64 %37, ptr %3, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %35, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  ret i32 %.1
}

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

declare i32 @rl_key_get_or_create(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

declare i32 @rl_key_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @rl_key_set(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


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