; LLVM IR from ShahjalalShohag/code-library :: Number Theory/Linear Diophantine Equation Three Variables with Nonnegative Solutions._60bd2cd0 (Z5brutennnn)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

30:                                               ; preds = %79, %7
  %31 = load i32, ptr %17, align 4, !tbaa !9
  %32 = sext i32 %31 to i128
  %33 = load i128, ptr %15, align 16, !tbaa !5
  %34 = icmp sle i128 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %30
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  br label %82

36:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %75, %36
  %38 = load i32, ptr %19, align 4, !tbaa !9
  %39 = sext i32 %38 to i128
  %40 = load i128, ptr %15, align 16, !tbaa !5
  %41 = icmp sle i128 %39, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %71, %43
  %45 = load i32, ptr %20, align 4, !tbaa !9
  %46 = sext i32 %45 to i128
  %47 = load i128, ptr %15, align 16, !tbaa !5
  %48 = icmp sle i128 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %44
  store i32 8, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  br label %74

50:                                               ; preds = %44
  %51 = load i32, ptr %17, align 4, !tbaa !9
  %52 = sext i32 %51 to i128
  %53 = load i128, ptr %12, align 16, !tbaa !5
  %54 = mul nsw i128 %52, %53
  %55 = load i32, ptr %19, align 4, !tbaa !9
  %56 = sext i32 %55 to i128
  %57 = load i128, ptr %13, align 16, !tbaa !5
  %58 = mul nsw i128 %56, %57
  %59 = add nsw i128 %54, %58
  %60 = load i32, ptr %20, align 4, !tbaa !9
  %61 = sext i32 %60 to i128
  %62 = load i128, ptr %14, align 16, !tbaa !5
  %63 = mul nsw i128 %61, %62
  %64 = add nsw i128 %59, %63
  %65 = load i128, ptr %15, align 16, !tbaa !5
  %66 = icmp eq i128 %64, %65
  br i1 %66, label %67, label %70

67:                                               ; preds = %50
  %68 = load i128, ptr %16, align 16, !tbaa !5
  %69 = add nsw i128 %68, 1
  store i128 %69, ptr %16, align 16, !tbaa !5
  br label %70

70:                                               ; preds = %67, %50
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %20, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %20, align 4, !tbaa !9
  br label %44, !llvm.loop !11

74:                                               ; preds = %49
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %19, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %19, align 4, !tbaa !9
  br label %37, !llvm.loop !13

78:                                               ; preds = %42
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %17, align 4, !tbaa !9
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %17, align 4, !tbaa !9
  br label %30, !llvm.loop !14

82:                                               ; preds = %35
  %83 = load i128, ptr %16, align 16, !tbaa !5
  store i128 %83, ptr %8, align 16
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #2
  %84 = load { i64, i64 }, ptr %8, align 16
  ret { i64, i64 } %84
}

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


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef { i64, i64 } @_Z5brutennnn(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i128 noundef %6) local_unnamed_addr #0 {
  %.sroa.221.0.insert.ext = zext i64 %1 to i128
  %.sroa.221.0.insert.shift = shl nuw i128 %.sroa.221.0.insert.ext, 64
  %.sroa.020.0.insert.ext = zext i64 %0 to i128
  %.sroa.020.0.insert.insert = or disjoint i128 %.sroa.221.0.insert.shift, %.sroa.020.0.insert.ext
  %.sroa.219.0.insert.ext = zext i64 %3 to i128
  %.sroa.219.0.insert.shift = shl nuw i128 %.sroa.219.0.insert.ext, 64
  %.sroa.018.0.insert.ext = zext i64 %2 to i128
  %.sroa.018.0.insert.insert = or disjoint i128 %.sroa.219.0.insert.shift, %.sroa.018.0.insert.ext
  %.sroa.2.0.insert.ext = zext i64 %5 to i128
  %.sroa.2.0.insert.shift = shl nuw i128 %.sroa.2.0.insert.ext, 64
  %.sroa.0.0.insert.ext = zext i64 %4 to i128
  %.sroa.0.0.insert.insert = or disjoint i128 %.sroa.2.0.insert.shift, %.sroa.0.0.insert.ext
  %.not38 = icmp slt i128 %6, 0
  br i1 %.not38, label %._crit_edge, label %.preheader33

.preheader33:                                     ; preds = %7, %13
  %8 = phi i128 [ %15, %13 ], [ 0, %7 ]
  %.02639 = phi i128 [ %spec.select, %13 ], [ 0, %7 ]
  %indvars43 = trunc nuw nsw i128 %8 to i32
  %9 = mul nsw i128 %8, %.sroa.020.0.insert.insert
  br label %.preheader

._crit_edge.loopexit:                             ; preds = %13
  %extract = lshr i128 %spec.select, 64
  %extract.t41 = trunc nuw i128 %extract to i64
  %extract.t = trunc i128 %spec.select to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %7
  %.026.lcssa.off0 = phi i64 [ 0, %7 ], [ %extract.t, %._crit_edge.loopexit ]
  %.026.lcssa.off64 = phi i64 [ 0, %7 ], [ %extract.t41, %._crit_edge.loopexit ]
  %.fca.0.insert = insertvalue { i64, i64 } poison, i64 %.026.lcssa.off0, 0
  %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %.026.lcssa.off64, 1
  ret { i64, i64 } %.fca.1.insert

.preheader:                                       ; preds = %.preheader33, %16
  %10 = phi i128 [ 0, %.preheader33 ], [ %18, %16 ]
  %.136 = phi i128 [ %.02639, %.preheader33 ], [ %spec.select, %16 ]
  %indvars42 = trunc nuw nsw i128 %10 to i32
  %11 = mul nsw i128 %10, %.sroa.018.0.insert.insert
  %12 = add nsw i128 %11, %9
  br label %19

13:                                               ; preds = %16
  %14 = add nuw nsw i32 %indvars43, 1
  %15 = zext nneg i32 %14 to i128
  %.not = icmp ugt i128 %15, %6
  br i1 %.not, label %._crit_edge.loopexit, label %.preheader33, !llvm.loop !5

16:                                               ; preds = %19
  %17 = add nuw nsw i32 %indvars42, 1
  %18 = zext nneg i32 %17 to i128
  %.not31 = icmp ugt i128 %18, %6
  br i1 %.not31, label %13, label %.preheader, !llvm.loop !7

19:                                               ; preds = %.preheader, %19
  %20 = phi i128 [ 0, %.preheader ], [ %26, %19 ]
  %.234 = phi i128 [ %.136, %.preheader ], [ %spec.select, %19 ]
  %indvars = trunc nuw nsw i128 %20 to i32
  %21 = mul nsw i128 %20, %.sroa.0.0.insert.insert
  %22 = add nsw i128 %12, %21
  %23 = icmp eq i128 %22, %6
  %24 = zext i1 %23 to i128
  %spec.select = add nsw i128 %.234, %24
  %25 = add nuw nsw i32 %indvars, 1
  %26 = zext nneg i32 %25 to i128
  %.not32 = icmp ugt i128 %26, %6
  br i1 %.not32, label %16, label %19, !llvm.loop !8
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass