; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src/ap.ll (ZN11alglib_impl12ae_int642strExPcPNS_8ae_stateE)

; 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.alglib_impl::ae_state" = type { i64, double, double, double, ptr, %"struct.alglib_impl::ae_dyn_block", ptr, i32, ptr, i64, ptr, ptr, ptr }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11alglib_impl12ae_int642strExPcPNS_8ae_stateE(i64 noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [9 x i8], align 1
  %8 = alloca i64, align 8
  %9 = alloca [12 x i64], align 16
  %10 = alloca i8, align 1
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 9, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr %9) #4
  %11 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 0
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = icmp slt i64 %12, 0
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 255, i32 0
  %16 = trunc i32 %15 to i8
  call void @llvm.memset.p0.i64(ptr align 1 %11, i8 %16, i64 8, i1 false)
  %17 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 0
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %17, ptr align 8 %4, i64 8, i1 false)
  %18 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 8
  store i8 0, ptr %18, align 1, !tbaa !11
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_state", ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !12
  %22 = icmp eq i64 %21, 2
  br i1 %22, label %23, label %45

23:                                               ; preds = %3
  store i64 0, ptr %8, align 8, !tbaa !18
  br label %24

24:                                               ; preds = %41, %23
  %25 = load i64, ptr %8, align 8, !tbaa !18
  %26 = icmp slt i64 %25, 4
  br i1 %26, label %27, label %44

27:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %28 = load i64, ptr %8, align 8, !tbaa !18
  %29 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  store i8 %30, ptr %10, align 1, !tbaa !11
  %31 = load i64, ptr %8, align 8, !tbaa !18
  %32 = sub nsw i64 7, %31
  %33 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = load i64, ptr %8, align 8, !tbaa !18
  %36 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 %35
  store i8 %34, ptr %36, align 1, !tbaa !11
  %37 = load i8, ptr %10, align 1, !tbaa !11
  %38 = load i64, ptr %8, align 8, !tbaa !18
  %39 = sub nsw i64 7, %38
  %40 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 %39
  store i8 %37, ptr %40, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  br label %41

41:                                               ; preds = %27
  %42 = load i64, ptr %8, align 8, !tbaa !18
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %8, align 8, !tbaa !18
  br label %24, !llvm.loop !19

44:                                               ; preds = %24
  br label %45

45:                                               ; preds = %44, %3
  %46 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 0
  %47 = getelementptr inbounds i8, ptr %46, i64 0
  %48 = getelementptr inbounds [12 x i64], ptr %9, i64 0, i64 0
  %49 = getelementptr inbounds i64, ptr %48, i64 0
  call void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef %47, ptr noundef %49)
  %50 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 0
  %51 = getelementptr inbounds i8, ptr %50, i64 3
  %52 = getelementptr inbounds [12 x i64], ptr %9, i64 0, i64 0
  %53 = getelementptr inbounds i64, ptr %52, i64 4
  call void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef %51, ptr noundef %53)
  %54 = getelementptr inbounds [9 x i8], ptr %7, i64 0, i64 0
  %55 = getelementptr inbounds i8, ptr %54, i64 6
  %56 = getelementptr inbounds [12 x i64], ptr %9, i64 0, i64 0
  %57 = getelementptr inbounds i64, ptr %56, i64 8
  call void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef %55, ptr noundef %57)
  store i64 0, ptr %8, align 8, !tbaa !18
  br label %58

58:                                               ; preds = %69, %45
  %59 = load i64, ptr %8, align 8, !tbaa !18
  %60 = icmp slt i64 %59, 11
  br i1 %60, label %61, label %72

61:                                               ; preds = %58
  %62 = load i64, ptr %8, align 8, !tbaa !18
  %63 = getelementptr inbounds [12 x i64], ptr %9, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !18
  %65 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %64)
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = load i64, ptr %8, align 8, !tbaa !18
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  store i8 %65, ptr %68, align 1, !tbaa !11
  br label %69

69:                                               ; preds = %61
  %70 = load i64, ptr %8, align 8, !tbaa !18
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %8, align 8, !tbaa !18
  br label %58, !llvm.loop !21

72:                                               ; preds = %58
  %73 = load ptr, ptr %5, align 8, !tbaa !9
  %74 = getelementptr inbounds i8, ptr %73, i64 11
  store i8 0, ptr %74, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 96, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSN11alglib_impl8ae_stateE", !14, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !10, i64 32, !16, i64 40, !10, i64 72, !17, i64 80, !10, i64 88, !6, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!14 = !{!"long", !7, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!17 = !{!"_ZTSN11alglib_impl13ae_error_typeE", !7, i64 0}
!18 = !{!14, !14, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 dso_local noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11alglib_impl12ae_int642strExPcPNS_8ae_stateE(i64 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = alloca [9 x i8], align 8
  %5 = alloca [12 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %5) #2
  store i64 %0, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store i8 0, ptr %6, align 8, !tbaa !5
  %7 = load i64, ptr %2, align 8, !tbaa !8
  %8 = icmp eq i64 %7, 2
  br i1 %8, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %3
  %9 = lshr i64 %0, 32
  %10 = trunc i64 %9 to i8
  %11 = lshr i64 %0, 24
  %12 = trunc i64 %11 to i8
  %13 = lshr i64 %0, 40
  %14 = trunc i64 %13 to i8
  %15 = lshr i64 %0, 16
  %16 = trunc i64 %15 to i8
  %17 = lshr i64 %0, 48
  %18 = trunc i64 %17 to i8
  %19 = lshr i64 %0, 8
  %20 = trunc i64 %19 to i8
  %21 = lshr i64 %0, 56
  %22 = trunc nuw i64 %21 to i8
  %23 = trunc i64 %0 to i8
  %24 = getelementptr inbounds i8, ptr %4, i64 7
  store i8 %22, ptr %4, align 8, !tbaa !5
  store i8 %23, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %4, i64 1
  %26 = getelementptr inbounds i8, ptr %4, i64 6
  store i8 %18, ptr %25, align 1, !tbaa !5
  store i8 %20, ptr %26, align 2, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %4, i64 2
  %28 = getelementptr inbounds i8, ptr %4, i64 5
  store i8 %14, ptr %27, align 2, !tbaa !5
  store i8 %16, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %4, i64 3
  %30 = getelementptr inbounds i8, ptr %4, i64 4
  store i8 %10, ptr %29, align 1, !tbaa !5
  store i8 %12, ptr %30, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.preheader, %3
  call void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef nonnull %4, ptr noundef nonnull %5)
  %31 = getelementptr inbounds i8, ptr %4, i64 3
  %32 = getelementptr inbounds i8, ptr %5, i64 32
  call void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef nonnull %31, ptr noundef nonnull %32)
  %33 = getelementptr inbounds i8, ptr %4, i64 6
  %34 = getelementptr inbounds i8, ptr %5, i64 64
  call void @_ZN11alglib_impl25ae_threebytes2foursixbitsEPKhPl(ptr noundef nonnull %33, ptr noundef nonnull %34)
  %35 = load i64, ptr %5, align 16, !tbaa !16
  %36 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %35)
  store i8 %36, ptr %1, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %5, i64 8
  %38 = load i64, ptr %37, align 8, !tbaa !16
  %39 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %38)
  %40 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %39, ptr %40, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %5, i64 16
  %42 = load i64, ptr %41, align 16, !tbaa !16
  %43 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %42)
  %44 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 %43, ptr %44, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %5, i64 24
  %46 = load i64, ptr %45, align 8, !tbaa !16
  %47 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %46)
  %48 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 %47, ptr %48, align 1, !tbaa !5
  %49 = load i64, ptr %32, align 16, !tbaa !16
  %50 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %49)
  %51 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 %50, ptr %51, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %5, i64 40
  %53 = load i64, ptr %52, align 8, !tbaa !16
  %54 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %53)
  %55 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %54, ptr %55, align 1, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %5, i64 48
  %57 = load i64, ptr %56, align 16, !tbaa !16
  %58 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %57)
  %59 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %58, ptr %59, align 1, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %5, i64 56
  %61 = load i64, ptr %60, align 8, !tbaa !16
  %62 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %61)
  %63 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %62, ptr %63, align 1, !tbaa !5
  %64 = load i64, ptr %34, align 16, !tbaa !16
  %65 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %64)
  %66 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %65, ptr %66, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %5, i64 72
  %68 = load i64, ptr %67, align 8, !tbaa !16
  %69 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %68)
  %70 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 %69, ptr %70, align 1, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %5, i64 80
  %72 = load i64, ptr %71, align 16, !tbaa !16
  %73 = call noundef signext i8 @_ZN11alglib_impl15ae_sixbits2charEl(i64 noundef %72)
  %74 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 %73, ptr %74, align 1, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 0, ptr %75, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %4) #2
  ret void
}

attributes #0 = { mustprogress 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTSN11alglib_impl8ae_stateE", !10, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !12, i64 72, !14, i64 80, !12, i64 88, !15, i64 96, !12, i64 104, !12, i64 112, !12, i64 120}
!10 = !{!"long", !6, i64 0}
!11 = !{!"double", !6, i64 0}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!14 = !{!"_ZTSN11alglib_impl13ae_error_typeE", !6, i64 0}
!15 = !{!"long long", !6, i64 0}
!16 = !{!10, !10, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass