; LLVM IR from henrywatkins/PARAMAGNET :: src/Initial.ll (Z16InitialConditionPd)

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

@nz = external constant i32, align 4
@ny = external constant i32, align 4
@nx = external constant i32, align 4
@vars = external constant i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z16InitialConditionPd(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %104, %1
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = load i32, ptr @nz, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %107

31:                                               ; preds = %27
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %100, %31
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = load i32, ptr @ny, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %36, label %103

36:                                               ; preds = %32
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %96, %36
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = load i32, ptr @nx, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %99

41:                                               ; preds = %37
  %42 = load i32, ptr @vars, align 4, !tbaa !9
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = load i32, ptr @nx, align 4, !tbaa !9
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = mul nsw i32 %44, %45
  %47 = add nsw i32 %43, %46
  %48 = load i32, ptr @nx, align 4, !tbaa !9
  %49 = load i32, ptr @ny, align 4, !tbaa !9
  %50 = mul nsw i32 %48, %49
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = mul nsw i32 %50, %51
  %53 = add nsw i32 %47, %52
  %54 = mul nsw i32 %42, %53
  store i32 %54, ptr %6, align 4, !tbaa !9
  %55 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %55, ptr %8, align 4, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %9, align 4, !tbaa !9
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = add nsw i32 %58, 2
  store i32 %59, ptr %10, align 4, !tbaa !9
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = add nsw i32 %60, 3
  store i32 %61, ptr %11, align 4, !tbaa !9
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = add nsw i32 %62, 4
  store i32 %63, ptr %12, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = add nsw i32 %64, 5
  store i32 %65, ptr %13, align 4, !tbaa !9
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = add nsw i32 %66, 6
  store i32 %67, ptr %14, align 4, !tbaa !9
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = add nsw i32 %68, 7
  store i32 %69, ptr %15, align 4, !tbaa !9
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = add nsw i32 %70, 8
  store i32 %71, ptr %16, align 4, !tbaa !9
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = add nsw i32 %72, 9
  store i32 %73, ptr %17, align 4, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = add nsw i32 %74, 10
  store i32 %75, ptr %18, align 4, !tbaa !9
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = add nsw i32 %76, 11
  store i32 %77, ptr %19, align 4, !tbaa !9
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = add nsw i32 %78, 12
  store i32 %79, ptr %20, align 4, !tbaa !9
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = add nsw i32 %80, 13
  store i32 %81, ptr %21, align 4, !tbaa !9
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = add nsw i32 %82, 14
  store i32 %83, ptr %22, align 4, !tbaa !9
  %84 = load i32, ptr %6, align 4, !tbaa !9
  %85 = add nsw i32 %84, 15
  store i32 %85, ptr %23, align 4, !tbaa !9
  %86 = load i32, ptr %6, align 4, !tbaa !9
  %87 = add nsw i32 %86, 16
  store i32 %87, ptr %24, align 4, !tbaa !9
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds double, ptr %88, i64 %90
  store double 1.000000e+00, ptr %91, align 8, !tbaa !11
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = load i32, ptr %12, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds double, ptr %92, i64 %94
  store double 1.000000e+00, ptr %95, align 8, !tbaa !11
  br label %96

96:                                               ; preds = %41
  %97 = load i32, ptr %3, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %3, align 4, !tbaa !9
  br label %37, !llvm.loop !13

99:                                               ; preds = %37
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %4, align 4, !tbaa !9
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %4, align 4, !tbaa !9
  br label %32, !llvm.loop !15

103:                                              ; preds = %32
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %5, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %5, align 4, !tbaa !9
  br label %27, !llvm.loop !16

107:                                              ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; 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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

@nz = external local_unnamed_addr constant i32, align 4
@ny = external local_unnamed_addr constant i32, align 4
@nx = external local_unnamed_addr constant i32, align 4
@vars = external local_unnamed_addr constant i32, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @_Z16InitialConditionPd(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @nz, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.preheader32.lr.ph, label %._crit_edge

.preheader32.lr.ph:                               ; preds = %1
  %4 = load i32, ptr @ny, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  %6 = load i32, ptr @nx, align 4
  %7 = load i32, ptr @vars, align 4
  %8 = icmp sgt i32 %6, 0
  %or.cond = select i1 %5, i1 %8, i1 false
  br i1 %or.cond, label %.preheader32.us.us.preheader, label %._crit_edge

.preheader32.us.us.preheader:                     ; preds = %.preheader32.lr.ph
  %wide.trip.count = zext nneg i32 %6 to i64
  %9 = add nsw i64 %wide.trip.count, -1
  %10 = mul i32 %4, %6
  %min.iters.check = icmp ult i32 %6, 8
  %ident.check = icmp ne i32 %7, 1
  %11 = trunc nsw i64 %9 to i32
  %12 = icmp ugt i64 %9, 4294967295
  %n.vec = and i64 %wide.trip.count, 2147483646
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %13 = add nsw i64 %wide.trip.count, -1
  br label %.preheader32.us.us

.preheader32.us.us:                               ; preds = %.preheader32.us.us.preheader, %._crit_edge35.split.us.us.us
  %.03036.us.us = phi i32 [ %49, %._crit_edge35.split.us.us.us ], [ 0, %.preheader32.us.us.preheader ]
  %14 = mul i32 %10, %.03036.us.us
  %15 = mul i32 %4, %.03036.us.us
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader32.us.us
  %.02934.us.us.us = phi i32 [ 0, %.preheader32.us.us ], [ %48, %._crit_edge.us.us.us ]
  %reass.add.us.us.us = add i32 %15, %.02934.us.us.us
  %reass.mul.us.us.us = mul i32 %reass.add.us.us.us, %6
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.preheader.us.us.us
  %16 = mul i32 %6, %.02934.us.us.us
  %17 = add i32 %14, %16
  %18 = add i32 %17, %11
  %19 = icmp slt i32 %18, %17
  %20 = or i1 %19, %12
  %21 = or i1 %ident.check, %20
  br i1 %21, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.scevcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.scevcheck ]
  %22 = trunc i64 %index to i32
  %23 = add i32 %reass.mul.us.us.us, %22
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %0, i64 %24
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %25, align 8, !tbaa !9
  %26 = getelementptr i8, ptr %25, i64 32
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %26, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 2
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us.us.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.scevcheck, %.preheader.us.us.us
  %indvars.iv.ph = phi i64 [ 0, %vector.scevcheck ], [ 0, %.preheader.us.us.us ], [ %n.vec, %middle.block ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %28 = trunc nuw nsw i64 %indvars.iv.ph to i32
  %29 = add i32 %reass.mul.us.us.us, %28
  %30 = mul nsw i32 %7, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %0, i64 %31
  store double 1.000000e+00, ptr %32, align 8, !tbaa !9
  %33 = getelementptr i8, ptr %32, i64 32
  store double 1.000000e+00, ptr %33, align 8, !tbaa !9
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %34 = icmp eq i64 %indvars.iv.ph, %13
  br i1 %34, label %._crit_edge.us.us.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %35 = trunc nuw nsw i64 %indvars.iv to i32
  %36 = add i32 %reass.mul.us.us.us, %35
  %37 = mul nsw i32 %7, %36
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %0, i64 %38
  store double 1.000000e+00, ptr %39, align 8, !tbaa !9
  %40 = getelementptr i8, ptr %39, i64 32
  store double 1.000000e+00, ptr %40, align 8, !tbaa !9
  %41 = trunc i64 %indvars.iv to i32
  %42 = add i32 %41, 1
  %43 = add i32 %reass.mul.us.us.us, %42
  %44 = mul nsw i32 %7, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %0, i64 %45
  store double 1.000000e+00, ptr %46, align 8, !tbaa !9
  %47 = getelementptr i8, ptr %46, i64 32
  store double 1.000000e+00, ptr %47, align 8, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge.us.us.us, label %scalar.ph, !llvm.loop !15

._crit_edge.us.us.us:                             ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %48 = add nuw nsw i32 %.02934.us.us.us, 1
  %exitcond44.not = icmp eq i32 %48, %4
  br i1 %exitcond44.not, label %._crit_edge35.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !16

._crit_edge35.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %49 = add nuw nsw i32 %.03036.us.us, 1
  %exitcond45.not = icmp eq i32 %49, %2
  br i1 %exitcond45.not, label %._crit_edge, label %.preheader32.us.us, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge35.split.us.us.us, %.preheader32.lr.ph, %1
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: write) 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !13}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass