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

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

@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [118 x i8], align 1
@__PRETTY_FUNCTION__._Z10sth_createiiP15RenderCallbacks = external hidden unnamed_addr constant [58 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z10sth_createiiP15RenderCallbacks(i32 noundef %0, i32 noundef %1, ptr noundef %2) #4 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !9
  %9 = call noalias ptr @malloc(i64 noundef 48) #6
  store ptr %9, ptr %7, align 8, !tbaa !9
  %10 = load ptr, ptr %7, align 8, !tbaa !9
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.17, i32 noundef 148, ptr noundef @__PRETTY_FUNCTION__._Z10sth_createiiP15RenderCallbacks) #7
  unreachable

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %14, i8 0, i64 48, i1 false)
  %15 = load ptr, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.sth_stash, ptr %16, i32 0, i32 7
  store ptr %15, ptr %17, align 8, !tbaa !11
  %18 = call noalias ptr @malloc(i64 noundef 82720) #6
  store ptr %18, ptr %8, align 8, !tbaa !9
  %19 = load ptr, ptr %8, align 8, !tbaa !9
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.17, i32 noundef 158, ptr noundef @__PRETTY_FUNCTION__._Z10sth_createiiP15RenderCallbacks) #7
  unreachable

22:                                               ; preds = %13
  %23 = load ptr, ptr %8, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %23, i8 0, i64 82720, i1 false)
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.sth_stash, ptr %25, i32 0, i32 0
  store i32 %24, ptr %26, align 8, !tbaa !14
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.sth_stash, ptr %28, i32 0, i32 1
  store i32 %27, ptr %29, align 4, !tbaa !15
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sitofp i32 %30 to float
  %32 = fdiv float 1.000000e+00, %31
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.sth_stash, ptr %33, i32 0, i32 2
  store float %32, ptr %34, align 8, !tbaa !16
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = sitofp i32 %35 to float
  %37 = fdiv float 1.000000e+00, %36
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.sth_stash, ptr %38, i32 0, i32 3
  store float %37, ptr %39, align 4, !tbaa !17
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.sth_stash, ptr %41, i32 0, i32 4
  store ptr %40, ptr %42, align 8, !tbaa !18
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.sth_stash, ptr %43, i32 0, i32 7
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.sth_stash, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !14
  %50 = load ptr, ptr %7, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.sth_stash, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !15
  %53 = load ptr, ptr %45, align 8, !tbaa !19
  %54 = getelementptr inbounds ptr, ptr %53, i64 5
  %55 = load ptr, ptr %54, align 8
  call void %55(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef %46, ptr noundef null, i32 noundef %49, i32 noundef %52)
  %56 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %56
}

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


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

@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [118 x i8], align 1
@__PRETTY_FUNCTION__._Z10sth_createiiP15RenderCallbacks = external hidden unnamed_addr constant [58 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
define dso_local noundef ptr @_Z10sth_createiiP15RenderCallbacks(i32 noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %calloc21 = tail call dereferenceable_or_null(48) ptr @calloc(i64 1, i64 48)
  %4 = icmp eq ptr %calloc21, null
  br i1 %4, label %5, label %6

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.17, i32 noundef 148, ptr noundef nonnull @__PRETTY_FUNCTION__._Z10sth_createiiP15RenderCallbacks) #3
  unreachable

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %calloc21, i64 40
  store ptr %2, ptr %7, align 8, !tbaa !5
  %calloc = tail call dereferenceable_or_null(82720) ptr @calloc(i64 1, i64 82720)
  %8 = icmp eq ptr %calloc, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.17, i32 noundef 158, ptr noundef nonnull @__PRETTY_FUNCTION__._Z10sth_createiiP15RenderCallbacks) #3
  unreachable

10:                                               ; preds = %6
  store i32 %0, ptr %calloc21, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %calloc21, i64 4
  store i32 %1, ptr %11, align 4, !tbaa !13
  %12 = insertelement <2 x i32> poison, i32 %0, i64 0
  %13 = insertelement <2 x i32> %12, i32 %1, i64 1
  %14 = sitofp <2 x i32> %13 to <2 x float>
  %15 = getelementptr inbounds i8, ptr %calloc21, i64 8
  %16 = fdiv <2 x float> <float 1.000000e+00, float 1.000000e+00>, %14
  store <2 x float> %16, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %calloc21, i64 16
  store ptr %calloc, ptr %17, align 8, !tbaa !15
  %18 = load ptr, ptr %2, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %18, i64 40
  %20 = load ptr, ptr %19, align 8
  tail call void %20(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull %calloc, ptr noundef null, i32 noundef %0, i32 noundef %1)
  ret ptr %calloc21
}

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

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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #3 = { 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 40}
!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 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !11, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !9, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass