; LLVM IR from libtcod/libtcod :: src/vendor (stb)

; 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: nounwind 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) #5
  %20 = load ptr, ptr %15, align 8, !tbaa !5
  %21 = call noalias ptr @malloc(i64 noundef 20) #6
  store ptr %21, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = load i32, ptr %14, align 4, !tbaa !9
  %24 = sub nsw i32 %22, %23
  store i32 %24, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %25 = load ptr, ptr %15, align 8, !tbaa !5
  %26 = load i32, ptr %17, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = mul i64 1, %27
  %29 = call noalias ptr @malloc(i64 noundef %28) #6
  store ptr %29, ptr %18, align 8, !tbaa !5
  %30 = load ptr, ptr %16, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %35, label %32

32:                                               ; preds = %7
  %33 = load ptr, ptr %18, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %48

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

38:                                               ; preds = %35
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %40) #5
  br label %41

41:                                               ; preds = %38, %35
  %42 = load ptr, ptr %18, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %47

44:                                               ; preds = %41
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = load ptr, ptr %18, align 8, !tbaa !5
  call void @free(ptr noundef %46) #5
  br label %47

47:                                               ; preds = %44, %41
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %104

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

72:                                               ; preds = %48
  %73 = load i32, ptr %13, align 4, !tbaa !9
  br label %76

74:                                               ; preds = %48
  %75 = load i32, ptr %11, align 4, !tbaa !9
  br label %76

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

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

103:                                              ; preds = %97, %76
  store i32 1, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %104

104:                                              ; preds = %103, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %105 = load i32, ptr %8, align 4
  ret i32 %105
}

; Function Attrs: nounwind uwtable
declare hidden void @stbrp_init_target(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #3

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

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"stbtt_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: 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 @stbrp_init_target(ptr noundef nonnull %8, i32 noundef %9, i32 noundef %30, ptr noundef nonnull %11, i32 noundef %9)
  %.not50 = icmp eq ptr %1, null
  br i1 %.not50, 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: nounwind uwtable
declare hidden void @stbrp_init_target(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 = { 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 = !{!"stbtt_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/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