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

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

@all = external dso_local global [40 x i32], align 16
@wan = external dso_local global [40 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
define dso_local noundef zeroext i1 @_Z9sevenpairv() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %32, %0
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 34
  br i1 %5, label %6, label %9

6:                                                ; preds = %3
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 7
  br label %9

9:                                                ; preds = %6, %3
  %10 = phi i1 [ false, %3 ], [ %8, %6 ]
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %9
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = icmp sge i32 %16, 2
  br i1 %17, label %18, label %31

18:                                               ; preds = %12
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sub nsw i32 %22, 2
  store i32 %23, ptr %21, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [40 x i32], ptr @wan, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add nsw i32 %27, 2
  store i32 %28, ptr %26, align 4, !tbaa !5
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %1, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %18, %12
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %3, !llvm.loop !9

35:                                               ; preds = %11
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = icmp eq i32 %36, 7
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret i1 true

39:                                               ; preds = %35
  unreachable
}

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"

@all = external dso_local local_unnamed_addr global [40 x i32], align 16
@wan = external dso_local local_unnamed_addr global [40 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: write) uwtable
define dso_local noundef zeroext i1 @_Z9sevenpairv() local_unnamed_addr #0 {
  br label %3

1:                                                ; preds = %13
  %2 = icmp eq i32 %.1, 7
  tail call void @llvm.assume(i1 %2)
  ret i1 true

3:                                                ; preds = %0, %13
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %13 ]
  %.0810 = phi i32 [ 0, %0 ], [ %.1, %13 ]
  %4 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %indvars.iv
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 1
  br i1 %6, label %7, label %13

7:                                                ; preds = %3
  %8 = add nsw i32 %5, -2
  store i32 %8, ptr %4, align 4, !tbaa !5
  %9 = getelementptr inbounds [40 x i32], ptr @wan, i64 0, i64 %indvars.iv
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = add nsw i32 %10, 2
  store i32 %11, ptr %9, align 4, !tbaa !5
  %12 = add nsw i32 %.0810, 1
  br label %13

13:                                               ; preds = %3, %7
  %.1 = phi i32 [ %12, %7 ], [ %.0810, %3 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = icmp ult i64 %indvars.iv, 33
  %15 = icmp slt i32 %.1, 7
  %16 = select i1 %14, i1 %15, i1 false
  br i1 %16, label %3, label %1, !llvm.loop !9
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: write) 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(inaccessiblemem: write) }

!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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass