; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd/730.ll (Z5solveii)

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

@tot = external dso_local global i32, align 4
@ans = external dso_local global [6 x [2 x i32]], align 16
@_ZL5prime = external hidden constant [25 x i32], align 16

; 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 zeroext i1 @_Z4calciii(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5solveii(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %22, %2
  %9 = load i32, ptr %6, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 25
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %7, align 4
  br label %25

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [25 x i32], ptr @_ZL5prime, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = call noundef zeroext i1 @_Z4calciii(i32 noundef %13, i32 noundef %14, i32 noundef %18)
  br i1 %19, label %21, label %20

20:                                               ; preds = %12
  store i32 1, ptr %5, align 4, !tbaa !5
  store i32 2, ptr %7, align 4
  br label %25

21:                                               ; preds = %12
  br label %22

22:                                               ; preds = %21
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %6, align 4, !tbaa !5
  br label %8, !llvm.loop !9

25:                                               ; preds = %20, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %26

26:                                               ; preds = %25
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %42, label %29

29:                                               ; preds = %26
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [6 x [2 x i32]], ptr @ans, i64 0, i64 %32
  %34 = getelementptr inbounds [2 x i32], ptr %33, i64 0, i64 0
  store i32 %30, ptr %34, align 8, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = load i32, ptr @tot, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [6 x [2 x i32]], ptr @ans, i64 0, i64 %37
  %39 = getelementptr inbounds [2 x i32], ptr %38, i64 0, i64 1
  store i32 %35, ptr %39, align 4, !tbaa !5
  %40 = load i32, ptr @tot, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr @tot, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %29, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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 = { 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 = distinct !{!9, !10}
!10 = !{!"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"

@tot = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global [6 x [2 x i32]], align 16
@_ZL5prime = external hidden local_unnamed_addr constant [25 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z4calciii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5solveii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr @_ZL5prime, align 16, !tbaa !5
  %4 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %3)
  br i1 %4, label %5, label %.loopexit

5:                                                ; preds = %2
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 4), align 4, !tbaa !5
  %7 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %6)
  br i1 %7, label %8, label %.loopexit

8:                                                ; preds = %5
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 8), align 8, !tbaa !5
  %10 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %9)
  br i1 %10, label %11, label %.loopexit

11:                                               ; preds = %8
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 12), align 4, !tbaa !5
  %13 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %12)
  br i1 %13, label %14, label %.loopexit

14:                                               ; preds = %11
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 16), align 16, !tbaa !5
  %16 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %15)
  br i1 %16, label %17, label %.loopexit

17:                                               ; preds = %14
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 20), align 4, !tbaa !5
  %19 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %18)
  br i1 %19, label %20, label %.loopexit

20:                                               ; preds = %17
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 24), align 8, !tbaa !5
  %22 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %21)
  br i1 %22, label %23, label %.loopexit

23:                                               ; preds = %20
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 28), align 4, !tbaa !5
  %25 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %24)
  br i1 %25, label %26, label %.loopexit

26:                                               ; preds = %23
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 32), align 16, !tbaa !5
  %28 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %27)
  br i1 %28, label %29, label %.loopexit

29:                                               ; preds = %26
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 36), align 4, !tbaa !5
  %31 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %30)
  br i1 %31, label %32, label %.loopexit

32:                                               ; preds = %29
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 40), align 8, !tbaa !5
  %34 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %33)
  br i1 %34, label %35, label %.loopexit

35:                                               ; preds = %32
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 44), align 4, !tbaa !5
  %37 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %36)
  br i1 %37, label %38, label %.loopexit

38:                                               ; preds = %35
  %39 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 48), align 16, !tbaa !5
  %40 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %39)
  br i1 %40, label %41, label %.loopexit

41:                                               ; preds = %38
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 52), align 4, !tbaa !5
  %43 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %42)
  br i1 %43, label %44, label %.loopexit

44:                                               ; preds = %41
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 56), align 8, !tbaa !5
  %46 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %45)
  br i1 %46, label %47, label %.loopexit

47:                                               ; preds = %44
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 60), align 4, !tbaa !5
  %49 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %48)
  br i1 %49, label %50, label %.loopexit

50:                                               ; preds = %47
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 64), align 16, !tbaa !5
  %52 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %51)
  br i1 %52, label %53, label %.loopexit

53:                                               ; preds = %50
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 68), align 4, !tbaa !5
  %55 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %54)
  br i1 %55, label %56, label %.loopexit

56:                                               ; preds = %53
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 72), align 8, !tbaa !5
  %58 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %57)
  br i1 %58, label %59, label %.loopexit

59:                                               ; preds = %56
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 76), align 4, !tbaa !5
  %61 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %60)
  br i1 %61, label %62, label %.loopexit

62:                                               ; preds = %59
  %63 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 80), align 16, !tbaa !5
  %64 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %63)
  br i1 %64, label %65, label %.loopexit

65:                                               ; preds = %62
  %66 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 84), align 4, !tbaa !5
  %67 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %66)
  br i1 %67, label %68, label %.loopexit

68:                                               ; preds = %65
  %69 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 88), align 8, !tbaa !5
  %70 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %69)
  br i1 %70, label %71, label %.loopexit

71:                                               ; preds = %68
  %72 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 92), align 4, !tbaa !5
  %73 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %72)
  br i1 %73, label %74, label %.loopexit

74:                                               ; preds = %71
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL5prime, i64 96), align 16, !tbaa !5
  %76 = tail call noundef zeroext i1 @_Z4calciii(i32 noundef %0, i32 noundef %1, i32 noundef %75)
  br i1 %76, label %.critedge, label %.loopexit

.critedge:                                        ; preds = %74
  %77 = load i32, ptr @tot, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [6 x [2 x i32]], ptr @ans, i64 0, i64 %78
  store i32 %0, ptr %79, align 8, !tbaa !5
  %80 = getelementptr inbounds [6 x [2 x i32]], ptr @ans, i64 0, i64 %78, i64 1
  store i32 %1, ptr %80, align 4, !tbaa !5
  %81 = add nsw i32 %77, 1
  store i32 %81, ptr @tot, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %2, %5, %8, %11, %14, %17, %20, %23, %26, %29, %32, %35, %38, %41, %44, %47, %50, %53, %56, %59, %62, %65, %68, %71, %74, %.critedge
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass