; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/library.ll (Z5gaussifPi)

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z9normalizePfi(ptr noundef, i32 noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z5gaussifPi(i32 noundef %0, float noundef %1, ptr noundef %2) #6 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store float 4.000000e+00, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 1, ptr %14, align 4, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %3
  %19 = load ptr, ptr %7, align 8, !tbaa !11
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %12, align 4, !tbaa !5
  br label %35

21:                                               ; preds = %3
  %22 = load float, ptr %6, align 4, !tbaa !9
  %23 = fpext float %22 to double
  %24 = load float, ptr %9, align 4, !tbaa !9
  %25 = fpext float %24 to double
  %26 = fmul double %25, 2.000000e+00
  %27 = call double @log(double noundef 1.000000e+01) #8
  %28 = fmul double %26, %27
  %29 = call double @sqrt(double noundef %28) #8
  %30 = fmul double %23, %29
  %31 = call double @llvm.ceil.f64(double %30)
  %32 = fptosi double %31 to i32
  %33 = mul nsw i32 2, %32
  %34 = add nsw i32 1, %33
  store i32 %34, ptr %12, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %21, %18
  %36 = load i32, ptr %12, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %37, i64 4)
  %39 = extractvalue { i64, i1 } %38, 1
  %40 = extractvalue { i64, i1 } %38, 0
  %41 = select i1 %39, i64 -1, i64 %40
  %42 = call noalias noundef nonnull ptr @_Znam(i64 noundef %41) #9
  store ptr %42, ptr %8, align 8, !tbaa !11
  %43 = load i32, ptr %12, align 4, !tbaa !5
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %48

45:                                               ; preds = %35
  %46 = load ptr, ptr %8, align 8, !tbaa !11
  %47 = getelementptr inbounds float, ptr %46, i64 0
  store float 1.000000e+00, ptr %47, align 4, !tbaa !9
  br label %89

48:                                               ; preds = %35
  %49 = load i32, ptr %12, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = sitofp i32 %50 to float
  %52 = fpext float %51 to double
  %53 = fmul double 5.000000e-01, %52
  %54 = fptrunc double %53 to float
  store float %54, ptr %10, align 4, !tbaa !9
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  %57 = sdiv i32 %56, 2
  store i32 %57, ptr %13, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %62, %48
  %59 = load i32, ptr %13, align 4, !tbaa !5
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr %13, align 4, !tbaa !5
  %61 = icmp ne i32 %59, 0
  br i1 %61, label %62, label %88

62:                                               ; preds = %58
  %63 = load i32, ptr %13, align 4, !tbaa !5
  %64 = sitofp i32 %63 to double
  %65 = load float, ptr %10, align 4, !tbaa !9
  %66 = fpext float %65 to double
  %67 = fsub double %64, %66
  %68 = load float, ptr %6, align 4, !tbaa !9
  %69 = fpext float %68 to double
  %70 = fdiv double %67, %69
  store double %70, ptr %11, align 8, !tbaa !13
  %71 = load double, ptr %11, align 8, !tbaa !13
  %72 = fmul double -5.000000e-01, %71
  %73 = load double, ptr %11, align 8, !tbaa !13
  %74 = fmul double %72, %73
  %75 = call double @exp(double noundef %74) #8
  %76 = fptrunc double %75 to float
  %77 = load ptr, ptr %8, align 8, !tbaa !11
  %78 = load i32, ptr %12, align 4, !tbaa !5
  %79 = sub nsw i32 %78, 1
  %80 = load i32, ptr %13, align 4, !tbaa !5
  %81 = sub nsw i32 %79, %80
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds float, ptr %77, i64 %82
  store float %76, ptr %83, align 4, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !11
  %85 = load i32, ptr %13, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds float, ptr %84, i64 %86
  store float %76, ptr %87, align 4, !tbaa !9
  br label %58, !llvm.loop !15

88:                                               ; preds = %58
  br label %89

89:                                               ; preds = %88, %45
  %90 = load i32, ptr %14, align 4, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !11
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = call noundef i32 @_Z9normalizePfi(ptr noundef %91, i32 noundef %92)
  %94 = icmp eq i32 %90, %93
  br i1 %94, label %95, label %99

95:                                               ; preds = %89
  %96 = load i32, ptr %12, align 4, !tbaa !5
  %97 = load ptr, ptr %7, align 8, !tbaa !11
  store i32 %96, ptr %97, align 4, !tbaa !5
  %98 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %98, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %105

99:                                               ; preds = %89
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %101 = load ptr, ptr %8, align 8, !tbaa !11
  %102 = icmp eq ptr %101, null
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  call void @_ZdaPv(ptr noundef %101) #10
  br label %104

104:                                              ; preds = %103, %99
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %105

105:                                              ; preds = %104, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  %106 = load ptr, ptr %4, align 8
  ret ptr %106
}

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

; Function Attrs: nounwind
declare double @log(double noundef) #7

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

; Function Attrs: nounwind
declare double @exp(double noundef) #7

attributes #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nobuiltin allocsize(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 = { nobuiltin 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 #5 = { 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 #6 = { mustprogress 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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.2 = external hidden unnamed_addr constant [55 x i8], align 1

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z9normalizePfi(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z5gaussifPi(i32 noundef %0, float noundef %1, ptr nocapture noundef %2) local_unnamed_addr #4 {
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %6, label %4

4:                                                ; preds = %3
  %5 = load i32, ptr %2, align 4, !tbaa !5
  br label %13

6:                                                ; preds = %3
  %7 = fpext float %1 to double
  %8 = fmul double %7, 0x40112AF03C69EB28
  %9 = tail call double @llvm.ceil.f64(double %8)
  %10 = fptosi double %9 to i32
  %11 = shl nsw i32 %10, 1
  %12 = or disjoint i32 %11, 1
  br label %13

13:                                               ; preds = %6, %4
  %.028 = phi i32 [ %5, %4 ], [ %12, %6 ]
  %14 = sext i32 %.028 to i64
  %15 = icmp slt i32 %.028, 0
  %16 = shl nsw i64 %14, 2
  %17 = select i1 %15, i64 -1, i64 %16
  %18 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %17) #7
  %19 = icmp eq i32 %.028, 1
  br i1 %19, label %20, label %21

20:                                               ; preds = %13
  store float 1.000000e+00, ptr %18, align 4, !tbaa !9
  br label %.loopexit

21:                                               ; preds = %13
  %.off = add i32 %.028, 2
  %.not2930 = icmp ult i32 %.off, 3
  br i1 %.not2930, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %21
  %22 = add nuw nsw i32 %.028, 1
  %23 = sdiv i32 %22, 2
  %24 = add nsw i32 %.028, -1
  %25 = sitofp i32 %24 to float
  %26 = fmul float %25, 5.000000e-01
  %27 = fpext float %26 to double
  %28 = fpext float %1 to double
  %29 = sext i32 %23 to i64
  br label %30

30:                                               ; preds = %.lr.ph, %30
  %indvars.iv = phi i64 [ %29, %.lr.ph ], [ %indvars.iv.next, %30 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %31 = trunc nsw i64 %indvars.iv.next to i32
  %32 = sitofp i32 %31 to double
  %33 = fsub double %32, %27
  %34 = fdiv double %33, %28
  %35 = fmul double %34, -5.000000e-01
  %36 = fmul double %34, %35
  %37 = tail call double @exp(double noundef %36) #8
  %38 = fptrunc double %37 to float
  %39 = trunc nsw i64 %indvars.iv to i32
  %40 = sub i32 %.028, %39
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %18, i64 %41
  store float %38, ptr %42, align 4, !tbaa !9
  %43 = getelementptr inbounds float, ptr %18, i64 %indvars.iv.next
  store float %38, ptr %43, align 4, !tbaa !9
  %44 = icmp eq i64 %indvars.iv.next, 0
  br i1 %44, label %.loopexit, label %30, !llvm.loop !11

.loopexit:                                        ; preds = %30, %21, %20
  %45 = tail call noundef i32 @_Z9normalizePfi(ptr noundef nonnull %18, i32 noundef %.028)
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %47, label %48

47:                                               ; preds = %.loopexit
  store i32 %.028, ptr %2, align 4, !tbaa !5
  br label %50

48:                                               ; preds = %.loopexit
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @_ZdaPv(ptr noundef nonnull %18) #9
  br label %50

50:                                               ; preds = %48, %47
  %.0 = phi ptr [ %18, %47 ], [ null, %48 ]
  ret ptr %.0
}

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

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

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 = { nobuiltin 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 = { 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 = { mustprogress 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 #5 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { builtin allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { builtin 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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