; LLVM IR from DionysiosB/CodeForces :: 0100-0199 (190B-Surrounded)

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5, ptr noundef %6, ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %12 = load double, ptr %2, align 8, !tbaa !5
  %13 = load double, ptr %5, align 8, !tbaa !5
  %14 = fsub double %12, %13
  %15 = load double, ptr %2, align 8, !tbaa !5
  %16 = load double, ptr %5, align 8, !tbaa !5
  %17 = fsub double %15, %16
  %18 = load double, ptr %3, align 8, !tbaa !5
  %19 = load double, ptr %6, align 8, !tbaa !5
  %20 = fsub double %18, %19
  %21 = load double, ptr %3, align 8, !tbaa !5
  %22 = load double, ptr %6, align 8, !tbaa !5
  %23 = fsub double %21, %22
  %24 = fmul double %20, %23
  %25 = call double @llvm.fmuladd.f64(double %14, double %17, double %24)
  %26 = call double @sqrt(double noundef %25) #5
  store double %26, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store double 0.000000e+00, ptr %9, align 8, !tbaa !5
  %27 = load double, ptr %8, align 8, !tbaa !5
  %28 = load double, ptr %4, align 8, !tbaa !5
  %29 = load double, ptr %7, align 8, !tbaa !5
  %30 = fadd double %28, %29
  %31 = fcmp ogt double %27, %30
  br i1 %31, label %32, label %39

32:                                               ; preds = %0
  %33 = load double, ptr %8, align 8, !tbaa !5
  %34 = load double, ptr %4, align 8, !tbaa !5
  %35 = fsub double %33, %34
  %36 = load double, ptr %7, align 8, !tbaa !5
  %37 = fsub double %35, %36
  %38 = fdiv double %37, 2.000000e+00
  store double %38, ptr %9, align 8, !tbaa !5
  br label %67

39:                                               ; preds = %0
  %40 = load double, ptr %8, align 8, !tbaa !5
  %41 = load double, ptr %4, align 8, !tbaa !5
  %42 = load double, ptr %7, align 8, !tbaa !5
  %43 = fsub double %41, %42
  %44 = fcmp olt double %40, %43
  br i1 %44, label %45, label %52

45:                                               ; preds = %39
  %46 = load double, ptr %4, align 8, !tbaa !5
  %47 = load double, ptr %8, align 8, !tbaa !5
  %48 = fsub double %46, %47
  %49 = load double, ptr %7, align 8, !tbaa !5
  %50 = fsub double %48, %49
  %51 = fdiv double %50, 2.000000e+00
  store double %51, ptr %9, align 8, !tbaa !5
  br label %66

52:                                               ; preds = %39
  %53 = load double, ptr %8, align 8, !tbaa !5
  %54 = load double, ptr %7, align 8, !tbaa !5
  %55 = load double, ptr %4, align 8, !tbaa !5
  %56 = fsub double %54, %55
  %57 = fcmp olt double %53, %56
  br i1 %57, label %58, label %65

58:                                               ; preds = %52
  %59 = load double, ptr %7, align 8, !tbaa !5
  %60 = load double, ptr %8, align 8, !tbaa !5
  %61 = fsub double %59, %60
  %62 = load double, ptr %4, align 8, !tbaa !5
  %63 = fsub double %61, %62
  %64 = fdiv double %63, 2.000000e+00
  store double %64, ptr %9, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %58, %52
  br label %66

66:                                               ; preds = %65, %45
  br label %67

67:                                               ; preds = %66, %32
  %68 = load double, ptr %9, align 8, !tbaa !5
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %68)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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

; 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

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 "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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %9 = load double, ptr %1, align 8, !tbaa !5
  %10 = load double, ptr %4, align 8, !tbaa !5
  %11 = fsub double %9, %10
  %12 = load double, ptr %2, align 8, !tbaa !5
  %13 = load double, ptr %5, align 8, !tbaa !5
  %14 = fsub double %12, %13
  %15 = fmul double %14, %14
  %16 = call double @llvm.fmuladd.f64(double %11, double %11, double %15)
  %sqrt = call double @llvm.sqrt.f64(double %16)
  %17 = load double, ptr %3, align 8, !tbaa !5
  %18 = load double, ptr %6, align 8, !tbaa !5
  %19 = fadd double %17, %18
  %20 = fcmp ogt double %sqrt, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %0
  %22 = fsub double %sqrt, %17
  %23 = fsub double %22, %18
  %24 = fmul double %23, 5.000000e-01
  br label %39

25:                                               ; preds = %0
  %26 = fsub double %17, %18
  %27 = fcmp olt double %sqrt, %26
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = fsub double %17, %sqrt
  %30 = fsub double %29, %18
  %31 = fmul double %30, 5.000000e-01
  br label %39

32:                                               ; preds = %25
  %33 = fsub double %18, %17
  %34 = fcmp olt double %sqrt, %33
  br i1 %34, label %35, label %39

35:                                               ; preds = %32
  %36 = fsub double %18, %sqrt
  %37 = fsub double %36, %17
  %38 = fmul double %37, 5.000000e-01
  br label %39

39:                                               ; preds = %28, %35, %32, %21
  %.0 = phi double [ %24, %21 ], [ %31, %28 ], [ %38, %35 ], [ 0.000000e+00, %32 ]
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %.0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; 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

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

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass