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

; 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 [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5primei(i32 noundef) #0

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

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

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

8:                                                ; preds = %96, %0
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4)
  %10 = xor i32 %9, -1
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %102

12:                                               ; preds = %8
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %22

15:                                               ; preds = %12
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %102

22:                                               ; preds = %18, %15, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = fmul double 1.000000e+00, %24
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sitofp i32 %26 to double
  %28 = fdiv double %25, %27
  %29 = fptrunc double %28 to float
  store float %29, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %30 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %30, ptr %6, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %92, %22
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = icmp sge i32 %32, 4
  br i1 %33, label %34, label %95

34:                                               ; preds = %31
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = call noundef i32 @_Z5primei(i32 noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %91, label %38

38:                                               ; preds = %34
  store i32 2, ptr %7, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %87, %38
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = sitofp i32 %40 to double
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = sitofp i32 %42 to double
  %44 = fmul double %43, 1.000000e+00
  %45 = call double @sqrt(double noundef %44) #5
  %46 = fcmp ole double %41, %45
  br i1 %46, label %47, label %90

47:                                               ; preds = %39
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = srem i32 %48, %49
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %86

52:                                               ; preds = %47
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = call noundef i32 @_Z5primei(i32 noundef %53)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %85

56:                                               ; preds = %52
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = sdiv i32 %57, %58
  %60 = call noundef i32 @_Z5primei(i32 noundef %59)
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %85

62:                                               ; preds = %56
  %63 = load float, ptr %5, align 4, !tbaa !9
  %64 = fpext float %63 to double
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = sitofp i32 %65 to double
  %67 = fmul double %66, 1.000000e+00
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = sdiv i32 %68, %69
  %71 = sitofp i32 %70 to double
  %72 = fdiv double %67, %71
  %73 = fcmp ole double %64, %72
  br i1 %73, label %74, label %85

74:                                               ; preds = %62
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = sitofp i32 %75 to double
  %77 = fmul double %76, 1.000000e+00
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = sdiv i32 %78, %79
  %81 = sitofp i32 %80 to double
  %82 = fdiv double %77, %81
  %83 = fcmp ole double %82, 1.000000e+00
  br i1 %83, label %84, label %85

84:                                               ; preds = %74
  br label %96

85:                                               ; preds = %74, %62, %56, %52
  br label %86

86:                                               ; preds = %85, %47
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %7, align 4, !tbaa !5
  br label %39, !llvm.loop !11

90:                                               ; preds = %39
  br label %91

91:                                               ; preds = %90, %34
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = add nsw i32 %93, -1
  store i32 %94, ptr %6, align 4, !tbaa !5
  br label %31, !llvm.loop !13

95:                                               ; preds = %31
  br label %96

96:                                               ; preds = %95, %84
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = sdiv i32 %98, %99
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %97, i32 noundef %100)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %8, !llvm.loop !14

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 "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 #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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 [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5primei(i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

.lr.ph45:                                         ; preds = %0, %.loopexit30
  %.044 = phi i32 [ %.4, %.loopexit30 ], [ undef, %0 ]
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  %7 = load i32, ptr %2, align 4
  %8 = icmp eq i32 %7, 0
  %or.cond = select i1 %6, i1 %8, i1 false
  %9 = load i32, ptr %3, align 4
  %10 = icmp eq i32 %9, 0
  %or.cond3 = select i1 %or.cond, i1 %10, i1 false
  br i1 %or.cond3, label %._crit_edge, label %11

11:                                               ; preds = %.lr.ph45
  %12 = icmp sgt i32 %5, 3
  br i1 %12, label %.lr.ph40, label %.loopexit30

.lr.ph40:                                         ; preds = %11
  %13 = sitofp i32 %7 to double
  %14 = sitofp i32 %9 to double
  %15 = fdiv double %13, %14
  %16 = fptrunc double %15 to float
  %17 = fpext float %16 to double
  br label %18

18:                                               ; preds = %.lr.ph40, %.loopexit
  %.139 = phi i32 [ %.044, %.lr.ph40 ], [ %.3, %.loopexit ]
  %.02337 = phi i32 [ %5, %.lr.ph40 ], [ %39, %.loopexit ]
  %19 = call noundef i32 @_Z5primei(i32 noundef %.02337)
  %.not26 = icmp eq i32 %19, 0
  br i1 %.not26, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %18
  %20 = uitofp nneg i32 %.02337 to double
  %sqrt = call double @llvm.sqrt.f64(double %20)
  %21 = fcmp ult double %sqrt, 2.000000e+00
  br i1 %21, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %35
  %22 = phi double [ %37, %35 ], [ 2.000000e+00, %.preheader ]
  %.236 = phi i32 [ %36, %35 ], [ 2, %.preheader ]
  %23 = urem i32 %.02337, %.236
  %24 = udiv i32 %.02337, %.236
  %25 = icmp eq i32 %23, 0
  br i1 %25, label %26, label %35

26:                                               ; preds = %.lr.ph
  %27 = call noundef i32 @_Z5primei(i32 noundef %.236)
  %.not27 = icmp eq i32 %27, 0
  br i1 %.not27, label %35, label %28

28:                                               ; preds = %26
  %29 = call noundef i32 @_Z5primei(i32 noundef %24)
  %.not28 = icmp eq i32 %29, 0
  br i1 %.not28, label %35, label %30

30:                                               ; preds = %28
  %31 = sitofp i32 %24 to double
  %32 = fdiv double %22, %31
  %33 = fcmp ult double %32, %17
  %34 = fcmp ugt double %32, 1.000000e+00
  %or.cond29 = or i1 %33, %34
  br i1 %or.cond29, label %35, label %.loopexit30

35:                                               ; preds = %.lr.ph, %30, %28, %26
  %36 = add nuw nsw i32 %.236, 1
  %37 = uitofp nneg i32 %36 to double
  %38 = fcmp ult double %sqrt, %37
  br i1 %38, label %.loopexit, label %.lr.ph, !llvm.loop !9

.loopexit:                                        ; preds = %35, %.preheader, %18
  %.3 = phi i32 [ %.139, %18 ], [ 2, %.preheader ], [ %36, %35 ]
  %39 = add nsw i32 %.02337, -1
  %40 = icmp sgt i32 %.02337, 4
  br i1 %40, label %18, label %.loopexit30, !llvm.loop !11

.loopexit30:                                      ; preds = %.loopexit, %30, %11
  %.02335 = phi i32 [ %5, %11 ], [ %.02337, %30 ], [ 3, %.loopexit ]
  %.4 = phi i32 [ %.044, %11 ], [ %.236, %30 ], [ %.3, %.loopexit ]
  %41 = sdiv i32 %.02335, %.4
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.4, i32 noundef %41)
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %.not = icmp eq i32 %43, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph45, !llvm.loop !12

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #4

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 = { mustprogress 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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}


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