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

; 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
declare dso_local noundef { i64, i64 } @_Z5sumsqn(i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef { i64, i64 } @_Z9floor_sumnnnn(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i128 noundef %6) #2 {
  %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 i128, align 16
  %18 = alloca i128, align 16
  %19 = alloca i32, align 4
  %20 = alloca i128, align 16
  %21 = alloca i128, align 16
  %22 = alloca i128, align 16
  %23 = alloca i128, align 16
  %24 = alloca i128, align 16
  %25 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  store i64 %0, ptr %25, align 16
  %26 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  store i64 %1, ptr %26, align 8
  %27 = load i128, ptr %9, align 16, !tbaa !5
  %28 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 0
  store i64 %2, ptr %28, align 16
  %29 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 1
  store i64 %3, ptr %29, align 8
  %30 = load i128, ptr %10, align 16, !tbaa !5
  %31 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  store i64 %4, ptr %31, align 16
  %32 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  store i64 %5, ptr %32, align 8
  %33 = load i128, ptr %11, align 16, !tbaa !5
  store i128 %27, ptr %12, align 16, !tbaa !5
  store i128 %30, ptr %13, align 16, !tbaa !5
  store i128 %33, 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) #3
  %34 = load i128, ptr %13, align 16, !tbaa !5
  %35 = load i128, ptr %14, align 16, !tbaa !5
  %36 = sdiv i128 %34, %35
  %37 = load i128, ptr %15, align 16, !tbaa !5
  store i128 %37, ptr %17, align 16, !tbaa !5
  %38 = getelementptr inbounds { i64, i64 }, ptr %17, i32 0, i32 0
  %39 = load i64, ptr %38, align 16
  %40 = getelementptr inbounds { i64, i64 }, ptr %17, i32 0, i32 1
  %41 = load i64, ptr %40, align 8
  %42 = call noundef { i64, i64 } @_Z5sumsqn(i64 noundef %39, i64 noundef %41)
  %43 = getelementptr inbounds { i64, i64 }, ptr %18, i32 0, i32 0
  %44 = extractvalue { i64, i64 } %42, 0
  store i64 %44, ptr %43, align 16
  %45 = getelementptr inbounds { i64, i64 }, ptr %18, i32 0, i32 1
  %46 = extractvalue { i64, i64 } %42, 1
  store i64 %46, ptr %45, align 8
  %47 = load i128, ptr %18, align 16, !tbaa !5
  %48 = mul nsw i128 %36, %47
  %49 = load i128, ptr %12, align 16, !tbaa !5
  %50 = load i128, ptr %14, align 16, !tbaa !5
  %51 = sdiv i128 %49, %50
  %52 = load i128, ptr %15, align 16, !tbaa !5
  %53 = mul nsw i128 %51, %52
  %54 = add nsw i128 %48, %53
  store i128 %54, ptr %16, align 16, !tbaa !5
  %55 = load i128, ptr %14, align 16, !tbaa !5
  %56 = load i128, ptr %13, align 16, !tbaa !5
  %57 = srem i128 %56, %55
  store i128 %57, ptr %13, align 16, !tbaa !5
  %58 = load i128, ptr %14, align 16, !tbaa !5
  %59 = load i128, ptr %12, align 16, !tbaa !5
  %60 = srem i128 %59, %58
  store i128 %60, ptr %12, align 16, !tbaa !5
  %61 = load i128, ptr %13, align 16, !tbaa !5
  %62 = icmp ne i128 %61, 0
  br i1 %62, label %65, label %63

63:                                               ; preds = %7
  %64 = load i128, ptr %16, align 16, !tbaa !5
  store i128 %64, ptr %8, align 16
  store i32 1, ptr %19, align 4
  br label %105

65:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #3
  %66 = load i128, ptr %15, align 16, !tbaa !5
  %67 = load i128, ptr %13, align 16, !tbaa !5
  %68 = mul nsw i128 %66, %67
  %69 = load i128, ptr %12, align 16, !tbaa !5
  %70 = add nsw i128 %68, %69
  %71 = load i128, ptr %14, align 16, !tbaa !5
  %72 = sdiv i128 %70, %71
  store i128 %72, ptr %20, align 16, !tbaa !5
  %73 = load i128, ptr %16, align 16, !tbaa !5
  %74 = load i128, ptr %15, align 16, !tbaa !5
  %75 = sub nsw i128 %74, 1
  %76 = load i128, ptr %20, align 16, !tbaa !5
  %77 = mul nsw i128 %75, %76
  %78 = add nsw i128 %73, %77
  %79 = load i128, ptr %14, align 16, !tbaa !5
  %80 = sub nsw i128 %79, 1
  %81 = load i128, ptr %12, align 16, !tbaa !5
  %82 = sub nsw i128 %80, %81
  %83 = load i128, ptr %14, align 16, !tbaa !5
  %84 = load i128, ptr %13, align 16, !tbaa !5
  %85 = load i128, ptr %20, align 16, !tbaa !5
  store i128 %82, ptr %21, align 16, !tbaa !5
  %86 = getelementptr inbounds { i64, i64 }, ptr %21, i32 0, i32 0
  %87 = load i64, ptr %86, align 16
  %88 = getelementptr inbounds { i64, i64 }, ptr %21, i32 0, i32 1
  %89 = load i64, ptr %88, align 8
  store i128 %83, ptr %22, align 16, !tbaa !5
  %90 = getelementptr inbounds { i64, i64 }, ptr %22, i32 0, i32 0
  %91 = load i64, ptr %90, align 16
  %92 = getelementptr inbounds { i64, i64 }, ptr %22, i32 0, i32 1
  %93 = load i64, ptr %92, align 8
  store i128 %84, ptr %23, align 16, !tbaa !5
  %94 = getelementptr inbounds { i64, i64 }, ptr %23, i32 0, i32 0
  %95 = load i64, ptr %94, align 16
  %96 = getelementptr inbounds { i64, i64 }, ptr %23, i32 0, i32 1
  %97 = load i64, ptr %96, align 8
  %98 = call noundef { i64, i64 } @_Z9floor_sumnnnn(i64 noundef %87, i64 noundef %89, i64 noundef %91, i64 noundef %93, i64 noundef %95, i64 noundef %97, i128 noundef %85)
  %99 = getelementptr inbounds { i64, i64 }, ptr %24, i32 0, i32 0
  %100 = extractvalue { i64, i64 } %98, 0
  store i64 %100, ptr %99, align 16
  %101 = getelementptr inbounds { i64, i64 }, ptr %24, i32 0, i32 1
  %102 = extractvalue { i64, i64 } %98, 1
  store i64 %102, ptr %101, align 8
  %103 = load i128, ptr %24, align 16, !tbaa !5
  %104 = sub nsw i128 %78, %103
  store i128 %104, ptr %8, align 16
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #3
  br label %105

105:                                              ; preds = %65, %63
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #3
  %106 = load { i64, i64 }, ptr %8, align 16
  ret { i64, i64 } %106
}

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 = { mustprogress 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 #3 = { 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"}


; 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 nounwind uwtable
declare dso_local noundef { i64, i64 } @_Z5sumsqn(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef { i64, i64 } @_Z9floor_sumnnnn(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.239.0.insert.ext = zext i64 %1 to i128
  %.sroa.239.0.insert.shift = shl nuw i128 %.sroa.239.0.insert.ext, 64
  %.sroa.038.0.insert.ext = zext i64 %0 to i128
  %.sroa.038.0.insert.insert = or disjoint i128 %.sroa.239.0.insert.shift, %.sroa.038.0.insert.ext
  %.sroa.237.0.insert.ext = zext i64 %3 to i128
  %.sroa.237.0.insert.shift = shl nuw i128 %.sroa.237.0.insert.ext, 64
  %.sroa.036.0.insert.ext = zext i64 %2 to i128
  %.sroa.036.0.insert.insert = or disjoint i128 %.sroa.237.0.insert.shift, %.sroa.036.0.insert.ext
  %.sroa.235.0.insert.ext = zext i64 %5 to i128
  %.sroa.235.0.insert.shift = shl nuw i128 %.sroa.235.0.insert.ext, 64
  %.sroa.034.0.insert.ext = zext i64 %4 to i128
  %.sroa.034.0.insert.insert = or disjoint i128 %.sroa.235.0.insert.shift, %.sroa.034.0.insert.ext
  %8 = sdiv i128 %.sroa.036.0.insert.insert, %.sroa.034.0.insert.insert
  %.sroa.010.0.extract.trunc = trunc i128 %6 to i64
  %.sroa.211.0.extract.shift = lshr i128 %6, 64
  %.sroa.211.0.extract.trunc = trunc nuw i128 %.sroa.211.0.extract.shift to i64
  %9 = tail call noundef { i64, i64 } @_Z5sumsqn(i64 noundef %.sroa.010.0.extract.trunc, i64 noundef %.sroa.211.0.extract.trunc)
  %10 = extractvalue { i64, i64 } %9, 0
  %11 = extractvalue { i64, i64 } %9, 1
  %.sroa.29.0.insert.ext = zext i64 %11 to i128
  %.sroa.29.0.insert.shift = shl nuw i128 %.sroa.29.0.insert.ext, 64
  %.sroa.08.0.insert.ext = zext i64 %10 to i128
  %.sroa.08.0.insert.insert = or disjoint i128 %.sroa.29.0.insert.shift, %.sroa.08.0.insert.ext
  %12 = mul nsw i128 %.sroa.08.0.insert.insert, %8
  %13 = sdiv i128 %.sroa.038.0.insert.insert, %.sroa.034.0.insert.insert
  %14 = mul nsw i128 %13, %6
  %15 = add nsw i128 %12, %14
  %16 = mul i128 %8, %.sroa.034.0.insert.insert
  %.decomposed = sub i128 %.sroa.036.0.insert.insert, %16
  %.not = icmp eq i128 %.decomposed, 0
  br i1 %.not, label %17, label %18

17:                                               ; preds = %7
  %.sroa.040.0.extract.trunc = trunc i128 %15 to i64
  %.sroa.3.0.extract.shift = lshr i128 %15, 64
  %.sroa.3.0.extract.trunc = trunc nuw i128 %.sroa.3.0.extract.shift to i64
  br label %32

18:                                               ; preds = %7
  %19 = mul i128 %13, %.sroa.034.0.insert.insert
  %.decomposed45 = sub i128 %.sroa.038.0.insert.insert, %19
  %20 = mul nsw i128 %.decomposed, %6
  %21 = add nsw i128 %.decomposed45, %20
  %22 = sdiv i128 %21, %.sroa.034.0.insert.insert
  %23 = add nsw i128 %6, -1
  %24 = mul nsw i128 %22, %23
  %25 = xor i128 %.decomposed45, -1
  %26 = add i128 %.sroa.034.0.insert.insert, %25
  %.sroa.05.0.extract.trunc = trunc i128 %26 to i64
  %.sroa.26.0.extract.shift = lshr i128 %26, 64
  %.sroa.26.0.extract.trunc = trunc nuw i128 %.sroa.26.0.extract.shift to i64
  %.sroa.01.0.extract.trunc = trunc i128 %.decomposed to i64
  %.sroa.22.0.extract.shift = lshr i128 %.decomposed, 64
  %.sroa.22.0.extract.trunc = trunc nuw i128 %.sroa.22.0.extract.shift to i64
  %27 = tail call noundef { i64, i64 } @_Z9floor_sumnnnn(i64 noundef %.sroa.05.0.extract.trunc, i64 noundef %.sroa.26.0.extract.trunc, i64 noundef %4, i64 noundef %5, i64 noundef %.sroa.01.0.extract.trunc, i64 noundef %.sroa.22.0.extract.trunc, i128 noundef %22)
  %28 = extractvalue { i64, i64 } %27, 0
  %29 = extractvalue { i64, i64 } %27, 1
  %.sroa.0.0.insert.ext = zext i64 %28 to i128
  %.sroa.0.0.insert.insert.neg = add i128 %24, %15
  %30 = sub i128 %.sroa.0.0.insert.insert.neg, %.sroa.0.0.insert.ext
  %.sroa.040.0.extract.trunc41 = trunc i128 %30 to i64
  %31 = lshr i128 %30, 64
  %.tr = trunc nuw i128 %31 to i64
  %.narrow = sub i64 %.tr, %29
  br label %32

32:                                               ; preds = %18, %17
  %.sroa.040.0 = phi i64 [ %.sroa.040.0.extract.trunc41, %18 ], [ %.sroa.040.0.extract.trunc, %17 ]
  %.sroa.3.0 = phi i64 [ %.narrow, %18 ], [ %.sroa.3.0.extract.trunc, %17 ]
  %.fca.0.insert = insertvalue { i64, i64 } poison, i64 %.sroa.040.0, 0
  %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %.sroa.3.0, 1
  ret { i64, i64 } %.fca.1.insert
}

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

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


; Effective O3 passes: DivRemPairsPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass