; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl/tiny_font_stash.ll (Z12sth_vmetricsP9sth_stashifPfS1_S1_)

; 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.sth_stash = type { i32, i32, float, float, ptr, ptr, i32, ptr }
%struct.sth_font = type { i32, i32, %struct.stbtt_fontinfo, ptr, ptr, [256 x i32], i32, float, float, float, ptr }
%struct.stbtt_fontinfo = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, 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: mustprogress nounwind uwtable
define dso_local void @_Z12sth_vmetricsP9sth_stashifPfS1_S1_(ptr noundef %0, i32 noundef %1, float noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store float %2, ptr %9, align 4, !tbaa !11
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  store ptr null, ptr %13, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %6
  store i32 1, ptr %14, align 4
  br label %89

18:                                               ; preds = %6
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sth_stash, ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  store i32 1, ptr %14, align 4
  br label %89

24:                                               ; preds = %18
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.sth_stash, ptr %25, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  store ptr %27, ptr %13, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %39, %24
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %37

31:                                               ; preds = %28
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sth_font, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp ne i32 %34, %35
  br label %37

37:                                               ; preds = %31, %28
  %38 = phi i1 [ false, %28 ], [ %36, %31 ]
  br i1 %38, label %39, label %43

39:                                               ; preds = %37
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.sth_font, ptr %40, i32 0, i32 10
  %42 = load ptr, ptr %41, align 8, !tbaa !19
  store ptr %42, ptr %13, align 8, !tbaa !5
  br label %28, !llvm.loop !20

43:                                               ; preds = %37
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store i32 1, ptr %14, align 4
  br label %89

47:                                               ; preds = %43
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.sth_font, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !22
  %51 = icmp ne i32 %50, 3
  br i1 %51, label %52, label %58

52:                                               ; preds = %47
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.sth_font, ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !23
  %56 = icmp ne ptr %55, null
  br i1 %56, label %58, label %57

57:                                               ; preds = %52
  store i32 1, ptr %14, align 4
  br label %89

58:                                               ; preds = %52, %47
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %68

61:                                               ; preds = %58
  %62 = load ptr, ptr %13, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.sth_font, ptr %62, i32 0, i32 7
  %64 = load float, ptr %63, align 4, !tbaa !24
  %65 = load float, ptr %9, align 4, !tbaa !11
  %66 = fmul float %64, %65
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  store float %66, ptr %67, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %61, %58
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %78

71:                                               ; preds = %68
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.sth_font, ptr %72, i32 0, i32 8
  %74 = load float, ptr %73, align 8, !tbaa !25
  %75 = load float, ptr %9, align 4, !tbaa !11
  %76 = fmul float %74, %75
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  store float %76, ptr %77, align 4, !tbaa !11
  br label %78

78:                                               ; preds = %71, %68
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = icmp ne ptr %79, null
  br i1 %80, label %81, label %88

81:                                               ; preds = %78
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.sth_font, ptr %82, i32 0, i32 9
  %84 = load float, ptr %83, align 4, !tbaa !26
  %85 = load float, ptr %9, align 4, !tbaa !11
  %86 = fmul float %84, %85
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  store float %86, ptr %87, align 4, !tbaa !11
  br label %88

88:                                               ; preds = %81, %78
  store i32 0, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %57, %46, %23, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  %90 = load i32, ptr %14, align 4
  switch i32 %90, label %92 [
    i32 0, label %91
    i32 1, label %91
  ]

91:                                               ; preds = %89, %89
  ret void

92:                                               ; preds = %89
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 }

!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, !6, i64 16}
!14 = !{!"_ZTS9sth_stash", !10, i64 0, !10, i64 4, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !10, i64 32, !6, i64 40}
!15 = !{!14, !6, i64 24}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTS8sth_font", !10, i64 0, !10, i64 4, !18, i64 8, !6, i64 64, !6, i64 72, !7, i64 80, !10, i64 1104, !12, i64 1108, !12, i64 1112, !12, i64 1116, !6, i64 1120}
!18 = !{!"_ZTS14stbtt_fontinfo", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!19 = !{!17, !6, i64 1120}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!17, !10, i64 4}
!23 = !{!17, !6, i64 64}
!24 = !{!17, !12, i64 1108}
!25 = !{!17, !12, i64 1112}
!26 = !{!17, !12, i64 1116}


; 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 nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_Z12sth_vmetricsP9sth_stashifPfS1_S1_(ptr noundef readonly %0, i32 noundef %1, float noundef %2, ptr noundef writeonly %3, ptr noundef writeonly %4, ptr noundef writeonly %5) local_unnamed_addr #0 {
  %7 = icmp eq ptr %0, null
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %.loopexit, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %.033 = load ptr, ptr %12, align 8, !tbaa !12
  %cond34 = icmp eq ptr %.033, null
  br i1 %cond34, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %11, %14
  %.035 = phi ptr [ %.0, %14 ], [ %.033, %11 ]
  %13 = load i32, ptr %.035, align 8, !tbaa !13
  %.not26 = icmp eq i32 %13, %1
  br i1 %.not26, label %.critedge, label %14

14:                                               ; preds = %.lr.ph
  %15 = getelementptr inbounds i8, ptr %.035, i64 1120
  %.0 = load ptr, ptr %15, align 8, !tbaa !12
  %cond = icmp eq ptr %.0, null
  br i1 %cond, label %.loopexit, label %.lr.ph, !llvm.loop !16

.critedge:                                        ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %.035, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !18
  %.not27 = icmp eq i32 %17, 3
  br i1 %.not27, label %21, label %18

18:                                               ; preds = %.critedge
  %19 = getelementptr inbounds i8, ptr %.035, i64 64
  %20 = load ptr, ptr %19, align 8, !tbaa !19
  %.not28 = icmp eq ptr %20, null
  br i1 %.not28, label %.loopexit, label %21

21:                                               ; preds = %18, %.critedge
  %.not29 = icmp eq ptr %3, null
  br i1 %.not29, label %26, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %.035, i64 1108
  %24 = load float, ptr %23, align 4, !tbaa !20
  %25 = fmul float %24, %2
  store float %25, ptr %3, align 4, !tbaa !21
  br label %26

26:                                               ; preds = %22, %21
  %.not30 = icmp eq ptr %4, null
  br i1 %.not30, label %31, label %27

27:                                               ; preds = %26
  %28 = getelementptr inbounds i8, ptr %.035, i64 1112
  %29 = load float, ptr %28, align 8, !tbaa !22
  %30 = fmul float %29, %2
  store float %30, ptr %4, align 4, !tbaa !21
  br label %31

31:                                               ; preds = %27, %26
  %.not31 = icmp eq ptr %5, null
  br i1 %.not31, label %.loopexit, label %32

32:                                               ; preds = %31
  %33 = getelementptr inbounds i8, ptr %.035, i64 1116
  %34 = load float, ptr %33, align 4, !tbaa !23
  %35 = fmul float %34, %2
  store float %35, ptr %5, align 4, !tbaa !21
  br label %.loopexit

.loopexit:                                        ; preds = %14, %11, %31, %32, %18, %8, %6
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 = !{!"_ZTS9sth_stash", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 24, !7, i64 32, !11, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTS8sth_font", !7, i64 0, !7, i64 4, !15, i64 8, !11, i64 64, !11, i64 72, !8, i64 80, !7, i64 1104, !10, i64 1108, !10, i64 1112, !10, i64 1116, !11, i64 1120}
!15 = !{!"_ZTS14stbtt_fontinfo", !11, i64 0, !11, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!14, !7, i64 4}
!19 = !{!14, !11, i64 64}
!20 = !{!14, !10, i64 1108}
!21 = !{!10, !10, i64 0}
!22 = !{!14, !10, i64 1112}
!23 = !{!14, !10, i64 1116}


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