; LLVM IR from dmalyuta/FlyARocket_GNC :: simplex_funcs (get_simplex_solution)

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

@i = external dso_local global i32, align 4
@j = external dso_local global i32, align 4
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local void @get_simplex_solution(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #1 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  store i32 %0, ptr %10, align 4, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !9
  store ptr %2, ptr %12, align 8, !tbaa !9
  store i32 %3, ptr %13, align 4, !tbaa !5
  store i32 %4, ptr %14, align 4, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !9
  store ptr %7, ptr %17, align 8, !tbaa !9
  store ptr %8, ptr %18, align 8, !tbaa !9
  %19 = load i32, ptr %10, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %98

21:                                               ; preds = %9
  store i32 1, ptr @i, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %94, %21
  %23 = load i32, ptr @i, align 4, !tbaa !5
  %24 = load i32, ptr %14, align 4, !tbaa !5
  %25 = icmp sle i32 %23, %24
  br i1 %25, label %26, label %97

26:                                               ; preds = %22
  store i32 1, ptr @j, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %79, %26
  %28 = load i32, ptr @j, align 4, !tbaa !5
  %29 = load i32, ptr %13, align 4, !tbaa !5
  %30 = icmp sle i32 %28, %29
  br i1 %30, label %31, label %82

31:                                               ; preds = %27
  %32 = load ptr, ptr %11, align 8, !tbaa !9
  %33 = load i32, ptr @j, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr %32, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr @i, align 4, !tbaa !5
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %78

39:                                               ; preds = %31
  %40 = load i32, ptr @i, align 4, !tbaa !5
  switch i32 %40, label %77 [
    i32 1, label %41
    i32 2, label %50
    i32 3, label %59
    i32 4, label %68
  ]

41:                                               ; preds = %39
  %42 = load ptr, ptr %12, align 8, !tbaa !9
  %43 = load i32, ptr @j, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [6 x double], ptr %42, i64 %45
  %47 = getelementptr inbounds [6 x double], ptr %46, i64 0, i64 1
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = load ptr, ptr %15, align 8, !tbaa !9
  store double %48, ptr %49, align 8, !tbaa !11
  br label %77

50:                                               ; preds = %39
  %51 = load ptr, ptr %12, align 8, !tbaa !9
  %52 = load i32, ptr @j, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [6 x double], ptr %51, i64 %54
  %56 = getelementptr inbounds [6 x double], ptr %55, i64 0, i64 1
  %57 = load double, ptr %56, align 8, !tbaa !11
  %58 = load ptr, ptr %16, align 8, !tbaa !9
  store double %57, ptr %58, align 8, !tbaa !11
  br label %77

59:                                               ; preds = %39
  %60 = load ptr, ptr %12, align 8, !tbaa !9
  %61 = load i32, ptr @j, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [6 x double], ptr %60, i64 %63
  %65 = getelementptr inbounds [6 x double], ptr %64, i64 0, i64 1
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = load ptr, ptr %17, align 8, !tbaa !9
  store double %66, ptr %67, align 8, !tbaa !11
  br label %77

68:                                               ; preds = %39
  %69 = load ptr, ptr %12, align 8, !tbaa !9
  %70 = load i32, ptr @j, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [6 x double], ptr %69, i64 %72
  %74 = getelementptr inbounds [6 x double], ptr %73, i64 0, i64 1
  %75 = load double, ptr %74, align 8, !tbaa !11
  %76 = load ptr, ptr %18, align 8, !tbaa !9
  store double %75, ptr %76, align 8, !tbaa !11
  br label %77

77:                                               ; preds = %68, %59, %50, %41, %39
  br label %93

78:                                               ; preds = %31
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr @j, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr @j, align 4, !tbaa !5
  br label %27, !llvm.loop !13

82:                                               ; preds = %27
  %83 = load i32, ptr @i, align 4, !tbaa !5
  switch i32 %83, label %92 [
    i32 1, label %84
    i32 2, label %86
    i32 3, label %88
    i32 4, label %90
  ]

84:                                               ; preds = %82
  %85 = load ptr, ptr %15, align 8, !tbaa !9
  store double 0.000000e+00, ptr %85, align 8, !tbaa !11
  br label %92

86:                                               ; preds = %82
  %87 = load ptr, ptr %16, align 8, !tbaa !9
  store double 0.000000e+00, ptr %87, align 8, !tbaa !11
  br label %92

88:                                               ; preds = %82
  %89 = load ptr, ptr %17, align 8, !tbaa !9
  store double 0.000000e+00, ptr %89, align 8, !tbaa !11
  br label %92

90:                                               ; preds = %82
  %91 = load ptr, ptr %18, align 8, !tbaa !9
  store double 0.000000e+00, ptr %91, align 8, !tbaa !11
  br label %92

92:                                               ; preds = %90, %88, %86, %84, %82
  br label %93

93:                                               ; preds = %92, %77
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr @i, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr @i, align 4, !tbaa !5
  br label %22, !llvm.loop !15

97:                                               ; preds = %22
  br label %101

98:                                               ; preds = %9
  %99 = load i32, ptr %10, align 4, !tbaa !5
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %99)
  br label %101

101:                                              ; preds = %98, %97
  ret void
}

attributes #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 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/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"

@i = external dso_local local_unnamed_addr global i32, align 4
@j = external dso_local local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @get_simplex_solution(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6, ptr nocapture noundef writeonly %7, ptr nocapture noundef writeonly %8) local_unnamed_addr #1 {
  %10 = icmp eq i32 %0, 0
  br i1 %10, label %.preheader20, label %46

.preheader20:                                     ; preds = %9
  %invariant.gep = getelementptr inbounds i8, ptr %2, i64 56
  store i32 1, ptr @i, align 4, !tbaa !5
  %.not29 = icmp slt i32 %4, 1
  br i1 %.not29, label %.loopexit, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader20
  %.not1921 = icmp slt i32 %3, 1
  br i1 %.not1921, label %.preheader.lr.ph.split.us, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %11 = add nuw i32 %3, 1
  %wide.trip.count = zext i32 %11 to i64
  br label %.preheader

.preheader.lr.ph.split.us:                        ; preds = %.preheader.lr.ph
  store i32 1, ptr @j, align 4, !tbaa !5
  %12 = add nuw i32 %4, 1
  %xtraiter = and i32 %4, 1
  %13 = icmp eq i32 %4, 1
  br i1 %13, label %..loopexit_crit_edge.split.us.unr-lcssa, label %.preheader.lr.ph.split.us.new

.preheader.lr.ph.split.us.new:                    ; preds = %.preheader.lr.ph.split.us
  %unroll_iter = and i32 %4, 2147483646
  br label %.preheader.us

.preheader.us:                                    ; preds = %20, %.preheader.lr.ph.split.us.new
  %storemerge30.us = phi i32 [ 1, %.preheader.lr.ph.split.us.new ], [ %21, %20 ]
  %niter = phi i32 [ 0, %.preheader.lr.ph.split.us.new ], [ %niter.next.1, %20 ]
  switch i32 %storemerge30.us, label %20 [
    i32 1, label %16
    i32 2, label %15
    i32 3, label %14
    i32 4, label %.sink.split
    i32 0, label %19
  ]

14:                                               ; preds = %.preheader.us
  br label %.sink.split

15:                                               ; preds = %.preheader.us
  br label %.sink.split

16:                                               ; preds = %.preheader.us
  br label %.sink.split

.sink.split:                                      ; preds = %.preheader.us, %14, %15, %16
  %.sink = phi ptr [ %5, %16 ], [ %6, %15 ], [ %7, %14 ], [ %8, %.preheader.us ]
  store double 0.000000e+00, ptr %.sink, align 8, !tbaa !9
  switch i32 %storemerge30.us, label %20 [
    i32 0, label %19
    i32 1, label %18
    i32 2, label %17
    i32 3, label %.sink.split.1
  ]

17:                                               ; preds = %.sink.split
  br label %.sink.split.1

18:                                               ; preds = %.sink.split
  br label %.sink.split.1

19:                                               ; preds = %.preheader.us, %.sink.split
  br label %.sink.split.1

.sink.split.1:                                    ; preds = %19, %18, %17, %.sink.split
  %.sink.1 = phi ptr [ %5, %19 ], [ %6, %18 ], [ %7, %17 ], [ %8, %.sink.split ]
  store double 0.000000e+00, ptr %.sink.1, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %.preheader.us, %.sink.split.1, %.sink.split
  %21 = add nuw i32 %storemerge30.us, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %..loopexit_crit_edge.split.us.unr-lcssa, label %.preheader.us, !llvm.loop !11

..loopexit_crit_edge.split.us.unr-lcssa:          ; preds = %20, %.preheader.lr.ph.split.us
  %storemerge30.us.unr = phi i32 [ 1, %.preheader.lr.ph.split.us ], [ %21, %20 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %..loopexit_crit_edge.split.us, label %.preheader.us.epil

.preheader.us.epil:                               ; preds = %..loopexit_crit_edge.split.us.unr-lcssa
  switch i32 %storemerge30.us.unr, label %..loopexit_crit_edge.split.us [
    i32 1, label %24
    i32 2, label %23
    i32 3, label %22
    i32 4, label %.sink.split.epil
  ]

22:                                               ; preds = %.preheader.us.epil
  br label %.sink.split.epil

23:                                               ; preds = %.preheader.us.epil
  br label %.sink.split.epil

24:                                               ; preds = %.preheader.us.epil
  br label %.sink.split.epil

.sink.split.epil:                                 ; preds = %24, %23, %22, %.preheader.us.epil
  %.sink.epil = phi ptr [ %5, %24 ], [ %6, %23 ], [ %7, %22 ], [ %8, %.preheader.us.epil ]
  store double 0.000000e+00, ptr %.sink.epil, align 8, !tbaa !9
  br label %..loopexit_crit_edge.split.us

..loopexit_crit_edge.split.us:                    ; preds = %.preheader.us.epil, %.sink.split.epil, %..loopexit_crit_edge.split.us.unr-lcssa
  store i32 %12, ptr @i, align 4, !tbaa !5
  br label %.loopexit

.preheader:                                       ; preds = %.preheader.preheader, %44
  %storemerge30 = phi i32 [ %45, %44 ], [ 1, %.preheader.preheader ]
  store i32 1, ptr @j, align 4, !tbaa !5
  br label %27

25:                                               ; preds = %27
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = trunc nuw i64 %indvars.iv.next to i32
  store i32 %26, ptr @j, align 4, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %27, !llvm.loop !13

27:                                               ; preds = %.preheader, %25
  %indvars.iv = phi i64 [ 1, %.preheader ], [ %indvars.iv.next, %25 ]
  %28 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp eq i32 %29, %storemerge30
  br i1 %30, label %31, label %25

31:                                               ; preds = %27
  switch i32 %storemerge30, label %44 [
    i32 1, label %32
    i32 2, label %34
    i32 3, label %36
    i32 4, label %38
  ]

32:                                               ; preds = %31
  %gep28 = getelementptr inbounds [6 x double], ptr %invariant.gep, i64 %indvars.iv
  %33 = load double, ptr %gep28, align 8, !tbaa !9
  store double %33, ptr %5, align 8, !tbaa !9
  br label %44

34:                                               ; preds = %31
  %gep26 = getelementptr inbounds [6 x double], ptr %invariant.gep, i64 %indvars.iv
  %35 = load double, ptr %gep26, align 8, !tbaa !9
  store double %35, ptr %6, align 8, !tbaa !9
  br label %44

36:                                               ; preds = %31
  %gep24 = getelementptr inbounds [6 x double], ptr %invariant.gep, i64 %indvars.iv
  %37 = load double, ptr %gep24, align 8, !tbaa !9
  store double %37, ptr %7, align 8, !tbaa !9
  br label %44

38:                                               ; preds = %31
  %gep = getelementptr inbounds [6 x double], ptr %invariant.gep, i64 %indvars.iv
  %39 = load double, ptr %gep, align 8, !tbaa !9
  store double %39, ptr %8, align 8, !tbaa !9
  br label %44

._crit_edge:                                      ; preds = %25
  switch i32 %storemerge30, label %44 [
    i32 1, label %40
    i32 2, label %41
    i32 3, label %42
    i32 4, label %43
  ]

40:                                               ; preds = %._crit_edge
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  br label %44

41:                                               ; preds = %._crit_edge
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  br label %44

42:                                               ; preds = %._crit_edge
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  br label %44

43:                                               ; preds = %._crit_edge
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %38, %36, %34, %32, %31, %43, %42, %41, %40, %._crit_edge
  %45 = add nuw i32 %storemerge30, 1
  store i32 %45, ptr @i, align 4, !tbaa !5
  %exitcond36.not = icmp eq i32 %storemerge30, %4
  br i1 %exitcond36.not, label %.loopexit, label %.preheader, !llvm.loop !11

46:                                               ; preds = %9
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %0)
  br label %.loopexit

.loopexit:                                        ; preds = %44, %.preheader20, %..loopexit_crit_edge.split.us, %46
  ret void
}

attributes #0 = { nofree 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 #1 = { nofree 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 = !{!"int", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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