; 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: 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 @rl_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #1

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

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

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

25:                                               ; preds = %8
  %26 = load i32, ptr %12, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 1
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 5, ptr %17, align 4, !tbaa !11
  br label %96

29:                                               ; preds = %25, %8
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load i64, ptr %11, align 8, !tbaa !9
  %33 = load i64, ptr %13, align 8, !tbaa !9
  %34 = load i64, ptr %14, align 8, !tbaa !9
  %35 = call i32 @rl_getrange(ptr noundef %30, ptr noundef %31, i64 noundef %32, i64 noundef %33, i64 noundef %34, ptr noundef %18, ptr noundef %19)
  store i32 %35, ptr %17, align 4, !tbaa !11
  %36 = load i32, ptr %17, align 4, !tbaa !11
  %37 = icmp ne i32 0, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %29
  br label %96

39:                                               ; preds = %29
  %40 = load i64, ptr %19, align 8, !tbaa !9
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %39
  %43 = load ptr, ptr %16, align 8, !tbaa !5
  store i64 -1, ptr %43, align 8, !tbaa !9
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %96

44:                                               ; preds = %39
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load i64, ptr %11, align 8, !tbaa !9
  %48 = call i32 @rl_get(ptr noundef %45, ptr noundef %46, i64 noundef %47, ptr noundef null, ptr noundef %20)
  store i32 %48, ptr %17, align 4, !tbaa !11
  %49 = load i32, ptr %17, align 4, !tbaa !11
  %50 = icmp ne i32 0, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %44
  br label %96

52:                                               ; preds = %44
  %53 = load i64, ptr %20, align 8, !tbaa !9
  %54 = call i32 @rl_normalize_string_range(i64 noundef %53, ptr noundef %13, ptr noundef %14)
  store i32 %54, ptr %17, align 4, !tbaa !11
  %55 = load i32, ptr %17, align 4, !tbaa !11
  %56 = icmp ne i32 0, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %52
  br label %96

58:                                               ; preds = %52
  %59 = load i64, ptr %14, align 8, !tbaa !9
  %60 = load i64, ptr %13, align 8, !tbaa !9
  %61 = sub nsw i64 %59, %60
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %21, align 8, !tbaa !9
  %63 = load i64, ptr %21, align 8, !tbaa !9
  %64 = load i64, ptr %19, align 8, !tbaa !9
  %65 = icmp slt i64 %63, %64
  br i1 %65, label %66, label %68

66:                                               ; preds = %58
  %67 = load i64, ptr %19, align 8, !tbaa !9
  store i64 %67, ptr %21, align 8, !tbaa !9
  br label %68

68:                                               ; preds = %66, %58
  %69 = load ptr, ptr %18, align 8, !tbaa !5
  %70 = load i64, ptr %21, align 8, !tbaa !9
  %71 = load i32, ptr %12, align 4, !tbaa !11
  %72 = call i64 @rl_internal_bitpos(ptr noundef %69, i64 noundef %70, i32 noundef %71)
  store i64 %72, ptr %22, align 8, !tbaa !9
  %73 = load i32, ptr %15, align 4, !tbaa !11
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %85

75:                                               ; preds = %68
  %76 = load i32, ptr %12, align 4, !tbaa !11
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %85

78:                                               ; preds = %75
  %79 = load i64, ptr %22, align 8, !tbaa !9
  %80 = load i64, ptr %21, align 8, !tbaa !9
  %81 = mul nsw i64 %80, 8
  %82 = icmp eq i64 %79, %81
  br i1 %82, label %83, label %85

83:                                               ; preds = %78
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  store i64 -1, ptr %84, align 8, !tbaa !9
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %96

85:                                               ; preds = %78, %75, %68
  %86 = load i64, ptr %22, align 8, !tbaa !9
  %87 = icmp ne i64 %86, -1
  br i1 %87, label %88, label %93

88:                                               ; preds = %85
  %89 = load i64, ptr %13, align 8, !tbaa !9
  %90 = mul nsw i64 %89, 8
  %91 = load i64, ptr %22, align 8, !tbaa !9
  %92 = add nsw i64 %91, %90
  store i64 %92, ptr %22, align 8, !tbaa !9
  br label %93

93:                                               ; preds = %88, %85
  %94 = load i64, ptr %22, align 8, !tbaa !9
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  store i64 %94, ptr %95, align 8, !tbaa !9
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %96

96:                                               ; preds = %93, %83, %57, %51, %42, %38, %28
  %97 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %97) #4
  %98 = load i32, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  ret i32 %98
}

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

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

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

!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}


; 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: mustprogress 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 @rl_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_bitpos(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i64 noundef %4, i64 noundef %5, i32 noundef %6, ptr nocapture noundef writeonly %7) local_unnamed_addr #1 {
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store i64 %4, ptr %9, align 8, !tbaa !5
  store i64 %5, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  store ptr null, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #5
  %or.cond = icmp ugt i32 %3, 1
  br i1 %or.cond, label %40, label %14

14:                                               ; preds = %8
  %15 = call i32 @rl_getrange(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %4, i64 noundef %5, ptr noundef nonnull %11, ptr noundef nonnull %12)
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %16, label %40

16:                                               ; preds = %14
  %17 = load i64, ptr %12, align 8, !tbaa !5
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %.sink.split, label %19

19:                                               ; preds = %16
  %20 = call i32 @rl_get(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef null, ptr noundef nonnull %13)
  %.not35 = icmp eq i32 %20, 0
  br i1 %.not35, label %21, label %40

21:                                               ; preds = %19
  %22 = load i64, ptr %13, align 8, !tbaa !5
  %23 = call i32 @rl_normalize_string_range(i64 noundef %22, ptr noundef nonnull %9, ptr noundef nonnull %10) #5
  %.not36 = icmp eq i32 %23, 0
  br i1 %.not36, label %24, label %40

24:                                               ; preds = %21
  %25 = load i64, ptr %10, align 8, !tbaa !5
  %26 = load i64, ptr %9, align 8, !tbaa !5
  %27 = add i64 %25, 1
  %28 = sub i64 %27, %26
  %29 = load i64, ptr %12, align 8, !tbaa !5
  %spec.select = call i64 @llvm.smax.i64(i64 %28, i64 %29)
  %30 = load ptr, ptr %11, align 8, !tbaa !9
  %31 = call i64 @rl_internal_bitpos(ptr noundef %30, i64 noundef %spec.select, i32 noundef %3) #5
  %32 = icmp ne i32 %6, 0
  %33 = icmp eq i32 %3, 0
  %or.cond3 = and i1 %33, %32
  %34 = shl nsw i64 %spec.select, 3
  %35 = icmp eq i64 %31, %34
  %or.cond39 = select i1 %or.cond3, i1 %35, i1 false
  br i1 %or.cond39, label %.sink.split, label %36

36:                                               ; preds = %24
  %.not37 = icmp eq i64 %31, -1
  %37 = load i64, ptr %9, align 8
  %38 = shl nsw i64 %37, 3
  %39 = add nsw i64 %38, %31
  %.0 = select i1 %.not37, i64 -1, i64 %39
  br label %.sink.split

.sink.split:                                      ; preds = %24, %16, %36
  %.0.sink = phi i64 [ %.0, %36 ], [ -1, %16 ], [ -1, %24 ]
  store i64 %.0.sink, ptr %7, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %.sink.split, %8, %21, %19, %14
  %.028 = phi i32 [ %15, %14 ], [ %20, %19 ], [ %23, %21 ], [ 5, %8 ], [ 0, %.sink.split ]
  %41 = load ptr, ptr %11, align 8, !tbaa !9
  call void @free(ptr noundef %41) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  ret i32 %.028
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #4

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 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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