; LLVM IR from microsoft/LightAIMD :: src (basis_func)

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

@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 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: nounwind uwtable
define dso_local void @print_basis_func(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.basis_func, ptr %4, i32 0, i32 8
  %6 = load double, ptr %5, align 8, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.basis_func, ptr %7, i32 0, i32 9
  %9 = load double, ptr %8, align 8, !tbaa !13
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.basis_func, ptr %10, i32 0, i32 10
  %12 = load double, ptr %11, align 8, !tbaa !14
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %6, double noundef %9, double noundef %12)
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.basis_func, ptr %14, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !15
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.basis_func, ptr %17, i32 0, i32 1
  %19 = load i64, ptr %18, align 8, !tbaa !16
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.basis_func, ptr %20, i32 0, i32 2
  %22 = load i64, ptr %21, align 8, !tbaa !17
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.basis_func, ptr %23, i32 0, i32 3
  %25 = load i64, ptr %24, align 8, !tbaa !18
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %16, i64 noundef %19, i64 noundef %22, i64 noundef %25)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !19
  br label %27

27:                                               ; preds = %55, %1
  %28 = load i64, ptr %3, align 8, !tbaa !19
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.basis_func, ptr %29, i32 0, i32 3
  %31 = load i64, ptr %30, align 8, !tbaa !18
  %32 = icmp ult i64 %28, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %58

34:                                               ; preds = %27
  %35 = load i64, ptr %3, align 8, !tbaa !19
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.basis_func, ptr %36, i32 0, i32 5
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = load i64, ptr %3, align 8, !tbaa !19
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !21
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.basis_func, ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !22
  %45 = load i64, ptr %3, align 8, !tbaa !19
  %46 = getelementptr inbounds double, ptr %44, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !21
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.basis_func, ptr %48, i32 0, i32 6
  %50 = load ptr, ptr %49, align 8, !tbaa !23
  %51 = load i64, ptr %3, align 8, !tbaa !19
  %52 = getelementptr inbounds double, ptr %50, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !21
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %35, double noundef %41, double noundef %47, double noundef %53)
  br label %55

55:                                               ; preds = %34
  %56 = load i64, ptr %3, align 8, !tbaa !19
  %57 = add i64 %56, 1
  store i64 %57, ptr %3, align 8, !tbaa !19
  br label %27, !llvm.loop !24

58:                                               ; preds = %33
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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/C++ TBAA"}
!9 = !{!10, !12, i64 64}
!10 = !{!"basis_func", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !12, i64 72}
!14 = !{!10, !12, i64 80}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !11, i64 8}
!17 = !{!10, !11, i64 16}
!18 = !{!10, !11, i64 24}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !6, i64 40}
!21 = !{!12, !12, i64 0}
!22 = !{!10, !6, i64 32}
!23 = !{!10, !6, i64 48}
!24 = distinct !{!24, !25}
!25 = !{!"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 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_basis_func(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = load double, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = load double, ptr %6, align 8, !tbaa !13
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %3, double noundef %5, double noundef %7)
  %9 = load i64, ptr %0, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !17
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %9, i64 noundef %11, i64 noundef %13, i64 noundef %15)
  %17 = load i64, ptr %14, align 8, !tbaa !17
  %.not = icmp eq i64 %17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  br label %21

._crit_edge:                                      ; preds = %21, %1
  ret void

21:                                               ; preds = %.lr.ph, %21
  %.016 = phi i64 [ 0, %.lr.ph ], [ %32, %21 ]
  %22 = load ptr, ptr %18, align 8, !tbaa !18
  %23 = getelementptr inbounds double, ptr %22, i64 %.016
  %24 = load double, ptr %23, align 8, !tbaa !19
  %25 = load ptr, ptr %19, align 8, !tbaa !20
  %26 = getelementptr inbounds double, ptr %25, i64 %.016
  %27 = load double, ptr %26, align 8, !tbaa !19
  %28 = load ptr, ptr %20, align 8, !tbaa !21
  %29 = getelementptr inbounds double, ptr %28, i64 %.016
  %30 = load double, ptr %29, align 8, !tbaa !19
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.016, double noundef %24, double noundef %27, double noundef %30)
  %32 = add nuw i64 %.016, 1
  %33 = load i64, ptr %14, align 8, !tbaa !17
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %21, label %._crit_edge, !llvm.loop !22
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

!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, !11, i64 64}
!6 = !{!"basis_func", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !11, i64 72}
!13 = !{!6, !11, i64 80}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 16}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !10, i64 40}
!19 = !{!11, !11, i64 0}
!20 = !{!6, !10, i64 32}
!21 = !{!6, !10, i64 48}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass