; LLVM IR from ahampriyanshu/algo-ds-101 :: Maths/Statistics/Confidence_Interval (Confidence_Inverval)

; 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.3 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @normalQuantile(double noundef) #0

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @confidence_interval(double noundef, double noundef, double noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca [2 x double], align 16
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store double 0x3FEFAE147AE147AE, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 10000, ptr %4, align 8, !tbaa !9
  %13 = call ptr @llvm.stacksave.p0()
  store ptr %13, ptr %5, align 8
  %14 = alloca double, i64 10000, align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  call void @srand(i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %27, %0
  %16 = load i64, ptr %8, align 8, !tbaa !9
  %17 = icmp ult i64 %16, 10000
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %30

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %20 = call i32 @rand() #6
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %21, 0x41DFFFFFFFC00000
  store double %22, ptr %9, align 8, !tbaa !5
  %23 = load double, ptr %9, align 8, !tbaa !5
  %24 = call double @normalQuantile(double noundef %23)
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = getelementptr inbounds double, ptr %14, i64 %25
  store double %24, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %27

27:                                               ; preds = %19
  %28 = load i64, ptr %8, align 8, !tbaa !9
  %29 = add i64 %28, 1
  store i64 %29, ptr %8, align 8, !tbaa !9
  br label %15, !llvm.loop !11

30:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %41, %30
  %32 = load i64, ptr %10, align 8, !tbaa !9
  %33 = icmp ult i64 %32, 10000
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %44

35:                                               ; preds = %31
  %36 = load i64, ptr %10, align 8, !tbaa !9
  %37 = getelementptr inbounds double, ptr %14, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = load double, ptr %6, align 8, !tbaa !5
  %40 = fadd double %39, %38
  store double %40, ptr %6, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %35
  %42 = load i64, ptr %10, align 8, !tbaa !9
  %43 = add i64 %42, 1
  store i64 %43, ptr %10, align 8, !tbaa !9
  br label %31, !llvm.loop !13

44:                                               ; preds = %34
  %45 = load double, ptr %6, align 8, !tbaa !5
  %46 = fdiv double %45, 1.000000e+04
  store double %46, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %64, %44
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = icmp ult i64 %48, 10000
  br i1 %49, label %51, label %50

50:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %67

51:                                               ; preds = %47
  %52 = load i64, ptr %11, align 8, !tbaa !9
  %53 = getelementptr inbounds double, ptr %14, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !5
  %55 = load double, ptr %6, align 8, !tbaa !5
  %56 = fsub double %54, %55
  %57 = load i64, ptr %11, align 8, !tbaa !9
  %58 = getelementptr inbounds double, ptr %14, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !5
  %60 = load double, ptr %6, align 8, !tbaa !5
  %61 = fsub double %59, %60
  %62 = load double, ptr %7, align 8, !tbaa !5
  %63 = call double @llvm.fmuladd.f64(double %56, double %61, double %62)
  store double %63, ptr %7, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %51
  %65 = load i64, ptr %11, align 8, !tbaa !9
  %66 = add i64 %65, 1
  store i64 %66, ptr %11, align 8, !tbaa !9
  br label %47, !llvm.loop !14

67:                                               ; preds = %50
  %68 = load double, ptr %7, align 8, !tbaa !5
  %69 = fdiv double %68, 9.999000e+03
  store double %69, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %70 = load double, ptr %7, align 8, !tbaa !5
  %71 = fdiv double %70, 1.000000e+04
  %72 = call double @sqrt(double noundef %71) #6
  store double %72, ptr %12, align 8, !tbaa !5
  %73 = load double, ptr %6, align 8, !tbaa !5
  %74 = load double, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds [2 x double], ptr %3, i64 0, i64 0
  call void @confidence_interval(double noundef %73, double noundef %74, double noundef 0x3FEFAE147AE147AE, ptr noundef %75)
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef 10000)
  %77 = load double, ptr %6, align 8, !tbaa !5
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %77)
  %79 = getelementptr inbounds [2 x double], ptr %3, i64 0, i64 0
  %80 = load double, ptr %79, align 16, !tbaa !5
  %81 = getelementptr inbounds [2 x double], ptr %3, i64 0, i64 1
  %82 = load double, ptr %81, align 8, !tbaa !5
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, double noundef 9.900000e+01, double noundef %80, double noundef %82)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %84 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %84)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %85 = load i32, ptr %1, align 4
  ret i32 %85
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

; Function Attrs: nounwind
declare void @srand(i32 noundef) #2

; Function Attrs: nounwind
declare i32 @rand() #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

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 "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { "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 #6 = { 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 = !{!"double", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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.3 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @normalQuantile(double noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @confidence_interval(double noundef, double noundef, double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [2 x double], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #7
  %2 = tail call ptr @llvm.stacksave.p0()
  %3 = alloca [10000 x double], align 16
  tail call void @srand(i32 noundef 0) #7
  br label %4

4:                                                ; preds = %0, %4
  %.02426 = phi i64 [ 0, %0 ], [ %10, %4 ]
  %5 = tail call i32 @rand() #7
  %6 = sitofp i32 %5 to double
  %7 = fdiv double %6, 0x41DFFFFFFFC00000
  %8 = tail call double @normalQuantile(double noundef %7)
  %9 = getelementptr inbounds double, ptr %3, i64 %.02426
  store double %8, ptr %9, align 8, !tbaa !5
  %10 = add nuw nsw i64 %.02426, 1
  %exitcond.not = icmp eq i64 %10, 10000
  br i1 %exitcond.not, label %.preheader, label %4, !llvm.loop !9

11:                                               ; preds = %.preheader
  %12 = fdiv double %43, 1.000000e+04
  %invariant.gep = getelementptr inbounds i8, ptr %3, i64 8
  %invariant.gep38 = getelementptr inbounds i8, ptr %3, i64 16
  %invariant.gep40 = getelementptr inbounds i8, ptr %3, i64 24
  %invariant.gep42 = getelementptr inbounds i8, ptr %3, i64 32
  br label %55

.preheader:                                       ; preds = %4, %.preheader
  %.02228 = phi i64 [ %44, %.preheader ], [ 0, %4 ]
  %.02327 = phi double [ %43, %.preheader ], [ 0.000000e+00, %4 ]
  %13 = getelementptr inbounds double, ptr %3, i64 %.02228
  %14 = load double, ptr %13, align 16, !tbaa !5
  %15 = fadd double %.02327, %14
  %16 = or disjoint i64 %.02228, 1
  %17 = getelementptr inbounds double, ptr %3, i64 %16
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fadd double %15, %18
  %20 = or disjoint i64 %.02228, 2
  %21 = getelementptr inbounds double, ptr %3, i64 %20
  %22 = load double, ptr %21, align 16, !tbaa !5
  %23 = fadd double %19, %22
  %24 = or disjoint i64 %.02228, 3
  %25 = getelementptr inbounds double, ptr %3, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fadd double %23, %26
  %28 = or disjoint i64 %.02228, 4
  %29 = getelementptr inbounds double, ptr %3, i64 %28
  %30 = load double, ptr %29, align 16, !tbaa !5
  %31 = fadd double %27, %30
  %32 = or disjoint i64 %.02228, 5
  %33 = getelementptr inbounds double, ptr %3, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fadd double %31, %34
  %36 = or disjoint i64 %.02228, 6
  %37 = getelementptr inbounds double, ptr %3, i64 %36
  %38 = load double, ptr %37, align 16, !tbaa !5
  %39 = fadd double %35, %38
  %40 = or disjoint i64 %.02228, 7
  %41 = getelementptr inbounds double, ptr %3, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !5
  %43 = fadd double %39, %42
  %44 = add nuw nsw i64 %.02228, 8
  %exitcond32.not.7 = icmp eq i64 %44, 10000
  br i1 %exitcond32.not.7, label %11, label %.preheader, !llvm.loop !11

45:                                               ; preds = %55
  %46 = fdiv double %71, 9.999000e+03
  %47 = fdiv double %46, 1.000000e+04
  %48 = tail call double @sqrt(double noundef %47) #7
  call void @confidence_interval(double noundef %12, double noundef %48, double noundef 0x3FEFAE147AE147AE, ptr noundef nonnull %1)
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef 10000)
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %12)
  %51 = load double, ptr %1, align 16, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %1, i64 8
  %53 = load double, ptr %52, align 8, !tbaa !5
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef 9.900000e+01, double noundef %51, double noundef %53)
  call void @llvm.stackrestore.p0(ptr %2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #7
  ret i32 0

55:                                               ; preds = %55, %11
  %.030 = phi i64 [ 0, %11 ], [ %72, %55 ]
  %.02529 = phi double [ 0.000000e+00, %11 ], [ %71, %55 ]
  %56 = getelementptr inbounds double, ptr %3, i64 %.030
  %57 = load double, ptr %56, align 8, !tbaa !5
  %58 = fsub double %57, %12
  %59 = tail call double @llvm.fmuladd.f64(double %58, double %58, double %.02529)
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %.030
  %60 = load double, ptr %gep, align 8, !tbaa !5
  %61 = fsub double %60, %12
  %62 = tail call double @llvm.fmuladd.f64(double %61, double %61, double %59)
  %gep39 = getelementptr inbounds double, ptr %invariant.gep38, i64 %.030
  %63 = load double, ptr %gep39, align 8, !tbaa !5
  %64 = fsub double %63, %12
  %65 = tail call double @llvm.fmuladd.f64(double %64, double %64, double %62)
  %gep41 = getelementptr inbounds double, ptr %invariant.gep40, i64 %.030
  %66 = load double, ptr %gep41, align 8, !tbaa !5
  %67 = fsub double %66, %12
  %68 = tail call double @llvm.fmuladd.f64(double %67, double %67, double %65)
  %gep43 = getelementptr inbounds double, ptr %invariant.gep42, i64 %.030
  %69 = load double, ptr %gep43, align 8, !tbaa !5
  %70 = fsub double %69, %12
  %71 = tail call double @llvm.fmuladd.f64(double %70, double %70, double %68)
  %72 = add nuw nsw i64 %.030, 5
  %exitcond33.not.4 = icmp eq i64 %72, 10000
  br i1 %exitcond33.not.4, label %45, label %55, !llvm.loop !12
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #5

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #6 = { 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 #7 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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