; LLVM IR from theolundqvist/parallax-voxel-ray-marcher :: src/external/Dear ImGui/imgui_draw.ll (ZN10ImDrawList19_OnChangedTextureIDEv)

; 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.ImDrawList = type <{ %struct.ImVector, %struct.ImVector.0, %struct.ImVector.1, i32, i32, ptr, ptr, ptr, ptr, %struct.ImVector.2, %struct.ImVector.3, %struct.ImVector.4, %struct.ImDrawCmdHeader, %struct.ImDrawListSplitter, float, [4 x i8] }>
%struct.ImVector = type { i32, i32, ptr }
%struct.ImVector.0 = type { i32, i32, ptr }
%struct.ImVector.1 = type { i32, i32, ptr }
%struct.ImVector.2 = type { i32, i32, ptr }
%struct.ImVector.3 = type { i32, i32, ptr }
%struct.ImVector.4 = type { i32, i32, ptr }
%struct.ImDrawCmdHeader = type <{ %struct.ImVec4, ptr, i32, [4 x i8] }>
%struct.ImVec4 = type { float, float, float, float }
%struct.ImDrawListSplitter = type { i32, i32, %struct.ImVector.5 }
%struct.ImVector.5 = type { i32, i32, ptr }
%struct.ImDrawCmd = type { %struct.ImVec4, ptr, i32, i32, i32, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@__PRETTY_FUNCTION__._ZN10ImDrawList19_OnChangedTextureIDEv = external hidden unnamed_addr constant [39 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ImDrawList10AddDrawCmdEv(ptr noundef nonnull align 8 dereferenceable(196)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN8ImVectorI9ImDrawCmdE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10ImDrawList19_OnChangedTextureIDEv(ptr noundef nonnull align 8 dereferenceable(196) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %7 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds %struct.ImVector, ptr %7, i32 0, i32 2
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 0
  %11 = getelementptr inbounds %struct.ImVector, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !23
  %13 = sub nsw i32 %12, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds %struct.ImDrawCmd, ptr %9, i64 %14
  store ptr %15, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ImDrawCmd, ptr %16, i32 0, i32 4
  %18 = load i32, ptr %17, align 8, !tbaa !24
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %29

20:                                               ; preds = %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImDrawCmd, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !26
  %24 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 12
  %25 = getelementptr inbounds %struct.ImDrawCmdHeader, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !27
  %27 = icmp ne ptr %23, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %20
  call void @_ZN10ImDrawList10AddDrawCmdEv(ptr noundef nonnull align 8 dereferenceable(196) %6)
  store i32 1, ptr %4, align 4
  br label %68

29:                                               ; preds = %20, %1
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ImDrawCmd, ptr %30, i32 0, i32 5
  %32 = load ptr, ptr %31, align 8, !tbaa !28
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  br label %37

35:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 539, ptr noundef @__PRETTY_FUNCTION__._ZN10ImDrawList19_OnChangedTextureIDEv) #6
  unreachable

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ImDrawCmd, ptr %38, i64 -1
  store ptr %39, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ImDrawCmd, ptr %40, i32 0, i32 4
  %42 = load i32, ptr %41, align 8, !tbaa !24
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %61

44:                                               ; preds = %37
  %45 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 0
  %46 = getelementptr inbounds %struct.ImVector, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !23
  %48 = icmp sgt i32 %47, 1
  br i1 %48, label %49, label %61

49:                                               ; preds = %44
  %50 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 12
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 @memcmp(ptr noundef %50, ptr noundef %51, i64 noundef 28) #7
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %61

54:                                               ; preds = %49
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ImDrawCmd, ptr %55, i32 0, i32 5
  %57 = load ptr, ptr %56, align 8, !tbaa !28
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %61

59:                                               ; preds = %54
  %60 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 0
  call void @_ZN8ImVectorI9ImDrawCmdE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(16) %60)
  store i32 1, ptr %4, align 4
  br label %67

61:                                               ; preds = %54, %49, %44, %37
  %62 = getelementptr inbounds %struct.ImDrawList, ptr %6, i32 0, i32 12
  %63 = getelementptr inbounds %struct.ImDrawCmdHeader, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !27
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ImDrawCmd, ptr %65, i32 0, i32 1
  store ptr %64, ptr %66, align 8, !tbaa !26
  store i32 0, ptr %4, align 4
  br label %67

67:                                               ; preds = %61, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %68

68:                                               ; preds = %67, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %69 = load i32, ptr %4, align 4
  switch i32 %69, label %71 [
    i32 0, label %70
    i32 1, label %70
  ]

70:                                               ; preds = %68, %68
  ret void

71:                                               ; preds = %68
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS10ImDrawList", !11, i64 0, !13, i64 16, !14, i64 32, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !15, i64 88, !16, i64 104, !17, i64 120, !18, i64 136, !21, i64 168, !20, i64 192}
!11 = !{!"_ZTS8ImVectorI9ImDrawCmdE", !12, i64 0, !12, i64 4, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS8ImVectorItE", !12, i64 0, !12, i64 4, !6, i64 8}
!14 = !{!"_ZTS8ImVectorI10ImDrawVertE", !12, i64 0, !12, i64 4, !6, i64 8}
!15 = !{!"_ZTS8ImVectorI6ImVec4E", !12, i64 0, !12, i64 4, !6, i64 8}
!16 = !{!"_ZTS8ImVectorIPvE", !12, i64 0, !12, i64 4, !6, i64 8}
!17 = !{!"_ZTS8ImVectorI6ImVec2E", !12, i64 0, !12, i64 4, !6, i64 8}
!18 = !{!"_ZTS15ImDrawCmdHeader", !19, i64 0, !6, i64 16, !12, i64 24}
!19 = !{!"_ZTS6ImVec4", !20, i64 0, !20, i64 4, !20, i64 8, !20, i64 12}
!20 = !{!"float", !7, i64 0}
!21 = !{!"_ZTS18ImDrawListSplitter", !12, i64 0, !12, i64 4, !22, i64 8}
!22 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !12, i64 0, !12, i64 4, !6, i64 8}
!23 = !{!10, !12, i64 0}
!24 = !{!25, !12, i64 32}
!25 = !{!"_ZTS9ImDrawCmd", !19, i64 0, !6, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !6, i64 40, !6, i64 48}
!26 = !{!25, !6, i64 16}
!27 = !{!10, !6, i64 152}
!28 = !{!25, !6, i64 40}


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

%struct.ImDrawCmd = type { %struct.ImVec4, ptr, i32, i32, i32, ptr, ptr }
%struct.ImVec4 = type { float, float, float, float }

@.str.1 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@__PRETTY_FUNCTION__._ZN10ImDrawList19_OnChangedTextureIDEv = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ImDrawList10AddDrawCmdEv(ptr noundef nonnull align 8 dereferenceable(196)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN8ImVectorI9ImDrawCmdE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10ImDrawList19_OnChangedTextureIDEv(ptr noundef nonnull align 8 dereferenceable(196) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load i32, ptr %0, align 8
  %5 = sext i32 %4 to i64
  %6 = getelementptr %struct.ImDrawCmd, ptr %3, i64 %5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i32, ptr %7, align 8, !tbaa !22
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %15, label %9

9:                                                ; preds = %1
  %10 = getelementptr i8, ptr %6, i64 -40
  %11 = load ptr, ptr %10, align 8, !tbaa !24
  %12 = getelementptr inbounds i8, ptr %0, i64 152
  %13 = load ptr, ptr %12, align 8, !tbaa !25
  %.not9 = icmp eq ptr %11, %13
  br i1 %.not9, label %15, label %14

14:                                               ; preds = %9
  tail call void @_ZN10ImDrawList10AddDrawCmdEv(ptr noundef nonnull align 8 dereferenceable(196) %0)
  br label %35

15:                                               ; preds = %9, %1
  %16 = getelementptr i8, ptr %6, i64 -16
  %17 = load ptr, ptr %16, align 8, !tbaa !26
  %18 = icmp eq ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 539, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN10ImDrawList19_OnChangedTextureIDEv) #4
  unreachable

20:                                               ; preds = %15
  %21 = icmp sgt i32 %4, 1
  %or.cond = and i1 %21, %.not
  br i1 %or.cond, label %22, label %31

22:                                               ; preds = %20
  %23 = getelementptr i8, ptr %6, i64 -112
  %24 = getelementptr inbounds i8, ptr %0, i64 136
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %24, ptr noundef nonnull dereferenceable(28) %23, i64 28)
  %25 = icmp eq i32 %bcmp, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = getelementptr i8, ptr %6, i64 -72
  %28 = load ptr, ptr %27, align 8, !tbaa !26
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  tail call void @_ZN8ImVectorI9ImDrawCmdE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br label %35

31:                                               ; preds = %26, %22, %20
  %32 = getelementptr inbounds i8, ptr %0, i64 152
  %33 = load ptr, ptr %32, align 8, !tbaa !25
  %34 = getelementptr i8, ptr %6, i64 -40
  store ptr %33, ptr %34, align 8, !tbaa !24
  br label %35

35:                                               ; preds = %30, %31, %14
  ret void
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

attributes #0 = { noreturn 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 #1 = { 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 #2 = { 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 #3 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { noreturn 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, !11, i64 8}
!6 = !{!"_ZTS10ImDrawList", !7, i64 0, !12, i64 16, !13, i64 32, !8, i64 48, !8, i64 52, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !14, i64 88, !15, i64 104, !16, i64 120, !17, i64 136, !20, i64 168, !19, i64 192}
!7 = !{!"_ZTS8ImVectorI9ImDrawCmdE", !8, i64 0, !8, i64 4, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS8ImVectorItE", !8, i64 0, !8, i64 4, !11, i64 8}
!13 = !{!"_ZTS8ImVectorI10ImDrawVertE", !8, i64 0, !8, i64 4, !11, i64 8}
!14 = !{!"_ZTS8ImVectorI6ImVec4E", !8, i64 0, !8, i64 4, !11, i64 8}
!15 = !{!"_ZTS8ImVectorIPvE", !8, i64 0, !8, i64 4, !11, i64 8}
!16 = !{!"_ZTS8ImVectorI6ImVec2E", !8, i64 0, !8, i64 4, !11, i64 8}
!17 = !{!"_ZTS15ImDrawCmdHeader", !18, i64 0, !11, i64 16, !8, i64 24}
!18 = !{!"_ZTS6ImVec4", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12}
!19 = !{!"float", !9, i64 0}
!20 = !{!"_ZTS18ImDrawListSplitter", !8, i64 0, !8, i64 4, !21, i64 8}
!21 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !8, i64 0, !8, i64 4, !11, i64 8}
!22 = !{!23, !8, i64 32}
!23 = !{!"_ZTS9ImDrawCmd", !18, i64 0, !11, i64 16, !8, i64 24, !8, i64 28, !8, i64 32, !11, i64 40, !11, i64 48}
!24 = !{!23, !11, i64 16}
!25 = !{!6, !11, i64 152}
!26 = !{!23, !11, i64 40}


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