; LLVM IR from hao14293/2021-Postgraduate-408 :: PAT/PAT-B/CPP/1034.有理数四则运算.ll (Z4funcxx)

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3gcdxx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4funcxx(i64 noundef %0, i64 noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  %14 = load i64, ptr %4, align 8, !tbaa !5
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 1, ptr %8, align 4
  br label %129

18:                                               ; preds = %2
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  store i32 1, ptr %8, align 4
  br label %129

23:                                               ; preds = %18
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = icmp slt i64 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %26, %23
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = icmp slt i64 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %30, %27
  %32 = load i64, ptr %3, align 8, !tbaa !5
  %33 = call noundef i64 @_ZSt3absx(i64 noundef %32)
  store i64 %33, ptr %3, align 8, !tbaa !5
  %34 = load i64, ptr %4, align 8, !tbaa !5
  %35 = call noundef i64 @_ZSt3absx(i64 noundef %34)
  store i64 %35, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %42

38:                                               ; preds = %31
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %50

42:                                               ; preds = %38, %31
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %48, label %45

45:                                               ; preds = %42
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %49

48:                                               ; preds = %45, %42
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %48, %45
  br label %50

50:                                               ; preds = %49, %41
  %51 = load i64, ptr %3, align 8, !tbaa !5
  %52 = load i64, ptr %4, align 8, !tbaa !5
  %53 = icmp eq i64 %51, %52
  br i1 %53, label %54, label %62

54:                                               ; preds = %50
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 1
  br i1 %56, label %57, label %59

57:                                               ; preds = %54
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %61

59:                                               ; preds = %54
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %61

61:                                               ; preds = %59, %57
  store i32 1, ptr %8, align 4
  br label %129

62:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %63 = load i64, ptr %3, align 8, !tbaa !5
  %64 = load i64, ptr %4, align 8, !tbaa !5
  %65 = srem i64 %63, %64
  store i64 %65, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %66 = load i64, ptr %3, align 8, !tbaa !5
  %67 = load i64, ptr %4, align 8, !tbaa !5
  %68 = sdiv i64 %66, %67
  store i64 %68, ptr %10, align 8, !tbaa !5
  %69 = load i64, ptr %9, align 8, !tbaa !5
  %70 = icmp eq i64 %69, 0
  br i1 %70, label %71, label %81

71:                                               ; preds = %62
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %77

74:                                               ; preds = %71
  %75 = load i64, ptr %10, align 8, !tbaa !5
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %75)
  br label %80

77:                                               ; preds = %71
  %78 = load i64, ptr %10, align 8, !tbaa !5
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i64 noundef %78)
  br label %80

80:                                               ; preds = %77, %74
  store i32 1, ptr %8, align 4
  br label %128

81:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %82 = load i64, ptr %3, align 8, !tbaa !5
  %83 = load i64, ptr %10, align 8, !tbaa !5
  %84 = load i64, ptr %4, align 8, !tbaa !5
  %85 = mul nsw i64 %83, %84
  %86 = sub nsw i64 %82, %85
  store i64 %86, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %87 = load i64, ptr %4, align 8, !tbaa !5
  store i64 %87, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %88 = load i64, ptr %11, align 8, !tbaa !5
  %89 = load i64, ptr %12, align 8, !tbaa !5
  %90 = call noundef i64 @_Z3gcdxx(i64 noundef %88, i64 noundef %89)
  store i64 %90, ptr %13, align 8, !tbaa !5
  %91 = load i64, ptr %11, align 8, !tbaa !5
  %92 = load i64, ptr %13, align 8, !tbaa !5
  %93 = sdiv i64 %91, %92
  store i64 %93, ptr %11, align 8, !tbaa !5
  %94 = load i64, ptr %12, align 8, !tbaa !5
  %95 = load i64, ptr %13, align 8, !tbaa !5
  %96 = sdiv i64 %94, %95
  store i64 %96, ptr %12, align 8, !tbaa !5
  %97 = load i32, ptr %7, align 4, !tbaa !9
  %98 = icmp eq i32 %97, 1
  br i1 %98, label %99, label %113

99:                                               ; preds = %81
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %101 = load i64, ptr %10, align 8, !tbaa !5
  %102 = icmp ne i64 %101, 0
  br i1 %102, label %103, label %108

103:                                              ; preds = %99
  %104 = load i64, ptr %10, align 8, !tbaa !5
  %105 = load i64, ptr %11, align 8, !tbaa !5
  %106 = load i64, ptr %12, align 8, !tbaa !5
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i64 noundef %104, i64 noundef %105, i64 noundef %106)
  br label %112

108:                                              ; preds = %99
  %109 = load i64, ptr %11, align 8, !tbaa !5
  %110 = load i64, ptr %12, align 8, !tbaa !5
  %111 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i64 noundef %109, i64 noundef %110)
  br label %112

112:                                              ; preds = %108, %103
  br label %126

113:                                              ; preds = %81
  %114 = load i64, ptr %10, align 8, !tbaa !5
  %115 = icmp ne i64 %114, 0
  br i1 %115, label %116, label %121

116:                                              ; preds = %113
  %117 = load i64, ptr %10, align 8, !tbaa !5
  %118 = load i64, ptr %11, align 8, !tbaa !5
  %119 = load i64, ptr %12, align 8, !tbaa !5
  %120 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i64 noundef %117, i64 noundef %118, i64 noundef %119)
  br label %125

121:                                              ; preds = %113
  %122 = load i64, ptr %11, align 8, !tbaa !5
  %123 = load i64, ptr %12, align 8, !tbaa !5
  %124 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, i64 noundef %122, i64 noundef %123)
  br label %125

125:                                              ; preds = %121, %116
  br label %126

126:                                              ; preds = %125, %112
  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
  br label %127

127:                                              ; preds = %126
  store i32 0, ptr %8, align 4
  br label %128

128:                                              ; preds = %127, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %129

129:                                              ; preds = %128, %61, %21, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %130 = load i32, ptr %8, align 4
  switch i32 %130, label %132 [
    i32 0, label %131
    i32 1, label %131
  ]

131:                                              ; preds = %129, %129
  ret void

132:                                              ; preds = %129
  unreachable
}

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

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

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

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

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 = { "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 = { 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" }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3gcdxx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4funcxx(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq i64 %1, 0
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %45

6:                                                ; preds = %2
  %7 = icmp eq i64 %0, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %6
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %45

10:                                               ; preds = %6
  %11 = tail call noundef i64 @_ZSt3absx(i64 noundef %0)
  %12 = tail call noundef i64 @_ZSt3absx(i64 noundef %1)
  %13 = xor i64 %1, %0
  %or.cond = icmp slt i64 %13, 0
  %14 = icmp eq i64 %11, %12
  br i1 %14, label %15, label %20

15:                                               ; preds = %10
  br i1 %or.cond, label %16, label %18

16:                                               ; preds = %15
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %45

18:                                               ; preds = %15
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %45

20:                                               ; preds = %10
  %21 = srem i64 %11, %12
  %22 = sdiv i64 %11, %12
  %.recomposed = srem i64 %11, %12
  %23 = icmp eq i64 %21, 0
  br i1 %23, label %24, label %29

24:                                               ; preds = %20
  br i1 %or.cond, label %27, label %25

25:                                               ; preds = %24
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %22)
  br label %45

27:                                               ; preds = %24
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i64 noundef %22)
  br label %45

29:                                               ; preds = %20
  %30 = mul nsw i64 %22, %12
  %31 = tail call noundef i64 @_Z3gcdxx(i64 noundef %.recomposed, i64 noundef %12)
  %32 = sdiv i64 %.recomposed, %31
  %33 = sdiv i64 %12, %31
  br i1 %or.cond, label %34, label %40

34:                                               ; preds = %29
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %.not54 = icmp eq i64 %22, 0
  br i1 %.not54, label %38, label %36

36:                                               ; preds = %34
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i64 noundef %22, i64 noundef %32, i64 noundef %33)
  br label %45

38:                                               ; preds = %34
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i64 noundef %32, i64 noundef %33)
  br label %45

40:                                               ; preds = %29
  %.not = icmp eq i64 %22, 0
  br i1 %.not, label %43, label %41

41:                                               ; preds = %40
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i64 noundef %22, i64 noundef %32, i64 noundef %33)
  br label %45

43:                                               ; preds = %40
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, i64 noundef %32, i64 noundef %33)
  br label %45

45:                                               ; preds = %27, %25, %41, %43, %36, %38, %16, %18, %8, %4
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) local_unnamed_addr #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 = { 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 #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)"}


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