; LLVM IR from jrouwe/JoltPhysics :: TestFramework/Renderer (Font)

; 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.stbtt_pack_context = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, ptr, ptr }

; 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
declare void @free(ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local i32 @stbtt_PackBegin(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6) #3 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %20 = call noalias ptr @malloc(i64 noundef 20) #7
  store ptr %20, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %14, align 4, !tbaa !9
  %23 = sub nsw i32 %21, %22
  store i32 %23, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %24 = load i32, ptr %17, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = mul i64 1, %25
  %27 = call noalias ptr @malloc(i64 noundef %26) #7
  store ptr %27, ptr %18, align 8, !tbaa !5
  %28 = load ptr, ptr %16, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %7
  %31 = load ptr, ptr %18, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %44

33:                                               ; preds = %30, %7
  %34 = load ptr, ptr %16, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %38

36:                                               ; preds = %33
  %37 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %37) #6
  br label %38

38:                                               ; preds = %36, %33
  %39 = load ptr, ptr %18, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %42) #6
  br label %43

43:                                               ; preds = %41, %38
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %100

44:                                               ; preds = %30
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.stbtt_pack_context, ptr %46, i32 0, i32 0
  store ptr %45, ptr %47, align 8, !tbaa !11
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.stbtt_pack_context, ptr %49, i32 0, i32 2
  store i32 %48, ptr %50, align 8, !tbaa !13
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.stbtt_pack_context, ptr %52, i32 0, i32 3
  store i32 %51, ptr %53, align 4, !tbaa !14
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.stbtt_pack_context, ptr %55, i32 0, i32 9
  store ptr %54, ptr %56, align 8, !tbaa !15
  %57 = load ptr, ptr %16, align 8, !tbaa !5
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.stbtt_pack_context, ptr %58, i32 0, i32 1
  store ptr %57, ptr %59, align 8, !tbaa !16
  %60 = load ptr, ptr %18, align 8, !tbaa !5
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.stbtt_pack_context, ptr %61, i32 0, i32 10
  store ptr %60, ptr %62, align 8, !tbaa !17
  %63 = load i32, ptr %14, align 4, !tbaa !9
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.stbtt_pack_context, ptr %64, i32 0, i32 5
  store i32 %63, ptr %65, align 4, !tbaa !18
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %44
  %69 = load i32, ptr %13, align 4, !tbaa !9
  br label %72

70:                                               ; preds = %44
  %71 = load i32, ptr %11, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %70, %68
  %73 = phi i32 [ %69, %68 ], [ %71, %70 ]
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.stbtt_pack_context, ptr %74, i32 0, i32 4
  store i32 %73, ptr %75, align 8, !tbaa !19
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.stbtt_pack_context, ptr %76, i32 0, i32 7
  store i32 1, ptr %77, align 4, !tbaa !20
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.stbtt_pack_context, ptr %78, i32 0, i32 8
  store i32 1, ptr %79, align 8, !tbaa !21
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.stbtt_pack_context, ptr %80, i32 0, i32 6
  store i32 0, ptr %81, align 8, !tbaa !22
  %82 = load ptr, ptr %16, align 8, !tbaa !5
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = load i32, ptr %14, align 4, !tbaa !9
  %85 = sub nsw i32 %83, %84
  %86 = load i32, ptr %12, align 4, !tbaa !9
  %87 = load i32, ptr %14, align 4, !tbaa !9
  %88 = sub nsw i32 %86, %87
  %89 = load ptr, ptr %18, align 8, !tbaa !5
  %90 = load i32, ptr %17, align 4, !tbaa !9
  call void @_ZL17stbrp_init_targetP13stbrp_contextiiP10stbrp_nodei(ptr noundef %82, i32 noundef %85, i32 noundef %88, ptr noundef %89, i32 noundef %90)
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = icmp ne ptr %91, null
  br i1 %92, label %93, label %99

93:                                               ; preds = %72
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = load i32, ptr %12, align 4, !tbaa !9
  %97 = mul nsw i32 %95, %96
  %98 = sext i32 %97 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %94, i8 0, i64 %98, i1 false)
  br label %99

99:                                               ; preds = %93, %72
  store i32 1, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %100

100:                                              ; preds = %99, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  %101 = load i32, ptr %8, align 4
  ret i32 %101
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL17stbrp_init_targetP13stbrp_contextiiP10stbrp_nodei(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

!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, !6, i64 0}
!12 = !{!"_ZTS18stbtt_pack_context", !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, !6, i64 48, !6, i64 56}
!13 = !{!12, !10, i64 16}
!14 = !{!12, !10, i64 20}
!15 = !{!12, !6, i64 48}
!16 = !{!12, !6, i64 8}
!17 = !{!12, !6, i64 56}
!18 = !{!12, !10, i64 28}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !10, i64 36}
!21 = !{!12, !10, i64 40}
!22 = !{!12, !10, i64 32}


; 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local range(i32 0, 2) i32 @stbtt_PackBegin(ptr nocapture noundef writeonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = tail call noalias dereferenceable_or_null(20) ptr @malloc(i64 noundef 20) #4
  %9 = sub nsw i32 %2, %5
  %10 = sext i32 %9 to i64
  %11 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %12 = icmp eq ptr %8, null
  %13 = icmp eq ptr %11, null
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %14, label %18

14:                                               ; preds = %7
  br i1 %12, label %16, label %15

15:                                               ; preds = %14
  tail call void @free(ptr noundef nonnull %8) #5
  br label %16

16:                                               ; preds = %15, %14
  br i1 %13, label %34, label %17

17:                                               ; preds = %16
  tail call void @free(ptr noundef nonnull %11) #5
  br label %34

18:                                               ; preds = %7
  store ptr %6, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %2, ptr %19, align 8, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %3, ptr %20, align 4, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %1, ptr %21, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %8, ptr %22, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %11, ptr %23, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %5, ptr %24, align 4, !tbaa !16
  %.not = icmp eq i32 %4, 0
  %25 = select i1 %.not, i32 %2, i32 %4
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %25, ptr %26, align 8, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 1, ptr %27, align 4, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 1, ptr %28, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 0, ptr %29, align 8, !tbaa !20
  %30 = sub nsw i32 %3, %5
  tail call void @_ZL17stbrp_init_targetP13stbrp_contextiiP10stbrp_nodei(ptr noundef nonnull %8, i32 noundef %9, i32 noundef %30, ptr noundef nonnull %11, i32 noundef %9)
  %.not46 = icmp eq ptr %1, null
  br i1 %.not46, label %34, label %31

31:                                               ; preds = %18
  %32 = mul nsw i32 %3, %2
  %33 = sext i32 %32 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %1, i8 0, i64 %33, i1 false)
  br label %34

34:                                               ; preds = %18, %31, %16, %17
  %.0 = phi i32 [ 0, %17 ], [ 0, %16 ], [ 1, %31 ], [ 1, %18 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL17stbrp_init_targetP13stbrp_contextiiP10stbrp_nodei(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind allocsize(0) }
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, !7, i64 0}
!6 = !{!"_ZTS18stbtt_pack_context", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!6, !10, i64 20}
!13 = !{!6, !7, i64 48}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 56}
!16 = !{!6, !10, i64 28}
!17 = !{!6, !10, i64 24}
!18 = !{!6, !10, i64 36}
!19 = !{!6, !10, i64 40}
!20 = !{!6, !10, i64 32}


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