; LLVM IR from Izaron/ACM-ICPC :: Google Code Jam/2017/Round 1B/pony_express.ll (Z3dfseeeRSt6vectorIeSaIeEEi)

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

@n = external dso_local global i32, align 4
@dista = external dso_local global [105 x [105 x x86_fp80]], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfseeeRSt6vectorIeSaIeEEi(x86_fp80 noundef %0, x86_fp80 noundef %1, x86_fp80 noundef %2, ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef %4) #0 {
  %6 = alloca x86_fp80, align 16
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store x86_fp80 %0, ptr %6, align 16, !tbaa !5
  store x86_fp80 %1, ptr %7, align 16, !tbaa !5
  store x86_fp80 %2, ptr %8, align 16, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  %12 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %13 = fcmp olt x86_fp80 %12, 0xK00000000000000000000
  br i1 %13, label %14, label %15

14:                                               ; preds = %5
  br label %77

15:                                               ; preds = %5
  %16 = load ptr, ptr %9, align 8, !tbaa !9
  %17 = load i32, ptr %10, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZNSt6vectorIeSaIeEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %18) #3
  %20 = load x86_fp80, ptr %19, align 16, !tbaa !5
  %21 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %22 = fcmp ole x86_fp80 %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %15
  br label %77

24:                                               ; preds = %15
  %25 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !9
  %27 = load i32, ptr %10, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZNSt6vectorIeSaIeEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %28) #3
  store x86_fp80 %25, ptr %29, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %74, %24
  %31 = load i32, ptr %11, align 4, !tbaa !11
  %32 = load i32, ptr @n, align 4, !tbaa !11
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load i32, ptr %11, align 4, !tbaa !11
  %37 = load i32, ptr %10, align 4, !tbaa !11
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  br label %74

40:                                               ; preds = %35
  %41 = load i32, ptr %10, align 4, !tbaa !11
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [105 x [105 x x86_fp80]], ptr @dista, i64 0, i64 %42
  %44 = load i32, ptr %11, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [105 x x86_fp80], ptr %43, i64 0, i64 %45
  %47 = load x86_fp80, ptr %46, align 16, !tbaa !5
  %48 = fcmp oeq x86_fp80 %47, 0xKBFFF8000000000000000
  br i1 %48, label %49, label %50

49:                                               ; preds = %40
  br label %74

50:                                               ; preds = %40
  %51 = load x86_fp80, ptr %6, align 16, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [105 x [105 x x86_fp80]], ptr @dista, i64 0, i64 %53
  %55 = load i32, ptr %11, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [105 x x86_fp80], ptr %54, i64 0, i64 %56
  %58 = load x86_fp80, ptr %57, align 16, !tbaa !5
  %59 = fsub x86_fp80 %51, %58
  %60 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %61 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %62 = load i32, ptr %10, align 4, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [105 x [105 x x86_fp80]], ptr @dista, i64 0, i64 %63
  %65 = load i32, ptr %11, align 4, !tbaa !11
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [105 x x86_fp80], ptr %64, i64 0, i64 %66
  %68 = load x86_fp80, ptr %67, align 16, !tbaa !5
  %69 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %70 = fdiv x86_fp80 %68, %69
  %71 = fadd x86_fp80 %61, %70
  %72 = load ptr, ptr %9, align 8, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !11
  call void @_Z3dfseeeRSt6vectorIeSaIeEEi(x86_fp80 noundef %59, x86_fp80 noundef %60, x86_fp80 noundef %71, ptr noundef nonnull align 8 dereferenceable(24) %72, i32 noundef %73)
  br label %74

74:                                               ; preds = %50, %49, %39
  %75 = load i32, ptr %11, align 4, !tbaa !11
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %11, align 4, !tbaa !11
  br label %30, !llvm.loop !13

77:                                               ; preds = %34, %23, %14
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZNSt6vectorIeSaIeEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

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

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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !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"

@n = external dso_local local_unnamed_addr global i32, align 4
@dista = external dso_local local_unnamed_addr global [105 x [105 x x86_fp80]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfseeeRSt6vectorIeSaIeEEi(x86_fp80 noundef %0, x86_fp80 noundef %1, x86_fp80 noundef %2, ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %5
  %8 = sext i32 %4 to i64
  %9 = tail call noundef nonnull align 16 dereferenceable(16) ptr @_ZNSt6vectorIeSaIeEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %8) #1
  %10 = load x86_fp80, ptr %9, align 16, !tbaa !5
  %11 = fcmp ugt x86_fp80 %10, %2
  br i1 %11, label %12, label %.loopexit

12:                                               ; preds = %7
  %13 = tail call noundef nonnull align 16 dereferenceable(16) ptr @_ZNSt6vectorIeSaIeEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %8) #1
  store x86_fp80 %2, ptr %13, align 16, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !9
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %12
  %16 = zext i32 %4 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %28
  %17 = phi i32 [ %14, %.lr.ph.preheader ], [ %29, %28 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %28 ]
  %18 = icmp eq i64 %indvars.iv, %16
  br i1 %18, label %28, label %19

19:                                               ; preds = %.lr.ph
  %20 = getelementptr inbounds [105 x [105 x x86_fp80]], ptr @dista, i64 0, i64 %8, i64 %indvars.iv
  %21 = load x86_fp80, ptr %20, align 16, !tbaa !5
  %22 = fcmp oeq x86_fp80 %21, 0xKBFFF8000000000000000
  br i1 %22, label %28, label %23

23:                                               ; preds = %19
  %24 = fsub x86_fp80 %0, %21
  %25 = fdiv x86_fp80 %21, %1
  %26 = fadd x86_fp80 %25, %2
  %27 = trunc nuw nsw i64 %indvars.iv to i32
  tail call void @_Z3dfseeeRSt6vectorIeSaIeEEi(x86_fp80 noundef %24, x86_fp80 noundef %1, x86_fp80 noundef %26, ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef %27)
  %.pre = load i32, ptr @n, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %19, %.lr.ph, %23
  %29 = phi i32 [ %17, %19 ], [ %17, %.lr.ph ], [ %.pre, %23 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next, %30
  br i1 %31, label %.lr.ph, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %28, %12, %7, %5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZNSt6vectorIeSaIeEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 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 = { 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"}


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