; LLVM IR from DionysiosB/CodeForces :: 1000-1099 (1076C-MemeProblem)

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

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

5:                                                ; preds = %43, %0
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %7 = add nsw i64 %6, -1
  store i64 %7, ptr %2, align 8, !tbaa !5
  %8 = icmp ne i64 %6, 0
  br i1 %8, label %9, label %44

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3)
  %11 = load double, ptr %3, align 8, !tbaa !9
  %12 = fcmp oeq double %11, 0.000000e+00
  br i1 %12, label %13, label %15

13:                                               ; preds = %9
  %14 = call i32 @puts(ptr noundef @.str.2)
  br label %43

15:                                               ; preds = %9
  %16 = load double, ptr %3, align 8, !tbaa !9
  %17 = fcmp olt double %16, 4.000000e+00
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  %19 = call i32 @puts(ptr noundef @.str.3)
  br label %42

20:                                               ; preds = %15
  %21 = load double, ptr %3, align 8, !tbaa !9
  %22 = load double, ptr %3, align 8, !tbaa !9
  %23 = load double, ptr %3, align 8, !tbaa !9
  %24 = load double, ptr %3, align 8, !tbaa !9
  %25 = fmul double 4.000000e+00, %24
  %26 = fneg double %25
  %27 = call double @llvm.fmuladd.f64(double %22, double %23, double %26)
  %28 = call double @sqrt(double noundef %27) #5
  %29 = fadd double %21, %28
  %30 = fdiv double %29, 2.000000e+00
  %31 = load double, ptr %3, align 8, !tbaa !9
  %32 = load double, ptr %3, align 8, !tbaa !9
  %33 = load double, ptr %3, align 8, !tbaa !9
  %34 = load double, ptr %3, align 8, !tbaa !9
  %35 = fmul double 4.000000e+00, %34
  %36 = fneg double %35
  %37 = call double @llvm.fmuladd.f64(double %32, double %33, double %36)
  %38 = call double @sqrt(double noundef %37) #5
  %39 = fsub double %31, %38
  %40 = fdiv double %39, 2.000000e+00
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %30, double noundef %40)
  br label %42

42:                                               ; preds = %20, %18
  br label %43

43:                                               ; preds = %42, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %5, !llvm.loop !11

44:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  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 @puts(ptr noundef) #2

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

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

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

; 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 "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = add nsw i64 %4, -1
  store i64 %5, ptr %1, align 8, !tbaa !5
  %.not1 = icmp eq i64 %4, 0
  br i1 %.not1, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %7 = load double, ptr %2, align 8, !tbaa !9
  %8 = fcmp oeq double %7, 0.000000e+00
  br i1 %8, label %9, label %11

9:                                                ; preds = %.lr.ph
  %10 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %28

11:                                               ; preds = %.lr.ph
  %12 = fcmp olt double %7, 4.000000e+00
  br i1 %12, label %13, label %15

13:                                               ; preds = %11
  %14 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %28

15:                                               ; preds = %11
  %16 = fmul double %7, -4.000000e+00
  %17 = call double @llvm.fmuladd.f64(double %7, double %7, double %16)
  %18 = call double @sqrt(double noundef %17) #5
  %19 = fadd double %7, %18
  %20 = fmul double %19, 5.000000e-01
  %21 = load double, ptr %2, align 8, !tbaa !9
  %22 = fmul double %21, -4.000000e+00
  %23 = call double @llvm.fmuladd.f64(double %21, double %21, double %22)
  %24 = call double @sqrt(double noundef %23) #5
  %25 = fsub double %21, %24
  %26 = fmul double %25, 5.000000e-01
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %20, double noundef %26)
  br label %28

28:                                               ; preds = %13, %15, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %29 = load i64, ptr %1, align 8, !tbaa !5
  %30 = add nsw i64 %29, -1
  store i64 %30, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %29, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %28, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  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 @puts(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 nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3

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

; 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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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