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

; 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: mustprogress uwtable
declare dso_local noundef { i64, i64 } @_Z15extended_euclidnnRnS_(i64 noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) #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

; Function Attrs: mustprogress uwtable
define dso_local noundef { i64, i64 } @_Z7inversenn(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) #0 {
  %5 = alloca i128, align 16
  %6 = alloca i128, align 16
  %7 = alloca i128, align 16
  %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 i32, align 4
  %17 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 0
  store i64 %0, ptr %17, align 16
  %18 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 1
  store i64 %1, ptr %18, align 8
  %19 = load i128, ptr %6, align 16, !tbaa !5
  %20 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  store i64 %2, ptr %20, align 16
  %21 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  store i64 %3, ptr %21, align 8
  %22 = load i128, ptr %7, align 16, !tbaa !5
  store i128 %19, ptr %8, align 16, !tbaa !5
  store i128 %22, ptr %9, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #2
  %23 = load i128, ptr %8, align 16, !tbaa !5
  %24 = load i128, ptr %9, align 16, !tbaa !5
  store i128 %23, ptr %13, align 16, !tbaa !5
  %25 = getelementptr inbounds { i64, i64 }, ptr %13, i32 0, i32 0
  %26 = load i64, ptr %25, align 16
  %27 = getelementptr inbounds { i64, i64 }, ptr %13, i32 0, i32 1
  %28 = load i64, ptr %27, align 8
  store i128 %24, ptr %14, align 16, !tbaa !5
  %29 = getelementptr inbounds { i64, i64 }, ptr %14, i32 0, i32 0
  %30 = load i64, ptr %29, align 16
  %31 = getelementptr inbounds { i64, i64 }, ptr %14, i32 0, i32 1
  %32 = load i64, ptr %31, align 8
  %33 = call noundef { i64, i64 } @_Z15extended_euclidnnRnS_(i64 noundef %26, i64 noundef %28, i64 noundef %30, i64 noundef %32, ptr noundef nonnull align 16 dereferenceable(16) %10, ptr noundef nonnull align 16 dereferenceable(16) %11)
  %34 = getelementptr inbounds { i64, i64 }, ptr %15, i32 0, i32 0
  %35 = extractvalue { i64, i64 } %33, 0
  store i64 %35, ptr %34, align 16
  %36 = getelementptr inbounds { i64, i64 }, ptr %15, i32 0, i32 1
  %37 = extractvalue { i64, i64 } %33, 1
  store i64 %37, ptr %36, align 8
  %38 = load i128, ptr %15, align 16, !tbaa !5
  store i128 %38, ptr %12, align 16, !tbaa !5
  %39 = load i128, ptr %12, align 16, !tbaa !5
  %40 = icmp ne i128 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %4
  store i128 -1, ptr %5, align 16
  store i32 1, ptr %16, align 4
  br label %50

42:                                               ; preds = %4
  %43 = load i128, ptr %10, align 16, !tbaa !5
  %44 = load i128, ptr %9, align 16, !tbaa !5
  %45 = srem i128 %43, %44
  %46 = load i128, ptr %9, align 16, !tbaa !5
  %47 = add nsw i128 %45, %46
  %48 = load i128, ptr %9, align 16, !tbaa !5
  %49 = srem i128 %47, %48
  store i128 %49, ptr %5, align 16
  store i32 1, ptr %16, align 4
  br label %50

50:                                               ; preds = %42, %41
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #2
  %51 = load { i64, i64 }, ptr %5, align 16
  ret { i64, i64 } %51
}

attributes #0 = { 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 #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 = !{!"__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 uwtable
declare dso_local noundef { i64, i64 } @_Z15extended_euclidnnRnS_(i64 noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef { i64, i64 } @_Z7inversenn(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i128, align 16
  %6 = alloca i128, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #2
  %7 = call noundef { i64, i64 } @_Z15extended_euclidnnRnS_(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 16 dereferenceable(16) %6)
  %8 = extractvalue { i64, i64 } %7, 0
  %9 = extractvalue { i64, i64 } %7, 1
  %.sroa.2.0.insert.ext = zext i64 %9 to i128
  %.sroa.2.0.insert.shift = shl nuw i128 %.sroa.2.0.insert.ext, 64
  %.sroa.0.0.insert.ext = zext i64 %8 to i128
  %.sroa.0.0.insert.insert = or disjoint i128 %.sroa.2.0.insert.shift, %.sroa.0.0.insert.ext
  %.not = icmp eq i128 %.sroa.0.0.insert.insert, 1
  br i1 %.not, label %10, label %15

10:                                               ; preds = %4
  %.sroa.211.0.insert.ext = zext i64 %3 to i128
  %.sroa.211.0.insert.shift = shl nuw i128 %.sroa.211.0.insert.ext, 64
  %.sroa.010.0.insert.ext = zext i64 %2 to i128
  %.sroa.010.0.insert.insert = or disjoint i128 %.sroa.211.0.insert.shift, %.sroa.010.0.insert.ext
  %11 = load i128, ptr %5, align 16, !tbaa !5
  %12 = srem i128 %11, %.sroa.010.0.insert.insert
  %13 = add nsw i128 %12, %.sroa.010.0.insert.insert
  %14 = srem i128 %13, %.sroa.010.0.insert.insert
  %.sroa.014.0.extract.trunc = trunc i128 %14 to i64
  %.sroa.3.0.extract.shift = lshr i128 %14, 64
  %.sroa.3.0.extract.trunc = trunc nuw i128 %.sroa.3.0.extract.shift to i64
  br label %15

15:                                               ; preds = %4, %10
  %.sroa.014.0 = phi i64 [ %.sroa.014.0.extract.trunc, %10 ], [ -1, %4 ]
  %.sroa.3.0 = phi i64 [ %.sroa.3.0.extract.trunc, %10 ], [ -1, %4 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  %.fca.0.insert = insertvalue { i64, i64 } poison, i64 %.sroa.014.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 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 = { mustprogress 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 = !{!"__int128", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass