; LLVM IR from tangjz/acm-icpc :: poj/1390.ll (Z1Fiii)

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

@c = external dso_local global [201 x i32], align 16
@pre = external dso_local global [201 x i32], align 16
@Case = external dso_local global i32, align 4
@tim = external dso_local global [8120601 x i32], align 16
@f = external dso_local global [8120601 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z1Fiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = icmp sgt i32 %12, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  br label %89

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = call noundef i32 @_Z3idxiii(i32 noundef %17, i32 noundef %18, i32 noundef %19)
  store i32 %20, ptr %8, align 4, !tbaa !5
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [8120601 x i32], ptr @tim, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr @Case, align 4, !tbaa !5
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %16
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [8120601 x i32], ptr @f, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  store i32 %31, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %88

32:                                               ; preds = %16
  %33 = load i32, ptr @Case, align 4, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [8120601 x i32], ptr @tim, i64 0, i64 %35
  store i32 %33, ptr %36, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = sub nsw i32 %38, 1
  %40 = call noundef i32 @_Z1Fiii(i32 noundef %37, i32 noundef %39, i32 noundef 0)
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = add nsw i32 %44, %45
  %47 = call noundef i32 @_Z3sqri(i32 noundef %46)
  %48 = add nsw i32 %40, %47
  store i32 %48, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  store i32 %52, ptr %11, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %77, %32
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = icmp sge i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 2, ptr %9, align 4
  br label %82

58:                                               ; preds = %53
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = load i32, ptr %11, align 4, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = add nsw i32 %64, %65
  %67 = call noundef i32 @_Z1Fiii(i32 noundef %59, i32 noundef %60, i32 noundef %66)
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = sub nsw i32 %70, 1
  %72 = call noundef i32 @_Z1Fiii(i32 noundef %69, i32 noundef %71, i32 noundef 0)
  %73 = add nsw i32 %67, %72
  %74 = call noundef zeroext i1 @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %10, i32 noundef %73)
  br i1 %74, label %75, label %76

75:                                               ; preds = %58
  store i32 2, ptr %9, align 4
  br label %82

76:                                               ; preds = %58
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  store i32 %81, ptr %11, align 4, !tbaa !5
  br label %53, !llvm.loop !9

82:                                               ; preds = %75, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = load i32, ptr %8, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [8120601 x i32], ptr @f, i64 0, i64 %86
  store i32 %84, ptr %87, align 4, !tbaa !5
  store i32 %84, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %88

88:                                               ; preds = %83, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %89

89:                                               ; preds = %88, %15
  %90 = load i32, ptr %4, align 4
  ret i32 %90
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxiii(i32 noundef, i32 noundef, i32 noundef) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #2

; 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 = { 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 #3 = { 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"

@c = external dso_local local_unnamed_addr global [201 x i32], align 16
@pre = external dso_local local_unnamed_addr global [201 x i32], align 16
@Case = external dso_local local_unnamed_addr global i32, align 4
@tim = external dso_local local_unnamed_addr global [8120601 x i32], align 16
@f = external dso_local local_unnamed_addr global [8120601 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z1Fiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = icmp sgt i32 %0, %1
  br i1 %5, label %36, label %6

6:                                                ; preds = %3
  %7 = tail call noundef i32 @_Z3idxiii(i32 noundef %0, i32 noundef %1, i32 noundef %2)
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [8120601 x i32], ptr @tim, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = load i32, ptr @Case, align 4, !tbaa !5
  %12 = icmp eq i32 %10, %11
  br i1 %12, label %13, label %16

13:                                               ; preds = %6
  %14 = getelementptr inbounds [8120601 x i32], ptr @f, i64 0, i64 %8
  %15 = load i32, ptr %14, align 4, !tbaa !5
  br label %36

16:                                               ; preds = %6
  store i32 %11, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %17 = add nsw i32 %1, -1
  %18 = tail call noundef i32 @_Z1Fiii(i32 noundef %0, i32 noundef %17, i32 noundef 0)
  %19 = sext i32 %1 to i64
  %20 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = add nsw i32 %21, %2
  %23 = tail call noundef i32 @_Z3sqri(i32 noundef %22)
  %24 = add nsw i32 %23, %18
  store i32 %24, ptr %4, align 4, !tbaa !5
  %.0.in28 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %19
  %.029 = load i32, ptr %.0.in28, align 4, !tbaa !5
  %.not30 = icmp slt i32 %.029, %0
  br i1 %.not30, label %._crit_edge, label %.lr.ph

25:                                               ; preds = %.lr.ph
  %26 = sext i32 %.031 to i64
  %.0.in = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %26
  %.0 = load i32, ptr %.0.in, align 4, !tbaa !5
  %.not = icmp slt i32 %.0, %0
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !9

.lr.ph:                                           ; preds = %16, %25
  %.031 = phi i32 [ %.0, %25 ], [ %.029, %16 ]
  %27 = load i32, ptr %20, align 4, !tbaa !5
  %28 = add nsw i32 %27, %2
  %29 = call noundef i32 @_Z1Fiii(i32 noundef %0, i32 noundef %.031, i32 noundef %28)
  %30 = add nsw i32 %.031, 1
  %31 = call noundef i32 @_Z1Fiii(i32 noundef %30, i32 noundef %17, i32 noundef 0)
  %32 = add nsw i32 %31, %29
  %33 = call noundef zeroext i1 @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %32)
  br i1 %33, label %._crit_edge.loopexit, label %25

._crit_edge.loopexit:                             ; preds = %.lr.ph, %25
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %16
  %34 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %24, %16 ]
  %35 = getelementptr inbounds [8120601 x i32], ptr @f, i64 0, i64 %8
  store i32 %34, ptr %35, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %36

36:                                               ; preds = %13, %._crit_edge, %3
  %.1 = phi i32 [ 0, %3 ], [ %15, %13 ], [ %34, %._crit_edge ]
  ret i32 %.1
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sqri(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass