; LLVM IR from xirc/cp-algorithm :: atcoder/abc026/D/main.ll (Z5solvev)

; 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z1fe(x86_fp80 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z5solvev() #0 {
  %1 = alloca x86_fp80, align 16
  %2 = alloca x86_fp80, align 16
  %3 = alloca x86_fp80, align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #3
  store x86_fp80 0xK00000000000000000000, ptr %2, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #3
  store x86_fp80 0xK4006C800000000000000, ptr %3, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %38, %0
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 400
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %5, align 4
  br label %41

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  %13 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %14 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %15 = fadd x86_fp80 %13, %14
  %16 = fdiv x86_fp80 %15, 0xK40008000000000000000
  store x86_fp80 %16, ptr %6, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  %17 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %18 = call noundef x86_fp80 @_Z1fe(x86_fp80 noundef %17)
  store x86_fp80 %18, ptr %7, align 16, !tbaa !5
  %19 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %20 = fsub x86_fp80 %19, 0xK4005C800000000000000
  %21 = call noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef %20)
  %22 = fcmp olt x86_fp80 %21, 0xK3FEB8637BD05AF6C6800
  br i1 %22, label %23, label %25

23:                                               ; preds = %12
  %24 = load x86_fp80, ptr %6, align 16, !tbaa !5
  store x86_fp80 %24, ptr %1, align 16
  store i32 1, ptr %5, align 4
  br label %35

25:                                               ; preds = %12
  %26 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %27 = fsub x86_fp80 %26, 0xK4005C800000000000000
  %28 = fcmp ogt x86_fp80 %27, 0xK00000000000000000000
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = load x86_fp80, ptr %6, align 16, !tbaa !5
  store x86_fp80 %30, ptr %3, align 16, !tbaa !5
  br label %33

31:                                               ; preds = %25
  %32 = load x86_fp80, ptr %6, align 16, !tbaa !5
  store x86_fp80 %32, ptr %2, align 16, !tbaa !5
  br label %33

33:                                               ; preds = %31, %29
  br label %34

34:                                               ; preds = %33
  store i32 0, ptr %5, align 4
  br label %35

35:                                               ; preds = %34, %23
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  %36 = load i32, ptr %5, align 4
  switch i32 %36, label %41 [
    i32 0, label %37
  ]

37:                                               ; preds = %35
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !11

41:                                               ; preds = %35, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %42 = load i32, ptr %5, align 4
  switch i32 %42, label %45 [
    i32 2, label %43
  ]

43:                                               ; preds = %41
  %44 = load x86_fp80, ptr %2, align 16, !tbaa !5
  store x86_fp80 %44, ptr %1, align 16
  store i32 1, ptr %5, align 4
  br label %45

45:                                               ; preds = %43, %41
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #3
  %46 = load x86_fp80, ptr %1, align 16
  ret x86_fp80 %46
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3abse(x86_fp80 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 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 = { inlinehint 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 #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 = !{!"long 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 = 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z1fe(x86_fp80 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z5solvev() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %0, %8
  %.01527 = phi x86_fp80 [ 0xK00000000000000000000, %0 ], [ %.015., %8 ]
  %.01926 = phi x86_fp80 [ 0xK4006C800000000000000, %0 ], [ %..019, %8 ]
  %.02225 = phi i32 [ 0, %0 ], [ %10, %8 ]
  %2 = fadd x86_fp80 %.01926, %.01527
  %3 = fmul x86_fp80 %2, 0xK3FFE8000000000000000
  %4 = tail call noundef x86_fp80 @_Z1fe(x86_fp80 noundef %3)
  %5 = fadd x86_fp80 %4, 0xKC005C800000000000000
  %6 = tail call noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef %5)
  %7 = fcmp uge x86_fp80 %6, 0xK3FEB8637BD05AF6C6800
  br i1 %7, label %8, label %11

8:                                                ; preds = %1
  %9 = fcmp ogt x86_fp80 %5, 0xK00000000000000000000
  %.015. = select i1 %9, x86_fp80 %.01527, x86_fp80 %3
  %..019 = select i1 %9, x86_fp80 %3, x86_fp80 %.01926
  %10 = add nuw nsw i32 %.02225, 1
  %exitcond = icmp eq i32 %10, 400
  br i1 %exitcond, label %11, label %1, !llvm.loop !5

11:                                               ; preds = %8, %1
  %spec.select = phi x86_fp80 [ %3, %1 ], [ %.015., %8 ]
  ret x86_fp80 %spec.select
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { inlinehint 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" }

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass