; LLVM IR from imteekay/algorithms :: competitive-programming/uri (angry_ducks)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z3radd(double noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i8, align 1
  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
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  br label %15

15:                                               ; preds = %75, %0
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %11, ptr noundef %12, ptr noundef %13)
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %18, label %76

18:                                               ; preds = %15
  %19 = load double, ptr %2, align 8, !tbaa !5
  %20 = fmul double 2.000000e+00, %19
  %21 = fdiv double %20, 0x40239D013A92A305
  store double %21, ptr %9, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %72, %18
  %23 = load i32, ptr %13, align 4, !tbaa !9
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %25, label %75

25:                                               ; preds = %22
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4)
  %27 = load double, ptr %4, align 8, !tbaa !5
  %28 = load double, ptr %3, align 8, !tbaa !5
  %29 = call noundef double @_Z3radd(double noundef %28)
  %30 = fptrunc double %29 to float
  %31 = call float @cosf(float noundef %30) #5
  %32 = fpext float %31 to double
  %33 = fmul double %27, %32
  store double %33, ptr %6, align 8, !tbaa !5
  %34 = load double, ptr %4, align 8, !tbaa !5
  %35 = load double, ptr %3, align 8, !tbaa !5
  %36 = call noundef double @_Z3radd(double noundef %35)
  %37 = fptrunc double %36 to float
  %38 = call float @sinf(float noundef %37) #5
  %39 = fpext float %38 to double
  %40 = fmul double %34, %39
  store double %40, ptr %7, align 8, !tbaa !5
  %41 = load double, ptr %7, align 8, !tbaa !5
  %42 = fdiv double %41, 0x40239D013A92A305
  store double %42, ptr %10, align 8, !tbaa !5
  %43 = load double, ptr %9, align 8, !tbaa !5
  %44 = load double, ptr %10, align 8, !tbaa !5
  %45 = fptrunc double %44 to float
  %46 = call float @powf(float noundef %45, float noundef 2.000000e+00) #5
  %47 = fpext float %46 to double
  %48 = fadd double %43, %47
  %49 = fptrunc double %48 to float
  %50 = call float @sqrtf(float noundef %49) #5
  %51 = fpext float %50 to double
  %52 = load double, ptr %10, align 8, !tbaa !5
  %53 = fadd double %51, %52
  store double %53, ptr %5, align 8, !tbaa !5
  %54 = load double, ptr %6, align 8, !tbaa !5
  %55 = load double, ptr %5, align 8, !tbaa !5
  %56 = fmul double %54, %55
  store double %56, ptr %8, align 8, !tbaa !5
  %57 = load double, ptr %8, align 8, !tbaa !5
  %58 = load double, ptr %11, align 8, !tbaa !5
  %59 = fcmp oge double %57, %58
  br i1 %59, label %60, label %64

60:                                               ; preds = %25
  %61 = load double, ptr %8, align 8, !tbaa !5
  %62 = load double, ptr %12, align 8, !tbaa !5
  %63 = fcmp ole double %61, %62
  br label %64

64:                                               ; preds = %60, %25
  %65 = phi i1 [ false, %25 ], [ %63, %60 ]
  %66 = zext i1 %65 to i64
  %67 = select i1 %65, i8 68, i8 78
  store i8 %67, ptr %14, align 1, !tbaa !11
  %68 = load double, ptr %8, align 8, !tbaa !5
  %69 = load i8, ptr %14, align 1, !tbaa !11
  %70 = sext i8 %69 to i32
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %68, i32 noundef %70)
  br label %72

72:                                               ; preds = %64
  %73 = load i32, ptr %13, align 4, !tbaa !9
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %13, align 4, !tbaa !9
  br label %22, !llvm.loop !12

75:                                               ; preds = %22
  br label %15, !llvm.loop !14

76:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  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) #2

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

; Function Attrs: nounwind
declare float @cosf(float noundef) #4

; Function Attrs: nounwind
declare float @sinf(float noundef) #4

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #4

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #4

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

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

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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z3radd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %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 i32, align 4
  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
  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 4, ptr nonnull %6) #5
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph9, label %._crit_edge

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph9
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph9, label %._crit_edge, !llvm.loop !5

.lr.ph9:                                          ; preds = %0, %.loopexit
  %11 = load double, ptr %1, align 8, !tbaa !7
  %12 = fmul double %11, 2.000000e+00
  %13 = fdiv double %12, 0x40239D013A92A305
  %.pr = load i32, ptr %6, align 4, !tbaa !11
  %14 = icmp sgt i32 %.pr, 0
  br i1 %14, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph9, %.lr.ph
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %16 = load double, ptr %3, align 8, !tbaa !7
  %17 = load double, ptr %2, align 8, !tbaa !7
  %18 = call noundef double @_Z3radd(double noundef %17)
  %19 = fptrunc double %18 to float
  %20 = call float @cosf(float noundef %19) #5
  %21 = fpext float %20 to double
  %22 = fmul double %16, %21
  %23 = load double, ptr %3, align 8, !tbaa !7
  %24 = load double, ptr %2, align 8, !tbaa !7
  %25 = call noundef double @_Z3radd(double noundef %24)
  %26 = fptrunc double %25 to float
  %27 = call float @sinf(float noundef %26) #5
  %28 = fpext float %27 to double
  %29 = fmul double %23, %28
  %30 = fdiv double %29, 0x40239D013A92A305
  %31 = fptrunc double %30 to float
  %square = fmul float %31, %31
  %32 = fpext float %square to double
  %33 = fadd double %13, %32
  %34 = fptrunc double %33 to float
  %35 = call float @sqrtf(float noundef %34) #5
  %36 = fpext float %35 to double
  %37 = fadd double %30, %36
  %38 = fmul double %22, %37
  %39 = load double, ptr %4, align 8, !tbaa !7
  %40 = fcmp oge double %38, %39
  %41 = load double, ptr %5, align 8
  %42 = fcmp ole double %38, %41
  %43 = select i1 %40, i1 %42, i1 false
  %44 = select i1 %43, i32 68, i32 78
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %38, i32 noundef %44)
  %46 = load i32, ptr %6, align 4, !tbaa !11
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr %6, align 4, !tbaa !11
  %48 = icmp sgt i32 %46, 1
  br i1 %48, label %.lr.ph, label %.loopexit, !llvm.loop !13

._crit_edge:                                      ; preds = %.loopexit, %0
  call void @llvm.lifetime.end.p0(i64 4, 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) #2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #4

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

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

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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = distinct !{!13, !6}


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