; LLVM IR from ritikbanger/Hacktoberfest2022-DSA :: 01. Mathematics/20_Linear_Diophantine_with_two_variables.ll (Z17find_any_solutionxxxRxS_S_)

; 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 nounwind uwtable
declare dso_local noundef i64 @_Z15extended_euclidxxRxS_(i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z17find_any_solutionxxxRxS_S_(i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #1 {
  %7 = alloca i1, align 1
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store i64 %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  %14 = load i64, ptr %8, align 8, !tbaa !5
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %27

16:                                               ; preds = %6
  %17 = load i64, ptr %9, align 8, !tbaa !5
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %27

19:                                               ; preds = %16
  %20 = load i64, ptr %10, align 8, !tbaa !5
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store i1 false, ptr %7, align 1
  br label %71

23:                                               ; preds = %19
  %24 = load ptr, ptr %13, align 8, !tbaa !9
  store i64 0, ptr %24, align 8, !tbaa !5
  %25 = load ptr, ptr %12, align 8, !tbaa !9
  store i64 0, ptr %25, align 8, !tbaa !5
  %26 = load ptr, ptr %11, align 8, !tbaa !9
  store i64 0, ptr %26, align 8, !tbaa !5
  store i1 true, ptr %7, align 1
  br label %71

27:                                               ; preds = %16, %6
  %28 = load i64, ptr %8, align 8, !tbaa !5
  %29 = call noundef i64 @_ZSt3absx(i64 noundef %28)
  %30 = load i64, ptr %9, align 8, !tbaa !5
  %31 = call noundef i64 @_ZSt3absx(i64 noundef %30)
  %32 = load ptr, ptr %11, align 8, !tbaa !9
  %33 = load ptr, ptr %12, align 8, !tbaa !9
  %34 = call noundef i64 @_Z15extended_euclidxxRxS_(i64 noundef %29, i64 noundef %31, ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef nonnull align 8 dereferenceable(8) %33)
  %35 = load ptr, ptr %13, align 8, !tbaa !9
  store i64 %34, ptr %35, align 8, !tbaa !5
  %36 = load i64, ptr %10, align 8, !tbaa !5
  %37 = load ptr, ptr %13, align 8, !tbaa !9
  %38 = load i64, ptr %37, align 8, !tbaa !5
  %39 = srem i64 %36, %38
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %27
  store i1 false, ptr %7, align 1
  br label %71

42:                                               ; preds = %27
  %43 = load i64, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !9
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = sdiv i64 %43, %45
  %47 = load ptr, ptr %11, align 8, !tbaa !9
  %48 = load i64, ptr %47, align 8, !tbaa !5
  %49 = mul nsw i64 %48, %46
  store i64 %49, ptr %47, align 8, !tbaa !5
  %50 = load i64, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %13, align 8, !tbaa !9
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %53 = sdiv i64 %50, %52
  %54 = load ptr, ptr %12, align 8, !tbaa !9
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = mul nsw i64 %55, %53
  store i64 %56, ptr %54, align 8, !tbaa !5
  %57 = load i64, ptr %8, align 8, !tbaa !5
  %58 = icmp slt i64 %57, 0
  br i1 %58, label %59, label %63

59:                                               ; preds = %42
  %60 = load ptr, ptr %11, align 8, !tbaa !9
  %61 = load i64, ptr %60, align 8, !tbaa !5
  %62 = mul nsw i64 %61, -1
  store i64 %62, ptr %60, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %59, %42
  %64 = load i64, ptr %9, align 8, !tbaa !5
  %65 = icmp slt i64 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %63
  %67 = load ptr, ptr %12, align 8, !tbaa !9
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = mul nsw i64 %68, -1
  store i64 %69, ptr %67, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %66, %63
  store i1 true, ptr %7, align 1
  br label %71

71:                                               ; preds = %70, %41, %23, %22
  %72 = load i1, ptr %7, align 1
  ret i1 %72
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) #2

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" }
attributes #1 = { 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 #2 = { inlinehint 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; 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 @_Z15extended_euclidxxRxS_(i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z17find_any_solutionxxxRxS_S_(i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr nocapture noundef nonnull align 8 dereferenceable(8) %5) local_unnamed_addr #0 {
  %7 = or i64 %1, %0
  %or.cond = icmp eq i64 %7, 0
  br i1 %or.cond, label %8, label %10

8:                                                ; preds = %6
  %.not24 = icmp eq i64 %2, 0
  br i1 %.not24, label %9, label %32

9:                                                ; preds = %8
  store i64 0, ptr %5, align 8, !tbaa !5
  store i64 0, ptr %4, align 8, !tbaa !5
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %32

10:                                               ; preds = %6
  %11 = tail call noundef i64 @_ZSt3absx(i64 noundef %0)
  %12 = tail call noundef i64 @_ZSt3absx(i64 noundef %1)
  %13 = tail call noundef i64 @_Z15extended_euclidxxRxS_(i64 noundef %11, i64 noundef %12, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  store i64 %13, ptr %5, align 8, !tbaa !5
  %14 = srem i64 %2, %13
  %15 = sdiv i64 %2, %13
  %.not = icmp eq i64 %14, 0
  br i1 %.not, label %16, label %32

16:                                               ; preds = %10
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = mul nsw i64 %17, %15
  store i64 %18, ptr %3, align 8, !tbaa !5
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %20 = sdiv i64 %2, %19
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = mul nsw i64 %21, %20
  store i64 %22, ptr %4, align 8, !tbaa !5
  %23 = icmp slt i64 %0, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %16
  %25 = load i64, ptr %3, align 8, !tbaa !5
  %26 = sub nsw i64 0, %25
  store i64 %26, ptr %3, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %24, %16
  %28 = icmp slt i64 %1, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %27
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = sub nsw i64 0, %30
  store i64 %31, ptr %4, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %27, %29, %10, %8, %9
  %.0 = phi i1 [ true, %9 ], [ false, %8 ], [ false, %10 ], [ true, %29 ], [ true, %27 ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) local_unnamed_addr #1

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" }
attributes #1 = { inlinehint 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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