; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (1407)

; 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 [10 x i8], align 1

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

7:                                                ; preds = %63, %0
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %9 = icmp ne i32 %8, -1
  br i1 %9, label %10, label %64

10:                                               ; preds = %7
  store i32 0, ptr %6, align 4, !tbaa !5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %60, %10
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp sle i32 %12, 100
  br i1 %13, label %14, label %63

14:                                               ; preds = %11
  %15 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %15, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %52, %14
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp sle i32 %17, 100
  br i1 %18, label %19, label %55

19:                                               ; preds = %16
  %20 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %20, ptr %5, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %44, %19
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = icmp sle i32 %22, 100
  br i1 %23, label %24, label %47

24:                                               ; preds = %21
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = mul nsw i32 %26, %27
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = mul nsw i32 %29, %30
  %32 = add nsw i32 %28, %31
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = mul nsw i32 %33, %34
  %36 = add nsw i32 %32, %35
  %37 = icmp eq i32 %25, %36
  br i1 %37, label %38, label %43

38:                                               ; preds = %24
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %39, i32 noundef %40, i32 noundef %41)
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %47

43:                                               ; preds = %24
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %5, align 4, !tbaa !5
  br label %21, !llvm.loop !9

47:                                               ; preds = %38, %21
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 1
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  br label %55

51:                                               ; preds = %47
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !11

55:                                               ; preds = %50, %16
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = icmp eq i32 %56, 1
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  br label %63

59:                                               ; preds = %55
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !12

63:                                               ; preds = %58, %11
  br label %7, !llvm.loop !13

64:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

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

declare i32 @printf(ptr 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 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 #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 = { 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"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; 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 [10 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not31 = icmp eq i32 %2, -1
  br i1 %.not31, label %._crit_edge, label %.preheader25

.preheader25:                                     ; preds = %0, %.loopexit
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %.preheader24

.preheader24:                                     ; preds = %.preheader25, %.critedge23
  %.02130 = phi i32 [ 1, %.preheader25 ], [ %16, %.critedge23 ]
  %3 = mul nuw nsw i32 %.02130, %.02130
  br label %.preheader

.preheader:                                       ; preds = %.preheader24, %.critedge
  %.02029 = phi i32 [ %.02130, %.preheader24 ], [ %13, %.critedge ]
  %4 = mul nuw nsw i32 %.02029, %.02029
  %5 = add nuw nsw i32 %4, %3
  br label %6

6:                                                ; preds = %.preheader, %10
  %.01928 = phi i32 [ %.02029, %.preheader ], [ %11, %10 ]
  %7 = mul nuw nsw i32 %.01928, %.01928
  %8 = add nuw nsw i32 %5, %7
  %9 = icmp eq i32 %.pre, %8
  br i1 %9, label %14, label %10

10:                                               ; preds = %6
  %11 = add nuw nsw i32 %.01928, 1
  %12 = icmp ult i32 %.01928, 100
  br i1 %12, label %6, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %10
  %13 = add nuw nsw i32 %.02029, 1
  %exitcond.not = icmp eq i32 %13, 101
  br i1 %exitcond.not, label %.critedge23, label %.preheader, !llvm.loop !11

14:                                               ; preds = %6
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.02130, i32 noundef %.02029, i32 noundef %.01928)
  br label %.loopexit

.critedge23:                                      ; preds = %.critedge
  %16 = add nuw nsw i32 %.02130, 1
  %exitcond35.not = icmp eq i32 %16, 101
  br i1 %exitcond35.not, label %.loopexit, label %.preheader24, !llvm.loop !12

.loopexit:                                        ; preds = %.critedge23, %14
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %.not = icmp eq i32 %17, -1
  br i1 %.not, label %._crit_edge, label %.preheader25, !llvm.loop !13

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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 nofree norecurse 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 = { 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 #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"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass