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

%struct.anon = type { i64, i64, i64, i64, i64, i64 }
%struct.anon.0 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }

@itcom1_ = external hidden global %struct.anon, align 8
@itcom3_ = external hidden global %struct.anon.0, align 8
@tstchg_.ip = external hidden global i64, align 8

; Function Attrs: nounwind uwtable
define dso_local i64 @tstchg_(ptr noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load i64, ptr @itcom1_, align 8, !tbaa !9
  %5 = load i64, ptr getelementptr inbounds (%struct.anon, ptr @itcom1_, i32 0, i32 1), align 8, !tbaa !12
  %6 = sub nsw i64 %4, %5
  store i64 %6, ptr @tstchg_.ip, align 8, !tbaa !13
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load i64, ptr %7, align 8, !tbaa !13
  %9 = icmp eq i64 %8, 2
  br i1 %9, label %10, label %13

10:                                               ; preds = %1
  %11 = load i64, ptr @tstchg_.ip, align 8, !tbaa !13
  %12 = shl i64 %11, 1
  store i64 %12, ptr @tstchg_.ip, align 8, !tbaa !13
  br label %13

13:                                               ; preds = %10, %1
  %14 = load i64, ptr @itcom1_, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  br label %60

17:                                               ; preds = %13
  %18 = load i64, ptr @tstchg_.ip, align 8, !tbaa !13
  %19 = icmp slt i64 %18, 3
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %61

21:                                               ; preds = %17
  %22 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 3), align 8, !tbaa !14
  %23 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 4), align 8, !tbaa !17
  %24 = fdiv double %22, %23
  %25 = fcmp oge double %24, 0.000000e+00
  br i1 %25, label %26, label %30

26:                                               ; preds = %21
  %27 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 3), align 8, !tbaa !14
  %28 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 4), align 8, !tbaa !17
  %29 = fdiv double %27, %28
  br label %35

30:                                               ; preds = %21
  %31 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 3), align 8, !tbaa !14
  %32 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 4), align 8, !tbaa !17
  %33 = fdiv double %31, %32
  %34 = fneg double %33
  br label %35

35:                                               ; preds = %30, %26
  %36 = phi double [ %29, %26 ], [ %34, %30 ]
  %37 = call double @sqrt(double noundef %36) #3
  store double %37, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 8), align 8, !tbaa !18
  %38 = call double @v3p_netlib_pow_di(ptr noundef getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 11), ptr noundef @tstchg_.ip)
  %39 = fcmp oge double %38, 0.000000e+00
  br i1 %39, label %40, label %42

40:                                               ; preds = %35
  %41 = call double @v3p_netlib_pow_di(ptr noundef getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 11), ptr noundef @tstchg_.ip)
  br label %45

42:                                               ; preds = %35
  %43 = call double @v3p_netlib_pow_di(ptr noundef getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 11), ptr noundef @tstchg_.ip)
  %44 = fneg double %43
  br label %45

45:                                               ; preds = %42, %40
  %46 = phi double [ %41, %40 ], [ %44, %42 ]
  %47 = call double @sqrt(double noundef %46) #3
  %48 = fmul double %47, 2.000000e+00
  %49 = call double @v3p_netlib_pow_di(ptr noundef getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 11), ptr noundef @tstchg_.ip)
  %50 = fadd double %49, 1.000000e+00
  %51 = fdiv double %48, %50
  store double %51, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 9), align 8, !tbaa !19
  %52 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 8), align 8, !tbaa !18
  %53 = fcmp oge double %52, 1.000000e+00
  br i1 %53, label %58, label %54

54:                                               ; preds = %45
  %55 = load double, ptr getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 8), align 8, !tbaa !18
  %56 = call double @v3p_netlib_pow_dd(ptr noundef getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 9), ptr noundef getelementptr inbounds (%struct.anon.0, ptr @itcom3_, i32 0, i32 5))
  %57 = fcmp olt double %55, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %54, %45
  br label %61

59:                                               ; preds = %54
  br label %60

60:                                               ; preds = %59, %16
  store i64 1, ptr %2, align 8
  br label %62

61:                                               ; preds = %58, %20
  store i64 0, ptr %2, align 8
  br label %62

62:                                               ; preds = %61, %60
  %63 = load i64, ptr %2, align 8
  ret i64 %63
}

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

declare double @v3p_netlib_pow_dd(ptr noundef, ptr noundef) #2

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

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 = { 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 = { "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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !16, i64 24}
!15 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !16, i64 104, !16, i64 112, !16, i64 120, !16, i64 128, !16, i64 136, !16, i64 144, !16, i64 152}
!16 = !{!"double", !7, i64 0}
!17 = !{!15, !16, i64 32}
!18 = !{!15, !16, i64 64}
!19 = !{!15, !16, i64 72}


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

%struct.anon = type { i64, i64, i64, i64, i64, i64 }
%struct.anon.0 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }

@itcom1_ = external hidden local_unnamed_addr global %struct.anon, align 8
@itcom3_ = external hidden global %struct.anon.0, align 8
@tstchg_.ip = external hidden global i64, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 2) i64 @tstchg_(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i64, ptr @itcom1_, align 8, !tbaa !5
  %3 = load i64, ptr getelementptr inbounds (i8, ptr @itcom1_, i64 8), align 8, !tbaa !10
  %4 = sub nsw i64 %2, %3
  store i64 %4, ptr @tstchg_.ip, align 8, !tbaa !11
  %5 = load i64, ptr %0, align 8, !tbaa !11
  %6 = icmp eq i64 %5, 2
  br i1 %6, label %7, label %9

7:                                                ; preds = %1
  %8 = shl i64 %4, 1
  store i64 %8, ptr @tstchg_.ip, align 8, !tbaa !11
  br label %9

9:                                                ; preds = %7, %1
  %10 = phi i64 [ %8, %7 ], [ %4, %1 ]
  %11 = icmp eq i64 %2, 0
  br i1 %11, label %38, label %12

12:                                               ; preds = %9
  %13 = icmp slt i64 %10, 3
  br i1 %13, label %37, label %14

14:                                               ; preds = %12
  %15 = load double, ptr getelementptr inbounds (i8, ptr @itcom3_, i64 24), align 8, !tbaa !12
  %16 = load double, ptr getelementptr inbounds (i8, ptr @itcom3_, i64 32), align 8, !tbaa !15
  %17 = fdiv double %15, %16
  %18 = fcmp ult double %17, 0.000000e+00
  %19 = fneg double %17
  %20 = select i1 %18, double %19, double %17
  %21 = tail call double @sqrt(double noundef %20) #3
  store double %21, ptr getelementptr inbounds (i8, ptr @itcom3_, i64 64), align 8, !tbaa !16
  %22 = tail call double @v3p_netlib_pow_di(ptr noundef nonnull getelementptr inbounds (i8, ptr @itcom3_, i64 88), ptr noundef nonnull @tstchg_.ip) #3
  %23 = fcmp ult double %22, 0.000000e+00
  %24 = tail call double @v3p_netlib_pow_di(ptr noundef nonnull getelementptr inbounds (i8, ptr @itcom3_, i64 88), ptr noundef nonnull @tstchg_.ip) #3
  %25 = fneg double %24
  %26 = select i1 %23, double %25, double %24
  %27 = tail call double @sqrt(double noundef %26) #3
  %28 = fmul double %27, 2.000000e+00
  %29 = tail call double @v3p_netlib_pow_di(ptr noundef nonnull getelementptr inbounds (i8, ptr @itcom3_, i64 88), ptr noundef nonnull @tstchg_.ip) #3
  %30 = fadd double %29, 1.000000e+00
  %31 = fdiv double %28, %30
  store double %31, ptr getelementptr inbounds (i8, ptr @itcom3_, i64 72), align 8, !tbaa !17
  %32 = load double, ptr getelementptr inbounds (i8, ptr @itcom3_, i64 64), align 8, !tbaa !16
  %33 = fcmp ult double %32, 1.000000e+00
  br i1 %33, label %34, label %37

34:                                               ; preds = %14
  %35 = tail call double @v3p_netlib_pow_dd(ptr noundef nonnull getelementptr inbounds (i8, ptr @itcom3_, i64 72), ptr noundef nonnull getelementptr inbounds (i8, ptr @itcom3_, i64 40)) #3
  %36 = fcmp olt double %32, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %14, %34, %12
  br label %38

38:                                               ; preds = %9, %34, %37
  %.0 = phi i64 [ 0, %37 ], [ 1, %34 ], [ 1, %9 ]
  ret i64 %.0
}

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

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

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

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 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 #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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 24}
!13 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !14, i64 152}
!14 = !{!"double", !8, i64 0}
!15 = !{!13, !14, i64 32}
!16 = !{!13, !14, i64 64}
!17 = !{!13, !14, i64 72}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass