; LLVM IR from ashishzero/karma :: src/modules/core (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_fontinfo = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.stbtt__buf, %struct.stbtt__buf, %struct.stbtt__buf, %struct.stbtt__buf, %struct.stbtt__buf, %struct.stbtt__buf }
%struct.stbtt__buf = type { ptr, i32, i32 }

@.str.15 = external hidden unnamed_addr constant [5 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: mustprogress nounwind uwtable
declare hidden noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL17stbtt__find_tablePhjPKc(ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local ptr @stbtt_GetFontNameString(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.stbtt_fontinfo, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  store ptr %24, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.stbtt_fontinfo, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !14
  store i32 %27, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %28 = load ptr, ptr %17, align 8, !tbaa !5
  %29 = load i32, ptr %18, align 4, !tbaa !9
  %30 = call noundef i32 @_ZL17stbtt__find_tablePhjPKc(ptr noundef %28, i32 noundef %29, ptr noundef @.str.15)
  store i32 %30, ptr %19, align 4, !tbaa !9
  %31 = load i32, ptr %19, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %6
  store ptr null, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %130

34:                                               ; preds = %6
  %35 = load ptr, ptr %17, align 8, !tbaa !5
  %36 = load i32, ptr %19, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %35, i64 %37
  %39 = getelementptr inbounds i8, ptr %38, i64 2
  %40 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %39)
  %41 = zext i16 %40 to i32
  store i32 %41, ptr %15, align 4, !tbaa !9
  %42 = load i32, ptr %19, align 4, !tbaa !9
  %43 = load ptr, ptr %17, align 8, !tbaa !5
  %44 = load i32, ptr %19, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = getelementptr inbounds i8, ptr %46, i64 4
  %48 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %47)
  %49 = zext i16 %48 to i32
  %50 = add i32 %42, %49
  store i32 %50, ptr %16, align 4, !tbaa !9
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %126, %34
  %52 = load i32, ptr %14, align 4, !tbaa !9
  %53 = load i32, ptr %15, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %129

55:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %56 = load i32, ptr %19, align 4, !tbaa !9
  %57 = add i32 %56, 6
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = mul nsw i32 12, %58
  %60 = add i32 %57, %59
  store i32 %60, ptr %21, align 4, !tbaa !9
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = load ptr, ptr %17, align 8, !tbaa !5
  %63 = load i32, ptr %21, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  %66 = getelementptr inbounds i8, ptr %65, i64 0
  %67 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %66)
  %68 = zext i16 %67 to i32
  %69 = icmp eq i32 %61, %68
  br i1 %69, label %70, label %122

70:                                               ; preds = %55
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = load i32, ptr %21, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %72, i64 %74
  %76 = getelementptr inbounds i8, ptr %75, i64 2
  %77 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %76)
  %78 = zext i16 %77 to i32
  %79 = icmp eq i32 %71, %78
  br i1 %79, label %80, label %122

80:                                               ; preds = %70
  %81 = load i32, ptr %12, align 4, !tbaa !9
  %82 = load ptr, ptr %17, align 8, !tbaa !5
  %83 = load i32, ptr %21, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %82, i64 %84
  %86 = getelementptr inbounds i8, ptr %85, i64 4
  %87 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %86)
  %88 = zext i16 %87 to i32
  %89 = icmp eq i32 %81, %88
  br i1 %89, label %90, label %122

90:                                               ; preds = %80
  %91 = load i32, ptr %13, align 4, !tbaa !9
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load i32, ptr %21, align 4, !tbaa !9
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %92, i64 %94
  %96 = getelementptr inbounds i8, ptr %95, i64 6
  %97 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %96)
  %98 = zext i16 %97 to i32
  %99 = icmp eq i32 %91, %98
  br i1 %99, label %100, label %122

100:                                              ; preds = %90
  %101 = load ptr, ptr %17, align 8, !tbaa !5
  %102 = load i32, ptr %21, align 4, !tbaa !9
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds i8, ptr %101, i64 %103
  %105 = getelementptr inbounds i8, ptr %104, i64 8
  %106 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %105)
  %107 = zext i16 %106 to i32
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %107, ptr %108, align 4, !tbaa !9
  %109 = load ptr, ptr %17, align 8, !tbaa !5
  %110 = load i32, ptr %16, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i8, ptr %109, i64 %111
  %113 = load ptr, ptr %17, align 8, !tbaa !5
  %114 = load i32, ptr %21, align 4, !tbaa !9
  %115 = zext i32 %114 to i64
  %116 = getelementptr inbounds i8, ptr %113, i64 %115
  %117 = getelementptr inbounds i8, ptr %116, i64 10
  %118 = call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %117)
  %119 = zext i16 %118 to i32
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i8, ptr %112, i64 %120
  store ptr %121, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %123

122:                                              ; preds = %90, %80, %70, %55
  store i32 0, ptr %20, align 4
  br label %123

123:                                              ; preds = %122, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  %124 = load i32, ptr %20, align 4
  switch i32 %124, label %130 [
    i32 0, label %125
  ]

125:                                              ; preds = %123
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %14, align 4, !tbaa !9
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %14, align 4, !tbaa !9
  br label %51, !llvm.loop !15

129:                                              ; preds = %51
  store ptr null, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %130

130:                                              ; preds = %129, %123, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %131 = load ptr, ptr %7, align 8
  ret ptr %131
}

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 = { 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 #3 = { 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, !6, i64 8}
!12 = !{!"_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, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !13, i64 80, !13, i64 96, !13, i64 112, !13, i64 128, !13, i64 144, !13, i64 160}
!13 = !{!"_ZTS10stbtt__buf", !6, i64 0, !10, i64 8, !10, i64 12}
!14 = !{!12, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL17stbtt__find_tablePhjPKc(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local ptr @stbtt_GetFontNameString(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %11 = tail call noundef i32 @_ZL17stbtt__find_tablePhjPKc(ptr noundef %8, i32 noundef %10, ptr noundef nonnull @.str.15)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %.loopexit, label %12

12:                                               ; preds = %6
  %13 = zext i32 %11 to i64
  %14 = getelementptr inbounds i8, ptr %8, i64 %13
  %15 = getelementptr inbounds i8, ptr %14, i64 2
  %16 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %15)
  %17 = getelementptr inbounds i8, ptr %14, i64 4
  %18 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %17)
  %19 = zext i16 %18 to i32
  %20 = add i32 %11, %19
  %.not42 = icmp eq i16 %16, 0
  br i1 %.not42, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %12
  %21 = add i32 %11, 6
  %wide.trip.count = zext i16 %16 to i64
  br label %22

22:                                               ; preds = %.lr.ph, %56
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %56 ]
  %23 = trunc i64 %indvars.iv to i32
  %24 = mul i32 %23, 12
  %25 = add i32 %21, %24
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %8, i64 %26
  %28 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef %27)
  %29 = zext i16 %28 to i32
  %30 = icmp eq i32 %29, %2
  br i1 %30, label %31, label %56

31:                                               ; preds = %22
  %32 = getelementptr inbounds i8, ptr %27, i64 2
  %33 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %32)
  %34 = zext i16 %33 to i32
  %35 = icmp eq i32 %34, %3
  br i1 %35, label %36, label %56

36:                                               ; preds = %31
  %37 = getelementptr inbounds i8, ptr %27, i64 4
  %38 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %37)
  %39 = zext i16 %38 to i32
  %40 = icmp eq i32 %39, %4
  br i1 %40, label %41, label %56

41:                                               ; preds = %36
  %42 = getelementptr inbounds i8, ptr %27, i64 6
  %43 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %42)
  %44 = zext i16 %43 to i32
  %45 = icmp eq i32 %44, %5
  br i1 %45, label %46, label %56

46:                                               ; preds = %41
  %47 = getelementptr inbounds i8, ptr %27, i64 8
  %48 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %47)
  %49 = zext i16 %48 to i32
  store i32 %49, ptr %1, align 4, !tbaa !13
  %50 = sext i32 %20 to i64
  %51 = getelementptr inbounds i8, ptr %8, i64 %50
  %52 = getelementptr inbounds i8, ptr %27, i64 10
  %53 = tail call noundef zeroext i16 @_ZL8ttUSHORTPh(ptr noundef nonnull %52)
  %54 = zext i16 %53 to i64
  %55 = getelementptr inbounds i8, ptr %51, i64 %54
  br label %.loopexit

56:                                               ; preds = %41, %36, %31, %22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %22, !llvm.loop !14

.loopexit:                                        ; preds = %56, %12, %46, %6
  %.2 = phi ptr [ %55, %46 ], [ null, %6 ], [ null, %12 ], [ null, %56 ]
  ret ptr %.2
}

attributes #0 = { 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" }

!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 8}
!6 = !{!"_ZTS14stbtt_fontinfo", !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, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !11, i64 80, !11, i64 96, !11, i64 112, !11, i64 128, !11, i64 144, !11, i64 160}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS10stbtt__buf", !7, i64 0, !10, i64 8, !10, i64 12}
!12 = !{!6, !10, i64 16}
!13 = !{!10, !10, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass