; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/Numerics/FEM/src (dsrc2c)

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

@ipstr_.ip = external hidden global i64, align 8
@ipstr_.wm1 = external hidden global double, align 8

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

; Function Attrs: nounwind uwtable
define dso_local i64 @ipstr_(ptr noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load double, ptr %6, align 8, !tbaa !9
  %8 = fsub double %7, 1.000000e+00
  store double %8, ptr @ipstr_.wm1, align 8, !tbaa !9
  store i64 6, ptr @ipstr_.ip, align 8, !tbaa !11
  br label %9

9:                                                ; preds = %24, %1
  %10 = load i64, ptr @ipstr_.ip, align 8, !tbaa !11
  %11 = icmp sle i64 %10, 940
  br i1 %11, label %12, label %27

12:                                               ; preds = %9
  %13 = load i64, ptr @ipstr_.ip, align 8, !tbaa !11
  %14 = sub nsw i64 %13, 1
  store i64 %14, ptr %4, align 8, !tbaa !11
  %15 = load i64, ptr @ipstr_.ip, align 8, !tbaa !11
  %16 = sitofp i64 %15 to float
  %17 = fpext float %16 to double
  %18 = call double @v3p_netlib_pow_di(ptr noundef @ipstr_.wm1, ptr noundef %4)
  %19 = fmul double %17, %18
  %20 = fcmp ole double %19, 5.000000e-01
  br i1 %20, label %21, label %23

21:                                               ; preds = %12
  %22 = load i64, ptr @ipstr_.ip, align 8, !tbaa !11
  store i64 %22, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %28

23:                                               ; preds = %12
  br label %24

24:                                               ; preds = %23
  %25 = load i64, ptr @ipstr_.ip, align 8, !tbaa !11
  %26 = add nsw i64 %25, 1
  store i64 %26, ptr @ipstr_.ip, align 8, !tbaa !11
  br label %9, !llvm.loop !13

27:                                               ; preds = %9
  store i64 940, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %28

28:                                               ; preds = %27, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %29 = load i64, ptr %2, align 8
  ret i64 %29
}

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

declare double @v3p_netlib_pow_di(ptr noundef, 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@ipstr_.ip = external hidden local_unnamed_addr global i64, align 8
@ipstr_.wm1 = external hidden global double, align 8

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

; Function Attrs: nounwind uwtable
define dso_local i64 @ipstr_(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = fadd double %3, -1.000000e+00
  store double %4, ptr @ipstr_.wm1, align 8, !tbaa !5
  store i64 6, ptr @ipstr_.ip, align 8, !tbaa !9
  br label %5

5:                                                ; preds = %1, %13
  %storemerge2 = phi i64 [ 6, %1 ], [ %14, %13 ]
  %6 = add nsw i64 %storemerge2, -1
  store i64 %6, ptr %2, align 8, !tbaa !9
  %7 = sitofp i64 %storemerge2 to float
  %8 = fpext float %7 to double
  %9 = call double @v3p_netlib_pow_di(ptr noundef nonnull @ipstr_.wm1, ptr noundef nonnull %2) #3
  %10 = fmul double %9, %8
  %11 = fcmp ugt double %10, 5.000000e-01
  %12 = load i64, ptr @ipstr_.ip, align 8, !tbaa !9
  br i1 %11, label %13, label %.loopexit

13:                                               ; preds = %5
  %14 = add nsw i64 %12, 1
  store i64 %14, ptr @ipstr_.ip, align 8, !tbaa !9
  %15 = icmp slt i64 %12, 940
  br i1 %15, label %5, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %13, %5
  %.0 = phi i64 [ %12, %5 ], [ 940, %13 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i64 %.0
}

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

declare double @v3p_netlib_pow_di(ptr noundef, ptr noundef) local_unnamed_addr #2

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass