; LLVM IR from kazunetakahashi/atcoder :: 2020/0112_ABC151/past/F2.ll (Z1gd)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z1fee(x86_fp80 noundef, x86_fp80 noundef) #2

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

8:                                                ; preds = %35, %1
  %9 = load i32, ptr %5, align 4, !tbaa !11
  %10 = icmp slt i32 %9, 80
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %38

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  %13 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %14 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %15 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %13, x86_fp80 0xK40008000000000000000, x86_fp80 %14)
  %16 = fdiv x86_fp80 %15, 0xK4000C000000000000000
  store x86_fp80 %16, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  %17 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %18 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %19 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %18, x86_fp80 0xK40008000000000000000, x86_fp80 %17)
  %20 = fdiv x86_fp80 %19, 0xK4000C000000000000000
  store x86_fp80 %20, ptr %7, align 16, !tbaa !9
  %21 = load double, ptr %2, align 8, !tbaa !5
  %22 = fpext double %21 to x86_fp80
  %23 = load x86_fp80, ptr %6, align 16, !tbaa !9
  %24 = call noundef x86_fp80 @_Z1fee(x86_fp80 noundef %22, x86_fp80 noundef %23)
  %25 = load double, ptr %2, align 8, !tbaa !5
  %26 = fpext double %25 to x86_fp80
  %27 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %28 = call noundef x86_fp80 @_Z1fee(x86_fp80 noundef %26, x86_fp80 noundef %27)
  %29 = fcmp ogt x86_fp80 %24, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %12
  %31 = load x86_fp80, ptr %6, align 16, !tbaa !9
  store x86_fp80 %31, ptr %3, align 16, !tbaa !9
  br label %34

32:                                               ; preds = %12
  %33 = load x86_fp80, ptr %7, align 16, !tbaa !9
  store x86_fp80 %33, ptr %4, align 16, !tbaa !9
  br label %34

34:                                               ; preds = %32, %30
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %5, align 4, !tbaa !11
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !11
  br label %8, !llvm.loop !13

38:                                               ; preds = %11
  %39 = load double, ptr %2, align 8, !tbaa !5
  %40 = fpext double %39 to x86_fp80
  %41 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %42 = call noundef x86_fp80 @_Z1fee(x86_fp80 noundef %40, x86_fp80 noundef %41)
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #3
  ret x86_fp80 %42
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z1fee(x86_fp80 noundef, x86_fp80 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef x86_fp80 @_Z1gd(double noundef %0) local_unnamed_addr #1 {
  %2 = fpext double %0 to x86_fp80
  br label %5

3:                                                ; preds = %5
  %4 = tail call noundef x86_fp80 @_Z1fee(x86_fp80 noundef %2, x86_fp80 noundef %..0)
  ret x86_fp80 %4

5:                                                ; preds = %1, %5
  %.019 = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %..0, %5 ]
  %.01418 = phi x86_fp80 [ 0xK4008FA00000000000000, %1 ], [ %.014., %5 ]
  %.01617 = phi i32 [ 0, %1 ], [ %13, %5 ]
  %6 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %.019, x86_fp80 0xK40008000000000000000, x86_fp80 %.01418)
  %7 = fdiv x86_fp80 %6, 0xK4000C000000000000000
  %8 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %.01418, x86_fp80 0xK40008000000000000000, x86_fp80 %.019)
  %9 = fdiv x86_fp80 %8, 0xK4000C000000000000000
  %10 = tail call noundef x86_fp80 @_Z1fee(x86_fp80 noundef %2, x86_fp80 noundef %7)
  %11 = tail call noundef x86_fp80 @_Z1fee(x86_fp80 noundef %2, x86_fp80 noundef %9)
  %12 = fcmp ogt x86_fp80 %10, %11
  %.014. = select i1 %12, x86_fp80 %.01418, x86_fp80 %9
  %..0 = select i1 %12, x86_fp80 %7, x86_fp80 %.019
  %13 = add nuw nsw i32 %.01617, 1
  %exitcond.not = icmp eq i32 %13, 80
  br i1 %exitcond.not, label %3, label %5, !llvm.loop !5
}

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

!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: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass