; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui/imgui.ll (Z9ImStristrPKcS0_S0_S0_)

; 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: inlinehint mustprogress nounwind uwtable
declare hidden noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext) #1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %21, label %16

16:                                               ; preds = %4
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = call i64 @strlen(ptr noundef %18) #4
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  store ptr %20, ptr %9, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %16, %4
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %23)
  store i8 %24, ptr %10, align 1, !tbaa !9
  br label %25

25:                                               ; preds = %89, %21
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %32, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i8, ptr %29, align 1, !tbaa !9
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %41, label %32

32:                                               ; preds = %28, %25
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %39

35:                                               ; preds = %32
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = icmp ult ptr %36, %37
  br label %39

39:                                               ; preds = %35, %32
  %40 = phi i1 [ false, %32 ], [ %38, %35 ]
  br label %41

41:                                               ; preds = %39, %28
  %42 = phi i1 [ true, %28 ], [ %40, %39 ]
  br i1 %42, label %43, label %92

43:                                               ; preds = %41
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %45)
  %47 = sext i8 %46 to i32
  %48 = load i8, ptr %10, align 1, !tbaa !9
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %47, %49
  br i1 %50, label %51, label %89

51:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i64 1
  store ptr %53, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 1
  store ptr %55, ptr %12, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %73, %51
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = icmp ult ptr %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 4, ptr %13, align 4
  br label %78

61:                                               ; preds = %56
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = load i8, ptr %62, align 1, !tbaa !9
  %64 = call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %63)
  %65 = sext i8 %64 to i32
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load i8, ptr %66, align 1, !tbaa !9
  %68 = call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %67)
  %69 = sext i8 %68 to i32
  %70 = icmp ne i32 %65, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %61
  store i32 4, ptr %13, align 4
  br label %78

72:                                               ; preds = %61
  br label %73

73:                                               ; preds = %72
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i32 1
  store ptr %75, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %76, i32 1
  store ptr %77, ptr %11, align 8, !tbaa !5
  br label %56, !llvm.loop !10

78:                                               ; preds = %71, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = icmp eq ptr %80, %81
  br i1 %82, label %83, label %85

83:                                               ; preds = %79
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %84, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %86

85:                                               ; preds = %79
  store i32 0, ptr %13, align 4
  br label %86

86:                                               ; preds = %85, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %87 = load i32, ptr %13, align 4
  switch i32 %87, label %93 [
    i32 0, label %88
  ]

88:                                               ; preds = %86
  br label %89

89:                                               ; preds = %88, %43
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %90, i32 1
  store ptr %91, ptr %6, align 8, !tbaa !5
  br label %25, !llvm.loop !12

92:                                               ; preds = %41
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %93

93:                                               ; preds = %92, %86
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  %94 = load ptr, ptr %5, align 8
  ret ptr %94
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 willreturn memory(read) "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 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 willreturn memory(read) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; 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: inlinehint mustprogress nounwind uwtable
declare hidden noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef readonly %0, ptr noundef readnone %1, ptr noundef readonly %2, ptr noundef readnone %3) local_unnamed_addr #2 {
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %5, label %8

5:                                                ; preds = %4
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #3
  %7 = getelementptr inbounds i8, ptr %2, i64 %6
  br label %8

8:                                                ; preds = %5, %4
  %.027 = phi ptr [ %3, %4 ], [ %7, %5 ]
  %9 = load i8, ptr %2, align 1, !tbaa !5
  %10 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %9)
  %.not34 = icmp eq ptr %1, null
  br i1 %.not34, label %.split.us, label %.split

.split.us:                                        ; preds = %8
  %11 = load i8, ptr %0, align 1, !tbaa !5
  %.not30.not.us41 = icmp eq i8 %11, 0
  br i1 %.not30.not.us41, label %.split36.us, label %.critedge.us

.critedge.us:                                     ; preds = %.split.us, %22
  %12 = phi i8 [ %24, %22 ], [ %11, %.split.us ]
  %.028.us42 = phi ptr [ %23, %22 ], [ %0, %.split.us ]
  %13 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %12)
  %14 = icmp eq i8 %13, %10
  br i1 %14, label %.preheader.us, label %22

.preheader.us:                                    ; preds = %.critedge.us, %16
  %.pn.us = phi ptr [ %.025.us, %16 ], [ %2, %.critedge.us ]
  %.028.pn.us = phi ptr [ %.024.us, %16 ], [ %.028.us42, %.critedge.us ]
  %.025.us = getelementptr inbounds i8, ptr %.pn.us, i64 1
  %15 = icmp ult ptr %.025.us, %.027
  br i1 %15, label %16, label %21

16:                                               ; preds = %.preheader.us
  %.024.us = getelementptr inbounds i8, ptr %.028.pn.us, i64 1
  %17 = load i8, ptr %.024.us, align 1, !tbaa !5
  %18 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %17)
  %19 = load i8, ptr %.025.us, align 1, !tbaa !5
  %20 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %19)
  %.not31.us = icmp eq i8 %18, %20
  br i1 %.not31.us, label %.preheader.us, label %21, !llvm.loop !8

21:                                               ; preds = %16, %.preheader.us
  %.not32.us = icmp eq ptr %.025.us, %.027
  br i1 %.not32.us, label %.split36.us, label %22

22:                                               ; preds = %21, %.critedge.us
  %23 = getelementptr inbounds i8, ptr %.028.us42, i64 1
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %.not30.not.us = icmp eq i8 %24, 0
  br i1 %.not30.not.us, label %.split36.us, label %.critedge.us, !llvm.loop !10

.split:                                           ; preds = %8
  %.old37 = icmp ult ptr %0, %1
  br i1 %.old37, label %.critedge, label %.split36.us

.critedge:                                        ; preds = %.split, %35
  %.02838 = phi ptr [ %36, %35 ], [ %0, %.split ]
  %25 = load i8, ptr %.02838, align 1, !tbaa !5
  %26 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %25)
  %27 = icmp eq i8 %26, %10
  br i1 %27, label %.preheader, label %35

.preheader:                                       ; preds = %.critedge, %29
  %.pn = phi ptr [ %.025, %29 ], [ %2, %.critedge ]
  %.028.pn = phi ptr [ %.024, %29 ], [ %.02838, %.critedge ]
  %.025 = getelementptr inbounds i8, ptr %.pn, i64 1
  %28 = icmp ult ptr %.025, %.027
  br i1 %28, label %29, label %34

29:                                               ; preds = %.preheader
  %.024 = getelementptr inbounds i8, ptr %.028.pn, i64 1
  %30 = load i8, ptr %.024, align 1, !tbaa !5
  %31 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %30)
  %32 = load i8, ptr %.025, align 1, !tbaa !5
  %33 = tail call noundef signext i8 @_ZL9ImToUpperc(i8 noundef signext %32)
  %.not31 = icmp eq i8 %31, %33
  br i1 %.not31, label %.preheader, label %34, !llvm.loop !8

34:                                               ; preds = %29, %.preheader
  %.not32 = icmp eq ptr %.025, %.027
  br i1 %.not32, label %.split36.us, label %35

35:                                               ; preds = %34, %.critedge
  %36 = getelementptr inbounds i8, ptr %.02838, i64 1
  %exitcond.not = icmp eq ptr %36, %1
  br i1 %exitcond.not, label %.split36.us, label %.critedge, !llvm.loop !10

.split36.us:                                      ; preds = %35, %34, %21, %22, %.split, %.split.us
  %.us-phi = phi ptr [ null, %.split.us ], [ null, %.split ], [ %.028.us42, %21 ], [ null, %22 ], [ null, %35 ], [ %.02838, %34 ]
  ret ptr %.us-phi
}

attributes #0 = { inlinehint mustprogress 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 nofree nounwind willreturn memory(argmem: read) "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 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 #3 = { nounwind willreturn memory(read) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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