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

; 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
declare dso_local i32 @rl_set(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, i64 noundef) #0

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_bitop(ptr noundef %0, i32 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !11
  store i64 %4, ptr %12, align 8, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  store ptr null, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %22 = load i64, ptr %12, align 8, !tbaa !11
  %23 = mul i64 8, %22
  %24 = call noalias ptr @malloc(i64 noundef %23) #6
  store ptr %24, ptr %19, align 8, !tbaa !5
  %25 = load ptr, ptr %19, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %28, label %27

27:                                               ; preds = %7
  store i32 4, ptr %16, align 4, !tbaa !9
  br label %102

28:                                               ; preds = %7
  %29 = load i64, ptr %12, align 8, !tbaa !11
  %30 = mul i64 8, %29
  %31 = call noalias ptr @malloc(i64 noundef %30) #6
  store ptr %31, ptr %17, align 8, !tbaa !5
  %32 = load ptr, ptr %17, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 4, ptr %16, align 4, !tbaa !9
  br label %102

35:                                               ; preds = %28
  %36 = load ptr, ptr %17, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %36, i64 0
  store ptr null, ptr %37, align 8, !tbaa !5
  store i64 0, ptr %20, align 8, !tbaa !11
  br label %38

38:                                               ; preds = %83, %35
  %39 = load i64, ptr %20, align 8, !tbaa !11
  %40 = load i64, ptr %12, align 8, !tbaa !11
  %41 = icmp ult i64 %39, %40
  br i1 %41, label %42, label %86

42:                                               ; preds = %38
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = load i64, ptr %20, align 8, !tbaa !11
  %46 = getelementptr inbounds ptr, ptr %44, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = load i64, ptr %20, align 8, !tbaa !11
  %50 = getelementptr inbounds i64, ptr %48, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !11
  %52 = load ptr, ptr %17, align 8, !tbaa !5
  %53 = load i64, ptr %20, align 8, !tbaa !11
  %54 = getelementptr inbounds ptr, ptr %52, i64 %53
  %55 = call i32 @rl_get(ptr noundef %43, ptr noundef %47, i64 noundef %51, ptr noundef %54, ptr noundef %15)
  store i32 %55, ptr %16, align 4, !tbaa !9
  %56 = load i32, ptr %16, align 4, !tbaa !9
  %57 = icmp ne i32 0, %56
  br i1 %57, label %58, label %62

58:                                               ; preds = %42
  %59 = load i32, ptr %16, align 4, !tbaa !9
  %60 = icmp ne i32 3, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %58
  br label %102

62:                                               ; preds = %58, %42
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = icmp eq i32 %63, 3
  br i1 %64, label %65, label %72

65:                                               ; preds = %62
  %66 = load ptr, ptr %17, align 8, !tbaa !5
  %67 = load i64, ptr %20, align 8, !tbaa !11
  %68 = getelementptr inbounds ptr, ptr %66, i64 %67
  store ptr null, ptr %68, align 8, !tbaa !5
  %69 = load ptr, ptr %19, align 8, !tbaa !5
  %70 = load i64, ptr %20, align 8, !tbaa !11
  %71 = getelementptr inbounds i64, ptr %69, i64 %70
  store i64 0, ptr %71, align 8, !tbaa !11
  br label %82

72:                                               ; preds = %62
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %80

75:                                               ; preds = %72
  %76 = load i64, ptr %15, align 8, !tbaa !11
  %77 = load ptr, ptr %19, align 8, !tbaa !5
  %78 = load i64, ptr %20, align 8, !tbaa !11
  %79 = getelementptr inbounds i64, ptr %77, i64 %78
  store i64 %76, ptr %79, align 8, !tbaa !11
  br label %81

80:                                               ; preds = %72
  br label %102

81:                                               ; preds = %75
  br label %82

82:                                               ; preds = %81, %65
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %20, align 8, !tbaa !11
  %85 = add i64 %84, 1
  store i64 %85, ptr %20, align 8, !tbaa !11
  br label %38, !llvm.loop !13

86:                                               ; preds = %38
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = load i64, ptr %12, align 8, !tbaa !11
  %89 = load ptr, ptr %17, align 8, !tbaa !5
  %90 = load ptr, ptr %19, align 8, !tbaa !5
  call void @rl_internal_bitop(i32 noundef %87, i64 noundef %88, ptr noundef %89, ptr noundef %90, ptr noundef %18, ptr noundef %21)
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = load i64, ptr %11, align 8, !tbaa !11
  %94 = load ptr, ptr %18, align 8, !tbaa !5
  %95 = load i64, ptr %21, align 8, !tbaa !11
  %96 = call i32 @rl_set(ptr noundef %91, ptr noundef %92, i64 noundef %93, ptr noundef %94, i64 noundef %95, i32 noundef 0, i64 noundef 0)
  store i32 %96, ptr %16, align 4, !tbaa !9
  %97 = load i32, ptr %16, align 4, !tbaa !9
  %98 = icmp ne i32 0, %97
  br i1 %98, label %99, label %100

99:                                               ; preds = %86
  br label %102

100:                                              ; preds = %86
  %101 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %101) #5
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %100, %99, %80, %61, %34, %27
  %103 = load ptr, ptr %17, align 8, !tbaa !5
  %104 = icmp ne ptr %103, null
  br i1 %104, label %105, label %127

105:                                              ; preds = %102
  %106 = load i64, ptr %20, align 8, !tbaa !11
  %107 = icmp ugt i64 %106, 0
  br i1 %107, label %108, label %123

108:                                              ; preds = %105
  %109 = load i64, ptr %20, align 8, !tbaa !11
  %110 = add i64 %109, -1
  store i64 %110, ptr %20, align 8, !tbaa !11
  br label %111

111:                                              ; preds = %119, %108
  %112 = load i64, ptr %20, align 8, !tbaa !11
  %113 = icmp ugt i64 %112, 0
  br i1 %113, label %114, label %122

114:                                              ; preds = %111
  %115 = load ptr, ptr %17, align 8, !tbaa !5
  %116 = load i64, ptr %20, align 8, !tbaa !11
  %117 = getelementptr inbounds ptr, ptr %115, i64 %116
  %118 = load ptr, ptr %117, align 8, !tbaa !5
  call void @free(ptr noundef %118) #5
  br label %119

119:                                              ; preds = %114
  %120 = load i64, ptr %20, align 8, !tbaa !11
  %121 = add i64 %120, -1
  store i64 %121, ptr %20, align 8, !tbaa !11
  br label %111, !llvm.loop !15

122:                                              ; preds = %111
  br label %123

123:                                              ; preds = %122, %105
  %124 = load ptr, ptr %17, align 8, !tbaa !5
  %125 = getelementptr inbounds ptr, ptr %124, i64 0
  %126 = load ptr, ptr %125, align 8, !tbaa !5
  call void @free(ptr noundef %126) #5
  br label %127

127:                                              ; preds = %123, %102
  %128 = load ptr, ptr %17, align 8, !tbaa !5
  call void @free(ptr noundef %128) #5
  %129 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %129) #5
  %130 = load i32, ptr %16, align 4, !tbaa !9
  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 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  ret i32 %130
}

declare void @rl_internal_bitop(i32 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

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 = { 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 = { 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 #4 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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
declare dso_local i32 @rl_set(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

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

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

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

; 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

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

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

13:                                               ; preds = %7
  %14 = tail call noalias ptr @malloc(i64 noundef %11) #6
  %.not53 = icmp eq ptr %14, null
  br i1 %.not53, label %.thread, label %15

15:                                               ; preds = %13
  store ptr null, ptr %14, align 8, !tbaa !5
  %.not72 = icmp eq i64 %4, 0
  br i1 %.not72, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %15, %25
  %.067 = phi i64 [ %27, %25 ], [ 0, %15 ]
  %16 = getelementptr inbounds ptr, ptr %5, i64 %.067
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i64, ptr %6, i64 %.067
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %14, i64 %.067
  %21 = call i32 @rl_get(ptr noundef %0, ptr noundef %17, i64 noundef %19, ptr noundef nonnull %20, ptr noundef nonnull %8)
  switch i32 %21, label %.loopexit64 [
    i32 3, label %22
    i32 0, label %23
  ]

22:                                               ; preds = %.lr.ph
  store ptr null, ptr %20, align 8, !tbaa !5
  br label %25

23:                                               ; preds = %.lr.ph
  %24 = load i64, ptr %8, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %22, %23
  %.sink = phi i64 [ 0, %22 ], [ %24, %23 ]
  %26 = getelementptr inbounds i64, ptr %12, i64 %.067
  store i64 %.sink, ptr %26, align 8, !tbaa !9
  %27 = add nuw i64 %.067, 1
  %exitcond.not = icmp eq i64 %27, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %25, %15
  call void @rl_internal_bitop(i32 noundef %1, i64 noundef %4, ptr noundef nonnull %14, ptr noundef nonnull %12, ptr noundef nonnull %9, ptr noundef nonnull %10) #5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load i64, ptr %10, align 8, !tbaa !9
  %30 = call i32 @rl_set(ptr noundef %0, ptr noundef %2, i64 noundef %3, ptr noundef %28, i64 noundef %29, i32 noundef 0, i64 noundef 0)
  %.not54 = icmp eq i32 %30, 0
  br i1 %.not54, label %31, label %.loopexit64

31:                                               ; preds = %._crit_edge
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  call void @free(ptr noundef %32) #5
  br label %.loopexit64

.loopexit64:                                      ; preds = %.lr.ph, %31, %._crit_edge
  %.066 = phi i64 [ %4, %._crit_edge ], [ %4, %31 ], [ %.067, %.lr.ph ]
  %.045 = phi i32 [ %30, %._crit_edge ], [ 0, %31 ], [ %21, %.lr.ph ]
  %or.cond = icmp ult i64 %.066, 2
  br i1 %or.cond, label %.loopexit, label %.lr.ph71.preheader

.lr.ph71.preheader:                               ; preds = %.loopexit64
  %.268 = add i64 %.066, -1
  br label %.lr.ph71

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %.lr.ph71
  %.270 = phi i64 [ %.2, %.lr.ph71 ], [ %.268, %.lr.ph71.preheader ]
  %33 = getelementptr inbounds ptr, ptr %14, i64 %.270
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  call void @free(ptr noundef %34) #5
  %.2 = add i64 %.270, -1
  %.not57 = icmp eq i64 %.2, 0
  br i1 %.not57, label %.loopexit, label %.lr.ph71, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph71, %.loopexit64
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %35) #5
  br label %.thread

.thread:                                          ; preds = %13, %7, %.loopexit
  %.04463 = phi ptr [ %14, %.loopexit ], [ null, %7 ], [ null, %13 ]
  %.04562 = phi i32 [ %.045, %.loopexit ], [ 4, %7 ], [ 4, %13 ]
  call void @free(ptr noundef %.04463) #5
  call void @free(ptr noundef %12) #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
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  ret i32 %.04562
}

declare void @rl_internal_bitop(i32 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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 = { 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 = { 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 #4 = { "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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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