; LLVM IR from Eukky/TRender :: lib/imgui (imgui_draw)

; 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.ImVec2 = type { float, float }
%struct.ImDrawVert = type { %struct.ImVec2, %struct.ImVec2, i32 }

; 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 uwtable
declare hidden <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui38ShadeVertsLinearColorGradientKeepAlphaEP10ImDrawVertS1_6ImVec2S2_jj(ptr noundef %0, ptr noundef %1, <2 x float> %2, <2 x float> %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca %struct.ImVec2, align 4
  %8 = alloca %struct.ImVec2, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.ImVec2, align 4
  %14 = alloca float, align 4
  %15 = alloca ptr, align 8
  %16 = alloca float, align 4
  %17 = alloca %struct.ImVec2, align 4
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store <2 x float> %2, ptr %7, align 4
  store <2 x float> %3, ptr %8, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %22 = call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %22, ptr %13, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %23 = call noundef float @_ZL11ImLengthSqrRK6ImVec2(ptr noundef nonnull align 4 dereferenceable(8) %13)
  %24 = fdiv float 1.000000e+00, %23
  store float %24, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %25, ptr %15, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %79, %6
  %27 = load ptr, ptr %15, align 8, !tbaa !5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = icmp ult ptr %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %82

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ImDrawVert, ptr %32, i32 0, i32 0
  %34 = call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %33, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %34, ptr %17, align 4
  %35 = call noundef float @_ZL5ImDotRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %17, ptr noundef nonnull align 4 dereferenceable(8) %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  store float %35, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %36 = load float, ptr %16, align 4, !tbaa !11
  %37 = load float, ptr %14, align 4, !tbaa !11
  %38 = fmul float %36, %37
  %39 = call noundef float @_ZL7ImClampIfET_S0_S0_S0_(float noundef %38, float noundef 0.000000e+00, float noundef 1.000000e+00)
  store float %39, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = lshr i32 %40, 0
  %42 = and i32 %41, 255
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = lshr i32 %43, 0
  %45 = and i32 %44, 255
  %46 = load float, ptr %18, align 4, !tbaa !11
  %47 = call noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef %42, i32 noundef %45, float noundef %46)
  store i32 %47, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = lshr i32 %48, 8
  %50 = and i32 %49, 255
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = lshr i32 %51, 8
  %53 = and i32 %52, 255
  %54 = load float, ptr %18, align 4, !tbaa !11
  %55 = call noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef %50, i32 noundef %53, float noundef %54)
  store i32 %55, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = lshr i32 %56, 16
  %58 = and i32 %57, 255
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = lshr i32 %59, 16
  %61 = and i32 %60, 255
  %62 = load float, ptr %18, align 4, !tbaa !11
  %63 = call noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef %58, i32 noundef %61, float noundef %62)
  store i32 %63, ptr %21, align 4, !tbaa !9
  %64 = load i32, ptr %19, align 4, !tbaa !9
  %65 = shl i32 %64, 0
  %66 = load i32, ptr %20, align 4, !tbaa !9
  %67 = shl i32 %66, 8
  %68 = or i32 %65, %67
  %69 = load i32, ptr %21, align 4, !tbaa !9
  %70 = shl i32 %69, 16
  %71 = or i32 %68, %70
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ImDrawVert, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 4, !tbaa !13
  %75 = and i32 %74, -16777216
  %76 = or i32 %71, %75
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ImDrawVert, ptr %77, i32 0, i32 2
  store i32 %76, ptr %78, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %79

79:                                               ; preds = %31
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ImDrawVert, ptr %80, i32 1
  store ptr %81, ptr %15, align 8, !tbaa !5
  br label %26, !llvm.loop !16

82:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL11ImLengthSqrRK6ImVec2(ptr noundef nonnull align 4 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL5ImDotRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL7ImClampIfET_S0_S0_S0_(float noundef, float noundef, float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef, i32 noundef, float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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"="64" "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 }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTS10ImDrawVert", !15, i64 0, !15, i64 8, !10, i64 16}
!15 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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.ImVec2 = type { float, float }

; 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: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui38ShadeVertsLinearColorGradientKeepAlphaEP10ImDrawVertS1_6ImVec2S2_jj(ptr noundef %0, ptr noundef readnone %1, <2 x float> %2, <2 x float> %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #2 {
  %7 = alloca %struct.ImVec2, align 8
  %8 = alloca %struct.ImVec2, align 8
  %9 = alloca %struct.ImVec2, align 8
  %10 = alloca %struct.ImVec2, align 8
  store <2 x float> %2, ptr %7, align 8
  store <2 x float> %3, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  %11 = call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %11, ptr %9, align 8
  %12 = call noundef float @_ZL11ImLengthSqrRK6ImVec2(ptr noundef nonnull align 4 dereferenceable(8) %9)
  %13 = fdiv float 1.000000e+00, %12
  %14 = icmp ult ptr %0, %1
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %15 = and i32 %4, 255
  %16 = and i32 %5, 255
  %17 = lshr i32 %4, 8
  %18 = and i32 %17, 255
  %19 = lshr i32 %5, 8
  %20 = and i32 %19, 255
  %21 = lshr i32 %4, 16
  %22 = and i32 %21, 255
  %23 = lshr i32 %5, 16
  %24 = and i32 %23, 255
  br label %25

._crit_edge:                                      ; preds = %25, %6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  ret void

25:                                               ; preds = %.lr.ph, %25
  %.020 = phi ptr [ %0, %.lr.ph ], [ %41, %25 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  %26 = call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %.020, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %26, ptr %10, align 8
  %27 = call noundef float @_ZL5ImDotRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  %28 = fmul float %13, %27
  %29 = call noundef float @_ZL7ImClampIfET_S0_S0_S0_(float noundef %28, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %30 = call noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef %15, i32 noundef %16, float noundef %29)
  %31 = call noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef %18, i32 noundef %20, float noundef %29)
  %32 = call noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef %22, i32 noundef %24, float noundef %29)
  %33 = shl i32 %31, 8
  %34 = or i32 %33, %30
  %35 = shl i32 %32, 16
  %36 = or i32 %34, %35
  %37 = getelementptr inbounds i8, ptr %.020, i64 16
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = and i32 %38, -16777216
  %40 = or i32 %36, %39
  store i32 %40, ptr %37, align 4, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %.020, i64 20
  %42 = icmp ult ptr %41, %1
  br i1 %42, label %25, label %._crit_edge, !llvm.loop !12
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL11ImLengthSqrRK6ImVec2(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL5ImDotRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL7ImClampIfET_S0_S0_S0_(float noundef, float noundef, float noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL6ImLerpIiET_S0_S0_f(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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"="64" "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 }

!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 16}
!6 = !{!"_ZTS10ImDrawVert", !7, i64 0, !7, i64 8, !11, i64 16}
!7 = !{!"_ZTS6ImVec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass