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

@itcom1_ = external hidden global %struct.anon, align 8
@iterm_.i = external hidden global i64, align 8

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

15:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  br label %43

16:                                               ; preds = %5
  %17 = load i64, ptr getelementptr inbounds (%struct.anon, ptr @itcom1_, i32 0, i32 4), align 8, !tbaa !9
  %18 = icmp slt i64 %17, 4
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  store i32 0, ptr %6, align 4
  br label %43

20:                                               ; preds = %16
  store i64 0, ptr @iterm_.i, align 8, !tbaa !12
  br label %21

21:                                               ; preds = %39, %20
  %22 = load i64, ptr @iterm_.i, align 8, !tbaa !12
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i64, ptr %23, align 8, !tbaa !12
  %25 = icmp slt i64 %22, %24
  br i1 %25, label %26, label %42

26:                                               ; preds = %21
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i64, ptr @iterm_.i, align 8, !tbaa !12
  %29 = getelementptr inbounds double, ptr %27, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !13
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load i64, ptr @iterm_.i, align 8, !tbaa !12
  %33 = getelementptr inbounds double, ptr %31, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = fdiv double %30, %34
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = load i64, ptr @iterm_.i, align 8, !tbaa !12
  %38 = getelementptr inbounds double, ptr %36, i64 %37
  store double %35, ptr %38, align 8, !tbaa !13
  br label %39

39:                                               ; preds = %26
  %40 = load i64, ptr @iterm_.i, align 8, !tbaa !12
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr @iterm_.i, align 8, !tbaa !12
  br label %21, !llvm.loop !15

42:                                               ; preds = %21
  store i32 0, ptr %6, align 4
  br label %43

43:                                               ; preds = %42, %19, %15
  %44 = load i32, ptr %6, align 4
  ret i32 %44
}

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

!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 32}
!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 = !{!11, !11, 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"

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

@itcom1_ = external hidden local_unnamed_addr global %struct.anon, align 8
@iterm_.i = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @iterm_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef readnone %4) local_unnamed_addr #0 {
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @itcom1_, i64 32), align 8, !tbaa !5
  %7 = icmp slt i64 %6, 4
  br i1 %7, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %5
  store i64 0, ptr @iterm_.i, align 8, !tbaa !10
  %8 = load i64, ptr %0, align 8, !tbaa !10
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %storemerge6 = phi i64 [ %16, %.lr.ph ], [ 0, %.preheader ]
  %10 = getelementptr inbounds double, ptr %2, i64 %storemerge6
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds double, ptr %1, i64 %storemerge6
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = fdiv double %11, %13
  %15 = getelementptr inbounds double, ptr %3, i64 %storemerge6
  store double %14, ptr %15, align 8, !tbaa !11
  %16 = add nuw nsw i64 %storemerge6, 1
  store i64 %16, ptr @iterm_.i, align 8, !tbaa !10
  %17 = load i64, ptr %0, align 8, !tbaa !10
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %5
  ret i32 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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 32}
!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 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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