; LLVM IR from theck01/offbrand_lib :: src/classes (obint)

; 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.obint_struct = type { ptr, i8, ptr, i64 }

; Function Attrs: nounwind uwtable
define dso_local ptr @obint_new(i64 noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  store i64 %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 1, ptr %4, align 8, !tbaa !5
  %7 = load i64, ptr %2, align 8, !tbaa !5
  %8 = sdiv i64 %7, 10
  store i64 %8, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %12, %1
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = icmp ne i64 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = sdiv i64 %13, 10
  store i64 %14, ptr %5, align 8, !tbaa !5
  %15 = load i64, ptr %4, align 8, !tbaa !5
  %16 = add i64 %15, 1
  store i64 %16, ptr %4, align 8, !tbaa !5
  br label %9, !llvm.loop !9

17:                                               ; preds = %9
  %18 = load i64, ptr %4, align 8, !tbaa !5
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = load i64, ptr %4, align 8, !tbaa !5
  br label %23

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22, %20
  %24 = phi i64 [ %21, %20 ], [ 1, %22 ]
  store i64 %24, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = call ptr @obint_create_default(i64 noundef %25)
  store ptr %26, ptr %6, align 8, !tbaa !11
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %23
  %30 = load ptr, ptr %6, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.obint_struct, ptr %30, i32 0, i32 1
  store i8 -1, ptr %31, align 8, !tbaa !13
  %32 = load i64, ptr %2, align 8, !tbaa !5
  %33 = mul nsw i64 %32, -1
  store i64 %33, ptr %2, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %29, %23
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %50, %34
  %36 = load i64, ptr %3, align 8, !tbaa !5
  %37 = load i64, ptr %4, align 8, !tbaa !5
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %39, label %53

39:                                               ; preds = %35
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = srem i64 %40, 10
  %42 = trunc i64 %41 to i8
  %43 = load ptr, ptr %6, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.obint_struct, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = load i64, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  store i8 %42, ptr %47, align 1, !tbaa !16
  %48 = load i64, ptr %2, align 8, !tbaa !5
  %49 = sdiv i64 %48, 10
  store i64 %49, ptr %2, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %39
  %51 = load i64, ptr %3, align 8, !tbaa !5
  %52 = add i64 %51, 1
  store i64 %52, ptr %3, align 8, !tbaa !5
  br label %35, !llvm.loop !17

53:                                               ; preds = %35
  %54 = load ptr, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret ptr %54
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @obint_create_default(i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !7, i64 8}
!14 = !{!"obint_struct", !12, i64 0, !7, i64 8, !12, i64 16, !6, i64 24}
!15 = !{!14, !12, i64 16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !10}


; 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: nounwind uwtable
define dso_local ptr @obint_new(i64 noundef %0) local_unnamed_addr #0 {
  %.017.in.off23 = add i64 %0, 9
  %.not24 = icmp ult i64 %.017.in.off23, 19
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.017.in26 = phi i64 [ %.017, %.lr.ph ], [ %0, %1 ]
  %.01825 = phi i64 [ %2, %.lr.ph ], [ 1, %1 ]
  %.017 = sdiv i64 %.017.in26, 10
  %2 = add i64 %.01825, 1
  %.017.in.off = add nsw i64 %.017, 9
  %.not = icmp ult i64 %.017.in.off, 19
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.018.lcssa = phi i64 [ 1, %1 ], [ %2, %.lr.ph ]
  %3 = tail call i64 @llvm.umax.i64(i64 %.018.lcssa, i64 1)
  %4 = tail call ptr @obint_create_default(i64 noundef %3)
  %5 = icmp slt i64 %0, 0
  br i1 %5, label %6, label %9

6:                                                ; preds = %._crit_edge
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i8 -1, ptr %7, align 8, !tbaa !7
  %8 = sub nsw i64 0, %0
  br label %9

9:                                                ; preds = %6, %._crit_edge
  %.0 = phi i64 [ %8, %6 ], [ %0, %._crit_edge ]
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  %xtraiter = and i64 %3, 1
  %11 = icmp ult i64 %.018.lcssa, 2
  br i1 %11, label %.unr-lcssa, label %.new

.new:                                             ; preds = %9
  %unroll_iter = and i64 %3, -2
  br label %12

12:                                               ; preds = %12, %.new
  %.128 = phi i64 [ %.0, %.new ], [ %23, %12 ]
  %.01927 = phi i64 [ 0, %.new ], [ %24, %12 ]
  %niter = phi i64 [ 0, %.new ], [ %niter.next.1, %12 ]
  %13 = urem i64 %.128, 10
  %14 = trunc nuw nsw i64 %13 to i8
  %15 = load ptr, ptr %10, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %15, i64 %.01927
  store i8 %14, ptr %16, align 1, !tbaa !14
  %17 = udiv i64 %.128, 10
  %18 = or disjoint i64 %.01927, 1
  %19 = urem i64 %17, 10
  %20 = trunc nuw nsw i64 %19 to i8
  %21 = load ptr, ptr %10, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %21, i64 %18
  store i8 %20, ptr %22, align 1, !tbaa !14
  %23 = udiv i64 %.128, 100
  %24 = add nuw i64 %.01927, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.unr-lcssa, label %12, !llvm.loop !15

.unr-lcssa:                                       ; preds = %12, %9
  %.128.unr = phi i64 [ %.0, %9 ], [ %23, %12 ]
  %.01927.unr = phi i64 [ 0, %9 ], [ %24, %12 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %29, label %.epilog-lcssa

.epilog-lcssa:                                    ; preds = %.unr-lcssa
  %25 = urem i64 %.128.unr, 10
  %26 = trunc nuw nsw i64 %25 to i8
  %27 = load ptr, ptr %10, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %27, i64 %.01927.unr
  store i8 %26, ptr %28, align 1, !tbaa !14
  br label %29

29:                                               ; preds = %.unr-lcssa, %.epilog-lcssa
  ret ptr %4
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @obint_create_default(i64 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !10, i64 8}
!8 = !{!"obint_struct", !9, i64 0, !10, i64 8, !9, i64 16, !12, i64 24}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!8, !9, i64 16}
!14 = !{!10, !10, i64 0}
!15 = distinct !{!15, !6}


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