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

; 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.ImFontConfig = type { ptr, i32, i8, i32, float, i32, i32, i8, %struct.ImVec2, %struct.ImVec2, ptr, float, float, i8, i32, float, [40 x i8], ptr }
%struct.ImVec2 = type { float, float }

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN11ImFontAtlas18AddFontFromFileTTFEPKcfPK12ImFontConfigPKt = external hidden unnamed_addr constant [100 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11ImFontAtlas18AddFontFromFileTTFEPKcfPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef %1, float noundef %2, ptr noundef %3, ptr noundef %4) #4 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.ImFontConfig, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = call noundef ptr @_Z18ImFileLoadToMemoryPKcS0_Pmi(ptr noundef %16, ptr noundef @.str.11, ptr noundef %11, i32 noundef 0)
  store ptr %17, ptr %12, align 8, !tbaa !5
  %18 = load ptr, ptr %12, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 1564, ptr noundef @__PRETTY_FUNCTION__._ZN11ImFontAtlas18AddFontFromFileTTFEPKcfPK12ImFontConfigPKt) #7
  unreachable

21:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 136, ptr %13) #6
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %25, i64 136, i1 false), !tbaa.struct !13
  br label %27

26:                                               ; preds = %21
  call void @_ZN12ImFontConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(136) %13)
  br label %27

27:                                               ; preds = %26, %24
  %28 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 16
  %29 = getelementptr inbounds [40 x i8], ptr %28, i64 0, i64 0
  %30 = load i8, ptr %29, align 4, !tbaa !18
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %67

33:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call i64 @strlen(ptr noundef %35) #8
  %37 = getelementptr inbounds i8, ptr %34, i64 %36
  store ptr %37, ptr %14, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %57, %33
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = icmp ugt ptr %39, %40
  br i1 %41, label %42, label %54

42:                                               ; preds = %38
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 -1
  %45 = load i8, ptr %44, align 1, !tbaa !18
  %46 = sext i8 %45 to i32
  %47 = icmp ne i32 %46, 47
  br i1 %47, label %48, label %54

48:                                               ; preds = %42
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 -1
  %51 = load i8, ptr %50, align 1, !tbaa !18
  %52 = sext i8 %51 to i32
  %53 = icmp ne i32 %52, 92
  br label %54

54:                                               ; preds = %48, %42, %38
  %55 = phi i1 [ false, %42 ], [ false, %38 ], [ %53, %48 ]
  br i1 %55, label %56, label %60

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i32 -1
  store ptr %59, ptr %14, align 8, !tbaa !5
  br label %38, !llvm.loop !19

60:                                               ; preds = %54
  %61 = getelementptr inbounds %struct.ImFontConfig, ptr %13, i32 0, i32 16
  %62 = getelementptr inbounds [40 x i8], ptr %61, i64 0, i64 0
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = load float, ptr %8, align 4, !tbaa !9
  %65 = fpext float %64 to double
  %66 = call noundef i32 (ptr, i64, ptr, ...) @_Z14ImFormatStringPcmPKcz(ptr noundef %62, i64 noundef 40, ptr noundef @.str.13, ptr noundef %63, double noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %67

67:                                               ; preds = %60, %27
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i64, ptr %11, align 8, !tbaa !11
  %70 = trunc i64 %69 to i32
  %71 = load float, ptr %8, align 4, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = call noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(116) %15, ptr noundef %68, i32 noundef %70, float noundef %71, ptr noundef %13, ptr noundef %72)
  call void @llvm.lifetime.end.p0(i64 136, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  ret ptr %73
}

declare noundef ptr @_Z18ImFileLoadToMemoryPKcS0_Pmi(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #5

declare noundef i32 @_Z14ImFormatStringPcmPKcz(ptr noundef, i64 noundef, ptr noundef, ...) #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(116), ptr noundef, i32 noundef, float noundef, ptr noundef, ptr noundef) #4 align 2

declare void @_ZN12ImFontConfigC1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { "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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{i64 0, i64 8, !5, i64 8, i64 4, !14, i64 12, i64 1, !16, i64 16, i64 4, !14, i64 20, i64 4, !9, i64 24, i64 4, !14, i64 28, i64 4, !14, i64 32, i64 1, !16, i64 36, i64 4, !9, i64 40, i64 4, !9, i64 44, i64 4, !9, i64 48, i64 4, !9, i64 56, i64 8, !5, i64 64, i64 4, !9, i64 68, i64 4, !9, i64 72, i64 1, !16, i64 76, i64 4, !14, i64 80, i64 4, !9, i64 84, i64 40, !18, i64 128, i64 8, !5}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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.ImFontConfig = type { ptr, i32, i8, i32, float, i32, i32, i8, %struct.ImVec2, %struct.ImVec2, ptr, float, float, i8, i32, float, [40 x i8], ptr }
%struct.ImVec2 = type { float, float }

@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN11ImFontAtlas18AddFontFromFileTTFEPKcfPK12ImFontConfigPKt = external hidden unnamed_addr constant [100 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress 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) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN11ImFontAtlas18AddFontFromFileTTFEPKcfPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef %1, float noundef %2, ptr noundef readonly %3, ptr noundef %4) local_unnamed_addr #4 align 2 {
  %6 = alloca i64, align 8
  %7 = alloca %struct.ImFontConfig, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  store i64 0, ptr %6, align 8, !tbaa !5
  %8 = call noundef ptr @_Z18ImFileLoadToMemoryPKcS0_Pmi(ptr noundef %1, ptr noundef nonnull @.str.11, ptr noundef nonnull %6, i32 noundef 0)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %5
  call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 1564, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN11ImFontAtlas18AddFontFromFileTTFEPKcfPK12ImFontConfigPKt) #7
  unreachable

10:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 136, ptr nonnull %7) #6
  %.not20 = icmp eq ptr %3, null
  br i1 %.not20, label %12, label %11

11:                                               ; preds = %10
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %7, ptr noundef nonnull align 8 dereferenceable(136) %3, i64 136, i1 false), !tbaa.struct !9
  br label %13

12:                                               ; preds = %10
  call void @_ZN12ImFontConfigC1Ev(ptr noundef nonnull align 8 dereferenceable(136) %7)
  br label %13

13:                                               ; preds = %12, %11
  %14 = getelementptr inbounds i8, ptr %7, i64 84
  %15 = load i8, ptr %14, align 4, !tbaa !18
  %16 = icmp eq i8 %15, 0
  br i1 %16, label %17, label %27

17:                                               ; preds = %13
  %18 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #8
  %19 = getelementptr inbounds i8, ptr %1, i64 %18
  br label %20

20:                                               ; preds = %22, %17
  %.0 = phi ptr [ %19, %17 ], [ %23, %22 ]
  %21 = icmp ugt ptr %.0, %1
  br i1 %21, label %22, label %.critedge

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %.0, i64 -1
  %24 = load i8, ptr %23, align 1, !tbaa !18
  switch i8 %24, label %20 [
    i8 47, label %.critedge
    i8 92, label %.critedge
  ], !llvm.loop !19

.critedge:                                        ; preds = %22, %22, %20
  %25 = fpext float %2 to double
  %26 = call noundef i32 (ptr, i64, ptr, ...) @_Z14ImFormatStringPcmPKcz(ptr noundef nonnull %14, i64 noundef 40, ptr noundef nonnull @.str.13, ptr noundef %.0, double noundef %25)
  br label %27

27:                                               ; preds = %.critedge, %13
  %28 = load i64, ptr %6, align 8, !tbaa !5
  %29 = trunc i64 %28 to i32
  %30 = call noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef nonnull %8, i32 noundef %29, float noundef %2, ptr noundef nonnull %7, ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 136, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  ret ptr %30
}

declare noundef ptr @_Z18ImFileLoadToMemoryPKcS0_Pmi(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

declare noundef i32 @_Z14ImFormatStringPcmPKcz(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11ImFontAtlas20AddFontFromMemoryTTFEPvifPK12ImFontConfigPKt(ptr noundef nonnull align 8 dereferenceable(116), ptr noundef, i32 noundef, float noundef, ptr noundef, ptr noundef) local_unnamed_addr #4 align 2

declare void @_ZN12ImFontConfigC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #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 = { "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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 8, !10, i64 8, i64 4, !12, i64 12, i64 1, !14, i64 16, i64 4, !12, i64 20, i64 4, !16, i64 24, i64 4, !12, i64 28, i64 4, !12, i64 32, i64 1, !14, i64 36, i64 4, !16, i64 40, i64 4, !16, i64 44, i64 4, !16, i64 48, i64 4, !16, i64 56, i64 8, !10, i64 64, i64 4, !16, i64 68, i64 4, !16, i64 72, i64 1, !14, i64 76, i64 4, !12, i64 80, i64 4, !16, i64 84, i64 40, !18, i64 128, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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