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

; 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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @print_f64_array(ptr noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = udiv i64 %19, %20
  store i64 %21, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %22 = load i64, ptr %6, align 8, !tbaa !9
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = urem i64 %22, %23
  store i64 %24, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %35, %4
  %26 = load i64, ptr %11, align 8, !tbaa !9
  %27 = load i64, ptr %7, align 8, !tbaa !9
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %38

30:                                               ; preds = %25
  %31 = load i32, ptr %8, align 4, !tbaa !11
  %32 = add nsw i32 %31, 7
  %33 = load i64, ptr %11, align 8, !tbaa !9
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %32, i64 noundef %33)
  br label %35

35:                                               ; preds = %30
  %36 = load i64, ptr %11, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %11, align 8, !tbaa !9
  br label %25, !llvm.loop !13

38:                                               ; preds = %29
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = load i32, ptr %8, align 4, !tbaa !11
  %42 = add nsw i32 %41, 8
  %43 = sext i32 %42 to i64
  %44 = mul i64 %40, %43
  %45 = sub i64 %44, 1
  store i64 %45, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %53, %38
  %47 = load i64, ptr %13, align 8, !tbaa !9
  %48 = load i64, ptr %12, align 8, !tbaa !9
  %49 = icmp ult i64 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %56

51:                                               ; preds = %46
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %53

53:                                               ; preds = %51
  %54 = load i64, ptr %13, align 8, !tbaa !9
  %55 = add i64 %54, 1
  store i64 %55, ptr %13, align 8, !tbaa !9
  br label %46, !llvm.loop !15

56:                                               ; preds = %50
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %87, %56
  %59 = load i64, ptr %14, align 8, !tbaa !9
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = icmp ult i64 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 8, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %90

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %82, %63
  %65 = load i64, ptr %16, align 8, !tbaa !9
  %66 = load i64, ptr %7, align 8, !tbaa !9
  %67 = icmp ult i64 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 11, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %85

69:                                               ; preds = %64
  %70 = load i32, ptr %8, align 4, !tbaa !11
  %71 = add nsw i32 %70, 7
  %72 = load i32, ptr %8, align 4, !tbaa !11
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i64, ptr %14, align 8, !tbaa !9
  %75 = load i64, ptr %7, align 8, !tbaa !9
  %76 = mul i64 %74, %75
  %77 = load i64, ptr %16, align 8, !tbaa !9
  %78 = add i64 %76, %77
  %79 = getelementptr inbounds double, ptr %73, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !16
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %71, i32 noundef %72, double noundef %80)
  br label %82

82:                                               ; preds = %69
  %83 = load i64, ptr %16, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %16, align 8, !tbaa !9
  br label %64, !llvm.loop !18

85:                                               ; preds = %68
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %87

87:                                               ; preds = %85
  %88 = load i64, ptr %14, align 8, !tbaa !9
  %89 = add i64 %88, 1
  store i64 %89, ptr %14, align 8, !tbaa !9
  br label %58, !llvm.loop !19

90:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store i64 0, ptr %17, align 8, !tbaa !9
  br label %91

91:                                               ; preds = %109, %90
  %92 = load i64, ptr %17, align 8, !tbaa !9
  %93 = load i64, ptr %10, align 8, !tbaa !9
  %94 = icmp ult i64 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 14, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %112

96:                                               ; preds = %91
  %97 = load i32, ptr %8, align 4, !tbaa !11
  %98 = add nsw i32 %97, 7
  %99 = load i32, ptr %8, align 4, !tbaa !11
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = load i64, ptr %9, align 8, !tbaa !9
  %102 = load i64, ptr %7, align 8, !tbaa !9
  %103 = mul i64 %101, %102
  %104 = load i64, ptr %17, align 8, !tbaa !9
  %105 = add i64 %103, %104
  %106 = getelementptr inbounds double, ptr %100, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !16
  %108 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %98, i32 noundef %99, double noundef %107)
  br label %109

109:                                              ; preds = %96
  %110 = load i64, ptr %17, align 8, !tbaa !9
  %111 = add i64 %110, 1
  store i64 %111, ptr %17, align 8, !tbaa !9
  br label %91, !llvm.loop !20

112:                                              ; preds = %95
  %113 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  store i64 0, ptr %18, align 8, !tbaa !9
  br label %114

114:                                              ; preds = %121, %112
  %115 = load i64, ptr %18, align 8, !tbaa !9
  %116 = load i64, ptr %12, align 8, !tbaa !9
  %117 = icmp ult i64 %115, %116
  br i1 %117, label %119, label %118

118:                                              ; preds = %114
  store i32 17, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  br label %124

119:                                              ; preds = %114
  %120 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %121

121:                                              ; preds = %119
  %122 = load i64, ptr %18, align 8, !tbaa !9
  %123 = add i64 %122, 1
  store i64 %123, ptr %18, align 8, !tbaa !9
  br label %114, !llvm.loop !21

124:                                              ; preds = %118
  %125 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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

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

; 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 = { "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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}


; 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 [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_f64_array(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = udiv i64 %1, %2
  %6 = urem i64 %1, %2
  %7 = add nsw i32 %3, 7
  %umax = tail call i64 @llvm.umax.i64(i64 %2, i64 1)
  br label %14

8:                                                ; preds = %14
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %10 = add nsw i32 %3, 8
  %11 = sext i32 %10 to i64
  %12 = mul i64 %11, %2
  %13 = add i64 %12, -1
  %.not = icmp eq i64 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

14:                                               ; preds = %4, %14
  %.04146 = phi i64 [ 0, %4 ], [ %16, %14 ]
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %7, i64 noundef %.04146)
  %16 = add nuw i64 %.04146, 1
  %exitcond.not = icmp eq i64 %16, %umax
  br i1 %exitcond.not, label %8, label %14, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %8
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %.not57 = icmp ugt i64 %2, %1
  br i1 %.not57, label %.preheader, label %.preheader45

.lr.ph:                                           ; preds = %8, %.lr.ph
  %.04047 = phi i64 [ %19, %.lr.ph ], [ 0, %8 ]
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %19 = add nuw i64 %.04047, 1
  %exitcond60.not = icmp eq i64 %19, %13
  br i1 %exitcond60.not, label %._crit_edge, label %.lr.ph, !llvm.loop !7

.preheader45:                                     ; preds = %._crit_edge, %24
  %.03949 = phi i64 [ %26, %24 ], [ 0, %._crit_edge ]
  %20 = mul i64 %.03949, %2
  %21 = getelementptr double, ptr %0, i64 %20
  br label %28

.preheader:                                       ; preds = %24, %._crit_edge
  %.not58 = icmp eq i64 %6, 0
  br i1 %.not58, label %._crit_edge52, label %.lr.ph51

.lr.ph51:                                         ; preds = %.preheader
  %22 = mul i64 %5, %2
  %23 = getelementptr double, ptr %0, i64 %22
  br label %34

24:                                               ; preds = %28
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %26 = add nuw i64 %.03949, 1
  %27 = icmp ult i64 %26, %5
  br i1 %27, label %.preheader45, label %.preheader, !llvm.loop !8

28:                                               ; preds = %.preheader45, %28
  %.03848 = phi i64 [ 0, %.preheader45 ], [ %32, %28 ]
  %29 = getelementptr double, ptr %21, i64 %.03848
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %7, i32 noundef %3, double noundef %30)
  %32 = add nuw i64 %.03848, 1
  %exitcond61.not = icmp eq i64 %32, %umax
  br i1 %exitcond61.not, label %24, label %28, !llvm.loop !13

._crit_edge52:                                    ; preds = %34, %.preheader
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br i1 %.not, label %._crit_edge56, label %.lr.ph55

34:                                               ; preds = %.lr.ph51, %34
  %.03750 = phi i64 [ 0, %.lr.ph51 ], [ %38, %34 ]
  %35 = getelementptr double, ptr %23, i64 %.03750
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %7, i32 noundef %3, double noundef %36)
  %38 = add nuw i64 %.03750, 1
  %39 = icmp ult i64 %38, %6
  br i1 %39, label %34, label %._crit_edge52, !llvm.loop !14

._crit_edge56:                                    ; preds = %.lr.ph55, %._crit_edge52
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  ret void

.lr.ph55:                                         ; preds = %._crit_edge52, %.lr.ph55
  %.053 = phi i64 [ %42, %.lr.ph55 ], [ 0, %._crit_edge52 ]
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %42 = add nuw i64 %.053, 1
  %exitcond62.not = icmp eq i64 %42, %13
  br i1 %exitcond62.not, label %._crit_edge56, label %.lr.ph55, !llvm.loop !15
}

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

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

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" }
attributes #2 = { 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 = distinct !{!7, !6}
!8 = distinct !{!8, !6}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C/C++ TBAA"}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}
!15 = distinct !{!15, !6}


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