; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数学算法 (二元一次不定方程)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3gcdxxRxS_S_(i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %15

15:                                               ; preds = %119, %117, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = icmp ne i32 %16, 0
  br i1 %18, label %19, label %120

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %21 = load i64, ptr %3, align 8, !tbaa !9
  %22 = load i64, ptr %4, align 8, !tbaa !9
  call void @_Z3gcdxxRxS_S_(i64 noundef %21, i64 noundef %22, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = srem i64 %23, %24
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %19
  %28 = call i32 @puts(ptr noundef @.str.2)
  store i32 2, ptr %9, align 4
  br label %117, !llvm.loop !11

29:                                               ; preds = %19
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = mul nsw i64 %30, %31
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = sdiv i64 %32, %33
  store i64 %34, ptr %7, align 8, !tbaa !9
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = mul nsw i64 %35, %36
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = sdiv i64 %37, %38
  store i64 %39, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %40 = load i64, ptr %4, align 8, !tbaa !9
  %41 = load i64, ptr %6, align 8, !tbaa !9
  %42 = sdiv i64 %40, %41
  store i64 %42, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %43 = load i64, ptr %3, align 8, !tbaa !9
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = sdiv i64 %43, %44
  store i64 %45, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = icmp sgt i64 %46, 0
  br i1 %47, label %48, label %53

48:                                               ; preds = %29
  %49 = load i64, ptr %7, align 8, !tbaa !9
  %50 = sub nsw i64 1, %49
  %51 = load i64, ptr %10, align 8, !tbaa !9
  %52 = sdiv i64 %50, %51
  br label %59

53:                                               ; preds = %29
  %54 = load i64, ptr %7, align 8, !tbaa !9
  %55 = sub nsw i64 0, %54
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = sdiv i64 %55, %56
  %58 = add nsw i64 %57, 1
  br label %59

59:                                               ; preds = %53, %48
  %60 = phi i64 [ %52, %48 ], [ %58, %53 ]
  store i64 %60, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %61 = load i64, ptr %8, align 8, !tbaa !9
  %62 = icmp sgt i64 %61, 0
  br i1 %62, label %63, label %68

63:                                               ; preds = %59
  %64 = load i64, ptr %8, align 8, !tbaa !9
  %65 = sub nsw i64 %64, 1
  %66 = load i64, ptr %11, align 8, !tbaa !9
  %67 = sdiv i64 %65, %66
  br label %73

68:                                               ; preds = %59
  %69 = load i64, ptr %8, align 8, !tbaa !9
  %70 = load i64, ptr %11, align 8, !tbaa !9
  %71 = sdiv i64 %69, %70
  %72 = sub nsw i64 %71, 1
  br label %73

73:                                               ; preds = %68, %63
  %74 = phi i64 [ %67, %63 ], [ %72, %68 ]
  store i64 %74, ptr %13, align 8, !tbaa !9
  %75 = load i64, ptr %12, align 8, !tbaa !9
  %76 = load i64, ptr %13, align 8, !tbaa !9
  %77 = icmp sle i64 %75, %76
  br i1 %77, label %78, label %104

78:                                               ; preds = %73
  %79 = load i64, ptr %13, align 8, !tbaa !9
  %80 = load i64, ptr %12, align 8, !tbaa !9
  %81 = sub nsw i64 %79, %80
  %82 = add nsw i64 %81, 1
  %83 = load i64, ptr %7, align 8, !tbaa !9
  %84 = load i64, ptr %12, align 8, !tbaa !9
  %85 = load i64, ptr %10, align 8, !tbaa !9
  %86 = mul nsw i64 %84, %85
  %87 = add nsw i64 %83, %86
  %88 = load i64, ptr %8, align 8, !tbaa !9
  %89 = load i64, ptr %13, align 8, !tbaa !9
  %90 = load i64, ptr %11, align 8, !tbaa !9
  %91 = mul nsw i64 %89, %90
  %92 = sub nsw i64 %88, %91
  %93 = load i64, ptr %7, align 8, !tbaa !9
  %94 = load i64, ptr %13, align 8, !tbaa !9
  %95 = load i64, ptr %10, align 8, !tbaa !9
  %96 = mul nsw i64 %94, %95
  %97 = add nsw i64 %93, %96
  %98 = load i64, ptr %8, align 8, !tbaa !9
  %99 = load i64, ptr %12, align 8, !tbaa !9
  %100 = load i64, ptr %11, align 8, !tbaa !9
  %101 = mul nsw i64 %99, %100
  %102 = sub nsw i64 %98, %101
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %82, i64 noundef %87, i64 noundef %92, i64 noundef %97, i64 noundef %102)
  br label %116

104:                                              ; preds = %73
  %105 = load i64, ptr %7, align 8, !tbaa !9
  %106 = load i64, ptr %12, align 8, !tbaa !9
  %107 = load i64, ptr %10, align 8, !tbaa !9
  %108 = mul nsw i64 %106, %107
  %109 = add nsw i64 %105, %108
  %110 = load i64, ptr %8, align 8, !tbaa !9
  %111 = load i64, ptr %13, align 8, !tbaa !9
  %112 = load i64, ptr %11, align 8, !tbaa !9
  %113 = mul nsw i64 %111, %112
  %114 = sub nsw i64 %110, %113
  %115 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %109, i64 noundef %114)
  br label %116

116:                                              ; preds = %104, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  store i32 0, ptr %9, align 4
  br label %117

117:                                              ; preds = %116, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  %118 = load i32, ptr %9, align 4
  switch i32 %118, label %122 [
    i32 0, label %119
    i32 2, label %15
  ]

119:                                              ; preds = %117
  br label %15, !llvm.loop !11

120:                                              ; preds = %15
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %121 = load i32, ptr %1, align 4
  ret i32 %121

122:                                              ; preds = %117
  unreachable
}

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

declare i32 @puts(ptr noundef) #3

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

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

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


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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3gcdxxRxS_S_(i64 noundef, i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr %1, align 4, !tbaa !5
  %.not29 = icmp eq i32 %9, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %65
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %12 = load i64, ptr %2, align 8, !tbaa !9
  %13 = load i64, ptr %3, align 8, !tbaa !9
  call void @_Z3gcdxxRxS_S_(i64 noundef %12, i64 noundef %13, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %14 = load i64, ptr %4, align 8, !tbaa !9
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = srem i64 %14, %15
  %.not27 = icmp eq i64 %16, 0
  br i1 %.not27, label %19, label %17

17:                                               ; preds = %.lr.ph
  %18 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %65, !llvm.loop !11

19:                                               ; preds = %.lr.ph
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = mul nsw i64 %20, %14
  %22 = sdiv i64 %21, %15
  store i64 %22, ptr %6, align 8, !tbaa !9
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = mul nsw i64 %23, %14
  %25 = sdiv i64 %24, %15
  store i64 %25, ptr %7, align 8, !tbaa !9
  %26 = load i64, ptr %3, align 8, !tbaa !9
  %27 = sdiv i64 %26, %15
  %28 = load i64, ptr %2, align 8, !tbaa !9
  %29 = sdiv i64 %28, %15
  %30 = icmp sgt i64 %22, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %19
  %32 = sub nsw i64 1, %22
  %33 = sdiv i64 %32, %27
  br label %37

34:                                               ; preds = %19
  %35 = sdiv i64 %22, %27
  %36 = sub i64 1, %35
  br label %37

37:                                               ; preds = %34, %31
  %38 = phi i64 [ %33, %31 ], [ %36, %34 ]
  %39 = icmp sgt i64 %25, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = add nsw i64 %25, -1
  %42 = sdiv i64 %41, %29
  br label %46

43:                                               ; preds = %37
  %44 = sdiv i64 %25, %29
  %45 = add nsw i64 %44, -1
  br label %46

46:                                               ; preds = %43, %40
  %47 = phi i64 [ %42, %40 ], [ %45, %43 ]
  %.not28 = icmp sgt i64 %38, %47
  br i1 %.not28, label %59, label %48

48:                                               ; preds = %46
  %reass.sub = sub i64 %47, %38
  %49 = add i64 %reass.sub, 1
  %50 = mul nsw i64 %38, %27
  %51 = add nsw i64 %50, %22
  %52 = mul nsw i64 %47, %29
  %53 = sub nsw i64 %25, %52
  %54 = mul nsw i64 %47, %27
  %55 = add nsw i64 %54, %22
  %56 = mul nsw i64 %38, %29
  %57 = sub nsw i64 %25, %56
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %49, i64 noundef %51, i64 noundef %53, i64 noundef %55, i64 noundef %57)
  br label %65

59:                                               ; preds = %46
  %60 = mul nsw i64 %38, %27
  %61 = add nsw i64 %60, %22
  %62 = mul nsw i64 %47, %29
  %63 = sub nsw i64 %25, %62
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %61, i64 noundef %63)
  br label %65

65:                                               ; preds = %48, %59, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  %66 = load i32, ptr %1, align 4, !tbaa !5
  %67 = add nsw i32 %66, -1
  store i32 %67, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %66, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %65, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

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

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

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass