; LLVM IR from NaokiHori/VerySimpleNSSolver :: src/integrate/transpose (main)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @transpose(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %43, %4
  %13 = load i64, ptr %9, align 8, !tbaa !5
  %14 = load i64, ptr %6, align 8, !tbaa !5
  %15 = icmp ult i64 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %46

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %39, %17
  %19 = load i64, ptr %11, align 8, !tbaa !5
  %20 = load i64, ptr %5, align 8, !tbaa !5
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  br label %42

23:                                               ; preds = %18
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = load i64, ptr %9, align 8, !tbaa !5
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = mul i64 %25, %26
  %28 = load i64, ptr %11, align 8, !tbaa !5
  %29 = add i64 %27, %28
  %30 = getelementptr inbounds double, ptr %24, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = load i64, ptr %11, align 8, !tbaa !5
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = mul i64 %33, %34
  %36 = load i64, ptr %9, align 8, !tbaa !5
  %37 = add i64 %35, %36
  %38 = getelementptr inbounds double, ptr %32, i64 %37
  store double %31, ptr %38, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %23
  %40 = load i64, ptr %11, align 8, !tbaa !5
  %41 = add i64 %40, 1
  store i64 %41, ptr %11, align 8, !tbaa !5
  br label %18, !llvm.loop !13

42:                                               ; preds = %22
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %9, align 8, !tbaa !5
  %45 = add i64 %44, 1
  store i64 %45, ptr %9, align 8, !tbaa !5
  br label %12, !llvm.loop !15

46:                                               ; preds = %16
  ret i32 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

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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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}


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

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local noundef i32 @transpose(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %.not = icmp eq i64 %1, 0
  %.not19 = icmp eq i64 %0, 0
  %or.cond = or i1 %.not, %.not19
  br i1 %or.cond, label %._crit_edge18, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %4
  %5 = add i64 %1, %0
  %6 = shl i64 %5, 3
  %7 = getelementptr i8, ptr %3, i64 %6
  %scevgep = getelementptr i8, ptr %7, i64 -8
  %8 = mul i64 %1, %0
  %9 = shl i64 %8, 3
  %scevgep22 = getelementptr i8, ptr %2, i64 %9
  %min.iters.check = icmp ugt i64 %0, 7
  %ident.check.not = icmp eq i64 %1, 1
  %or.cond24 = and i1 %min.iters.check, %ident.check.not
  %bound0 = icmp ugt ptr %scevgep22, %3
  %bound1 = icmp ugt ptr %scevgep, %2
  %found.conflict = and i1 %bound0, %bound1
  %.mask = and i64 %0, 1152921504606846976
  %stride.check = icmp ne i64 %.mask, 0
  %10 = or i1 %found.conflict, %stride.check
  %n.vec = and i64 %0, -1152921504606846980
  %cmp.n = icmp eq i64 %n.vec, %0
  %xtraiter = and i64 %0, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.01317.us = phi i64 [ %40, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %invariant.gep.us = getelementptr double, ptr %3, i64 %.01317.us
  %11 = mul i64 %.01317.us, %0
  %12 = getelementptr double, ptr %2, i64 %11
  %or.cond24.not = xor i1 %or.cond24, true
  %brmerge = or i1 %or.cond24.not, %10
  br i1 %brmerge, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.preheader.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader.us ]
  %13 = getelementptr double, ptr %12, i64 %index
  %14 = getelementptr i8, ptr %13, i64 16
  %wide.load = load <2 x double>, ptr %13, align 8, !tbaa !5, !alias.scope !9
  %wide.load23 = load <2 x double>, ptr %14, align 8, !tbaa !5, !alias.scope !9
  %15 = getelementptr double, ptr %invariant.gep.us, i64 %index
  %16 = getelementptr i8, ptr %15, i64 16
  store <2 x double> %wide.load, ptr %15, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  store <2 x double> %wide.load23, ptr %16, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %index.next = add nuw i64 %index, 4
  %17 = icmp eq i64 %index.next, %n.vec
  br i1 %17, label %middle.block, label %vector.body, !llvm.loop !14

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

scalar.ph.preheader:                              ; preds = %.preheader.us, %middle.block
  %.016.us.ph = phi i64 [ 0, %.preheader.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, %scalar.ph.prol
  %.016.us.prol = phi i64 [ %21, %scalar.ph.prol ], [ %.016.us.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %18 = getelementptr double, ptr %12, i64 %.016.us.prol
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = mul i64 %.016.us.prol, %1
  %gep.us.prol = getelementptr double, ptr %invariant.gep.us, i64 %20
  store double %19, ptr %gep.us.prol, align 8, !tbaa !5
  %21 = add nuw i64 %.016.us.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !18

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.016.us.unr = phi i64 [ %.016.us.ph, %scalar.ph.preheader ], [ %21, %scalar.ph.prol ]
  %22 = sub i64 %.016.us.ph, %0
  %23 = icmp ugt i64 %22, -4
  br i1 %23, label %._crit_edge.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.016.us = phi i64 [ %39, %scalar.ph ], [ %.016.us.unr, %scalar.ph.prol.loopexit ]
  %24 = getelementptr double, ptr %12, i64 %.016.us
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = mul i64 %.016.us, %1
  %gep.us = getelementptr double, ptr %invariant.gep.us, i64 %26
  store double %25, ptr %gep.us, align 8, !tbaa !5
  %27 = add nuw i64 %.016.us, 1
  %28 = getelementptr double, ptr %12, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = mul i64 %27, %1
  %gep.us.1 = getelementptr double, ptr %invariant.gep.us, i64 %30
  store double %29, ptr %gep.us.1, align 8, !tbaa !5
  %31 = add nuw i64 %.016.us, 2
  %32 = getelementptr double, ptr %12, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = mul i64 %31, %1
  %gep.us.2 = getelementptr double, ptr %invariant.gep.us, i64 %34
  store double %33, ptr %gep.us.2, align 8, !tbaa !5
  %35 = add nuw i64 %.016.us, 3
  %36 = getelementptr double, ptr %12, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = mul i64 %35, %1
  %gep.us.3 = getelementptr double, ptr %invariant.gep.us, i64 %38
  store double %37, ptr %gep.us.3, align 8, !tbaa !5
  %39 = add nuw i64 %.016.us, 4
  %exitcond.not.3 = icmp eq i64 %39, %0
  br i1 %exitcond.not.3, label %._crit_edge.us, label %scalar.ph, !llvm.loop !20

._crit_edge.us:                                   ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %40 = add nuw i64 %.01317.us, 1
  %exitcond21.not = icmp eq i64 %40, %1
  br i1 %exitcond21.not, label %._crit_edge18, label %.preheader.us, !llvm.loop !21

._crit_edge18:                                    ; preds = %._crit_edge.us, %4
  ret i32 0
}

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


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