; 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.stbrp_node = type { i16, i16, ptr }
%struct.stbrp_context = type { i32, i32, i32, i32, i32, i32, ptr, ptr, [2 x %struct.stbrp_node] }

@.str.6 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__.stbrp_init_target = external hidden unnamed_addr constant [69 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: mustprogress nounwind uwtable
declare dso_local void @stbrp_setup_allow_out_of_mem(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @stbrp_init_target(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = icmp sle i32 %12, 65535
  br i1 %13, label %14, label %17

14:                                               ; preds = %5
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp sle i32 %15, 65535
  br label %17

17:                                               ; preds = %14, %5
  %18 = phi i1 [ false, %5 ], [ %16, %14 ]
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  br label %22

20:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.6, i32 noundef 257, ptr noundef @__PRETTY_FUNCTION__.stbrp_init_target) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %39, %22
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = sub nsw i32 %25, 1
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %28, label %42

28:                                               ; preds = %23
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.stbrp_node, ptr %29, i64 %32
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %struct.stbrp_node, ptr %34, i64 %36
  %38 = getelementptr inbounds %struct.stbrp_node, ptr %37, i32 0, i32 2
  store ptr %33, ptr %38, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %28
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %11, align 4, !tbaa !9
  br label %23, !llvm.loop !14

42:                                               ; preds = %23
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.stbrp_node, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.stbrp_node, ptr %46, i32 0, i32 2
  store ptr null, ptr %47, align 8, !tbaa !11
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.stbrp_context, ptr %48, i32 0, i32 3
  store i32 1, ptr %49, align 4, !tbaa !16
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.stbrp_context, ptr %50, i32 0, i32 4
  store i32 0, ptr %51, align 8, !tbaa !18
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.stbrp_node, ptr %52, i64 0
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.stbrp_context, ptr %54, i32 0, i32 7
  store ptr %53, ptr %55, align 8, !tbaa !19
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.stbrp_context, ptr %56, i32 0, i32 8
  %58 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %57, i64 0, i64 0
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.stbrp_context, ptr %59, i32 0, i32 6
  store ptr %58, ptr %60, align 8, !tbaa !20
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.stbrp_context, ptr %62, i32 0, i32 0
  store i32 %61, ptr %63, align 8, !tbaa !21
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.stbrp_context, ptr %65, i32 0, i32 1
  store i32 %64, ptr %66, align 4, !tbaa !22
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.stbrp_context, ptr %68, i32 0, i32 5
  store i32 %67, ptr %69, align 4, !tbaa !23
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  call void @stbrp_setup_allow_out_of_mem(ptr noundef %70, i32 noundef 0)
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.stbrp_context, ptr %71, i32 0, i32 8
  %73 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %72, i64 0, i64 0
  %74 = getelementptr inbounds %struct.stbrp_node, ptr %73, i32 0, i32 0
  store i16 0, ptr %74, align 8, !tbaa !24
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.stbrp_context, ptr %75, i32 0, i32 8
  %77 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %76, i64 0, i64 0
  %78 = getelementptr inbounds %struct.stbrp_node, ptr %77, i32 0, i32 1
  store i16 0, ptr %78, align 2, !tbaa !25
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.stbrp_context, ptr %79, i32 0, i32 8
  %81 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %80, i64 0, i64 1
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.stbrp_context, ptr %82, i32 0, i32 8
  %84 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %83, i64 0, i64 0
  %85 = getelementptr inbounds %struct.stbrp_node, ptr %84, i32 0, i32 2
  store ptr %81, ptr %85, align 8, !tbaa !11
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = trunc i32 %86 to i16
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.stbrp_context, ptr %88, i32 0, i32 8
  %90 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %89, i64 0, i64 1
  %91 = getelementptr inbounds %struct.stbrp_node, ptr %90, i32 0, i32 0
  store i16 %87, ptr %91, align 8, !tbaa !24
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.stbrp_context, ptr %92, i32 0, i32 8
  %94 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %93, i64 0, i64 1
  %95 = getelementptr inbounds %struct.stbrp_node, ptr %94, i32 0, i32 1
  store i16 -1, ptr %95, align 2, !tbaa !25
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.stbrp_context, ptr %96, i32 0, i32 8
  %98 = getelementptr inbounds [2 x %struct.stbrp_node], ptr %97, i64 0, i64 1
  %99 = getelementptr inbounds %struct.stbrp_node, ptr %98, i32 0, i32 2
  store ptr null, ptr %99, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret void
}

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 = { 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 = { nounwind }
attributes #4 = { 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 = !{!"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 = !{!"_ZTS10stbrp_node", !13, i64 0, !13, i64 2, !6, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !10, i64 12}
!17 = !{!"_ZTS13stbrp_context", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !7, i64 40}
!18 = !{!17, !10, i64 16}
!19 = !{!17, !6, i64 32}
!20 = !{!17, !6, i64 24}
!21 = !{!17, !10, i64 0}
!22 = !{!17, !10, i64 4}
!23 = !{!17, !10, i64 20}
!24 = !{!12, !13, i64 0}
!25 = !{!12, !13, i64 2}


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

@.str.6 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__.stbrp_init_target = external hidden unnamed_addr constant [69 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 nounwind uwtable
declare dso_local void @stbrp_setup_allow_out_of_mem(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @stbrp_init_target(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = icmp slt i32 %1, 65536
  %7 = icmp slt i32 %2, 65536
  %8 = and i1 %6, %7
  br i1 %8, label %.preheader, label %13

.preheader:                                       ; preds = %5
  %9 = add i32 %4, -1
  %10 = icmp sgt i32 %4, 1
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %9 to i64
  %11 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %wide.trip.count, 3
  %12 = icmp ult i64 %11, 3
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

13:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.6, i32 noundef 257, ptr noundef nonnull @__PRETTY_FUNCTION__.stbrp_init_target) #2
  unreachable

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %14 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next
  %15 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv, i32 2
  store ptr %14, ptr %15, align 8, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %16 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next.1
  %17 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next, i32 2
  store ptr %16, ptr %17, align 8, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %18 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next.2
  %19 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next.1, i32 2
  store ptr %18, ptr %19, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %20 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next.3
  %21 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next.2, i32 2
  store ptr %20, ptr %21, align 8, !tbaa !5
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %22 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.next.epil
  %23 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %indvars.iv.epil, i32 2
  store ptr %22, ptr %23, align 8, !tbaa !5
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.loopexit, label %.lr.ph.epil, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa
  %24 = zext nneg i32 %9 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.preheader, %._crit_edge.loopexit
  %.0.lcssa = phi i64 [ %24, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %25 = getelementptr inbounds %struct.stbrp_node, ptr %3, i64 %.0.lcssa, i32 2
  store ptr null, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 1, ptr %26, align 4, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %27, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %3, ptr %28, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %0, i64 40
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %29, ptr %30, align 8, !tbaa !20
  store i32 %1, ptr %0, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %31, align 4, !tbaa !22
  %32 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %4, ptr %32, align 4, !tbaa !23
  tail call void @stbrp_setup_allow_out_of_mem(ptr noundef nonnull %0, i32 noundef 0)
  store i16 0, ptr %29, align 8, !tbaa !24
  %33 = getelementptr inbounds i8, ptr %0, i64 42
  store i16 0, ptr %33, align 2, !tbaa !25
  %34 = getelementptr inbounds i8, ptr %0, i64 56
  %35 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %34, ptr %35, align 8, !tbaa !5
  %36 = trunc i32 %1 to i16
  store i16 %36, ptr %34, align 8, !tbaa !24
  %37 = getelementptr inbounds i8, ptr %0, i64 58
  store i16 -1, ptr %37, align 2, !tbaa !25
  %38 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr null, ptr %38, align 8, !tbaa !5
  ret void
}

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 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 = { 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, !10, i64 8}
!6 = !{!"_ZTS10stbrp_node", !7, i64 0, !7, i64 2, !10, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = !{!16, !17, i64 12}
!16 = !{!"_ZTS13stbrp_context", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20, !10, i64 24, !10, i64 32, !8, i64 40}
!17 = !{!"int", !8, i64 0}
!18 = !{!16, !17, i64 16}
!19 = !{!16, !10, i64 32}
!20 = !{!16, !10, i64 24}
!21 = !{!16, !17, i64 0}
!22 = !{!16, !17, i64 4}
!23 = !{!16, !17, i64 20}
!24 = !{!6, !7, i64 0}
!25 = !{!6, !7, i64 2}


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