; LLVM IR from fcimeson/cbTSP :: cbLKH/SRC (Statistics)

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

@Successes = external hidden global i32, align 4
@TrialSum = external hidden global i32, align 4
@CostSum = external hidden global i64, align 8
@TimeSum = external hidden global double, align 8
@TrialsMin = external hidden global i32, align 4
@TrialsMax = external hidden global i32, align 4
@TimeMin = external hidden global double, align 8
@TimeMax = external hidden global double, align 8
@CostMin = external hidden global i64, align 8
@CostMax = external hidden global i64, align 8
@Optimum = external dso_local global i64, align 8
@Runs = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@BestCost = external dso_local global i64, align 8
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [69 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @PrintStatistics() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  %5 = load i32, ptr @Runs, align 4, !tbaa !5
  store i32 %5, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %6 = load i32, ptr @TrialsMin, align 4, !tbaa !5
  store i32 %6, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %7 = load double, ptr @TimeMin, align 8, !tbaa !9
  store double %7, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = load i64, ptr @Optimum, align 8, !tbaa !11
  store i64 %8, ptr %4, align 8, !tbaa !11
  %9 = load i32, ptr @Successes, align 4, !tbaa !5
  %10 = load i32, ptr @Runs, align 4, !tbaa !5
  call void (ptr, ...) @printff(ptr noundef @.str, i32 noundef %9, i32 noundef %10)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %0
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %13, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @TrialsMax, align 4, !tbaa !5
  %17 = icmp sgt i32 %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %18, %14
  %20 = load double, ptr %3, align 8, !tbaa !9
  %21 = load double, ptr @TimeMax, align 8, !tbaa !9
  %22 = fcmp ogt double %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %23, %19
  %25 = load i64, ptr @CostMin, align 8, !tbaa !11
  %26 = load i64, ptr @CostMax, align 8, !tbaa !11
  %27 = icmp sle i64 %25, %26
  br i1 %27, label %28, label %75

28:                                               ; preds = %24
  %29 = load i64, ptr @CostMin, align 8, !tbaa !11
  %30 = icmp ne i64 %29, 9223372036854775807
  br i1 %30, label %31, label %75

31:                                               ; preds = %28
  %32 = load i64, ptr @CostMin, align 8, !tbaa !11
  %33 = load i64, ptr @CostSum, align 8, !tbaa !11
  %34 = sitofp i64 %33 to double
  %35 = load i32, ptr %1, align 4, !tbaa !5
  %36 = sitofp i32 %35 to double
  %37 = fdiv double %34, %36
  %38 = load i64, ptr @CostMax, align 8, !tbaa !11
  call void (ptr, ...) @printff(ptr noundef @.str.1, i64 noundef %32, double noundef %37, i64 noundef %38)
  %39 = load i64, ptr %4, align 8, !tbaa !11
  %40 = icmp eq i64 %39, -9223372036854775808
  br i1 %40, label %41, label %43

41:                                               ; preds = %31
  %42 = load i64, ptr @BestCost, align 8, !tbaa !11
  store i64 %42, ptr %4, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %41, %31
  %44 = load i64, ptr %4, align 8, !tbaa !11
  %45 = icmp ne i64 %44, 0
  br i1 %45, label %46, label %74

46:                                               ; preds = %43
  %47 = load i64, ptr @CostMin, align 8, !tbaa !11
  %48 = load i64, ptr %4, align 8, !tbaa !11
  %49 = sub nsw i64 %47, %48
  %50 = sitofp i64 %49 to double
  %51 = fmul double 1.000000e+02, %50
  %52 = load i64, ptr %4, align 8, !tbaa !11
  %53 = sitofp i64 %52 to double
  %54 = fdiv double %51, %53
  %55 = load i64, ptr @CostSum, align 8, !tbaa !11
  %56 = load i32, ptr %1, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = sdiv i64 %55, %57
  %59 = load i64, ptr %4, align 8, !tbaa !11
  %60 = sub nsw i64 %58, %59
  %61 = sitofp i64 %60 to double
  %62 = fmul double 1.000000e+02, %61
  %63 = load i64, ptr %4, align 8, !tbaa !11
  %64 = sitofp i64 %63 to double
  %65 = fdiv double %62, %64
  %66 = load i64, ptr @CostMax, align 8, !tbaa !11
  %67 = load i64, ptr %4, align 8, !tbaa !11
  %68 = sub nsw i64 %66, %67
  %69 = sitofp i64 %68 to double
  %70 = fmul double 1.000000e+02, %69
  %71 = load i64, ptr %4, align 8, !tbaa !11
  %72 = sitofp i64 %71 to double
  %73 = fdiv double %70, %72
  call void (ptr, ...) @printff(ptr noundef @.str.2, double noundef %54, double noundef %65, double noundef %73)
  br label %74

74:                                               ; preds = %46, %43
  br label %75

75:                                               ; preds = %74, %28, %24
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = load i32, ptr @TrialSum, align 4, !tbaa !5
  %78 = sitofp i32 %77 to double
  %79 = fmul double 1.000000e+00, %78
  %80 = load i32, ptr %1, align 4, !tbaa !5
  %81 = sitofp i32 %80 to double
  %82 = fdiv double %79, %81
  %83 = load i32, ptr @TrialsMax, align 4, !tbaa !5
  call void (ptr, ...) @printff(ptr noundef @.str.3, i32 noundef %76, double noundef %82, i32 noundef %83)
  %84 = load double, ptr %3, align 8, !tbaa !9
  %85 = call double @llvm.fabs.f64(double %84)
  %86 = load double, ptr @TimeSum, align 8, !tbaa !9
  %87 = call double @llvm.fabs.f64(double %86)
  %88 = load i32, ptr %1, align 4, !tbaa !5
  %89 = sitofp i32 %88 to double
  %90 = fdiv double %87, %89
  %91 = load double, ptr @TimeMax, align 8, !tbaa !9
  %92 = call double @llvm.fabs.f64(double %91)
  call void (ptr, ...) @printff(ptr noundef @.str.4, double noundef %85, double noundef %90, double noundef %92)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

declare void @printff(ptr noundef, ...) #2

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

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

attributes #0 = { 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}


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

@Successes = external hidden local_unnamed_addr global i32, align 4
@TrialSum = external hidden local_unnamed_addr global i32, align 4
@CostSum = external hidden local_unnamed_addr global i64, align 8
@TimeSum = external hidden local_unnamed_addr global double, align 8
@TrialsMin = external hidden local_unnamed_addr global i32, align 4
@TrialsMax = external hidden local_unnamed_addr global i32, align 4
@TimeMin = external hidden local_unnamed_addr global double, align 8
@TimeMax = external hidden local_unnamed_addr global double, align 8
@CostMin = external hidden local_unnamed_addr global i64, align 8
@CostMax = external hidden local_unnamed_addr global i64, align 8
@Optimum = external dso_local local_unnamed_addr global i64, align 8
@Runs = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@BestCost = external dso_local local_unnamed_addr global i64, align 8
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [69 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @PrintStatistics() local_unnamed_addr #0 {
  %1 = load i32, ptr @Runs, align 4, !tbaa !5
  %2 = load i32, ptr @TrialsMin, align 4, !tbaa !5
  %3 = load double, ptr @TimeMin, align 8, !tbaa !9
  %4 = load i64, ptr @Optimum, align 8, !tbaa !11
  %5 = load i32, ptr @Successes, align 4, !tbaa !5
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str, i32 noundef %5, i32 noundef %1) #4
  %spec.store.select = tail call i32 @llvm.umax.i32(i32 %1, i32 1)
  %6 = load i32, ptr @TrialsMax, align 4, !tbaa !5
  %7 = load double, ptr @TimeMax, align 8, !tbaa !9
  %8 = load i64, ptr @CostMin, align 8
  %9 = load i64, ptr @CostMax, align 8, !tbaa !11
  %10 = icmp sle i64 %8, %9
  %11 = icmp ne i64 %8, 9223372036854775807
  %or.cond = and i1 %11, %10
  br i1 %or.cond, label %12, label %._crit_edge

._crit_edge:                                      ; preds = %0
  %.pre = sitofp i32 %spec.store.select to double
  br label %38

12:                                               ; preds = %0
  %13 = load i64, ptr @CostSum, align 8, !tbaa !11
  %14 = sitofp i64 %13 to double
  %15 = sitofp i32 %spec.store.select to double
  %16 = fdiv double %14, %15
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.1, i64 noundef %8, double noundef %16, i64 noundef %9) #4
  %17 = icmp eq i64 %4, -9223372036854775808
  %18 = load i64, ptr @BestCost, align 8
  %spec.select = select i1 %17, i64 %18, i64 %4
  %.not = icmp eq i64 %spec.select, 0
  br i1 %.not, label %38, label %19

19:                                               ; preds = %12
  %20 = load i64, ptr @CostMin, align 8, !tbaa !11
  %21 = sub nsw i64 %20, %spec.select
  %22 = sitofp i64 %21 to double
  %23 = fmul double %22, 1.000000e+02
  %24 = sitofp i64 %spec.select to double
  %25 = fdiv double %23, %24
  %26 = load i64, ptr @CostSum, align 8, !tbaa !11
  %27 = sext i32 %spec.store.select to i64
  %28 = sdiv i64 %26, %27
  %29 = sub nsw i64 %28, %spec.select
  %30 = sitofp i64 %29 to double
  %31 = fmul double %30, 1.000000e+02
  %32 = fdiv double %31, %24
  %33 = load i64, ptr @CostMax, align 8, !tbaa !11
  %34 = sub nsw i64 %33, %spec.select
  %35 = sitofp i64 %34 to double
  %36 = fmul double %35, 1.000000e+02
  %37 = fdiv double %36, %24
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.2, double noundef %25, double noundef %32, double noundef %37) #4
  br label %38

38:                                               ; preds = %._crit_edge, %12, %19
  %.pre-phi = phi double [ %.pre, %._crit_edge ], [ %15, %12 ], [ %15, %19 ]
  %39 = fcmp ogt double %3, %7
  %40 = icmp sgt i32 %2, %6
  %spec.store.select2 = select i1 %40, i32 0, i32 %2
  %41 = load i32, ptr @TrialSum, align 4, !tbaa !5
  %42 = sitofp i32 %41 to double
  %43 = fdiv double %42, %.pre-phi
  %44 = load i32, ptr @TrialsMax, align 4, !tbaa !5
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.3, i32 noundef %spec.store.select2, double noundef %43, i32 noundef %44) #4
  %45 = tail call double @llvm.fabs.f64(double %3)
  %46 = select i1 %39, double 0.000000e+00, double %45
  %47 = load double, ptr @TimeSum, align 8, !tbaa !9
  %48 = tail call double @llvm.fabs.f64(double %47)
  %49 = fdiv double %48, %.pre-phi
  %50 = load double, ptr @TimeMax, align 8, !tbaa !9
  %51 = tail call double @llvm.fabs.f64(double %50)
  tail call void (ptr, ...) @printff(ptr noundef nonnull @.str.4, double noundef %46, double noundef %49, double noundef %51) #4
  ret void
}

declare void @printff(ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #3

attributes #0 = { 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 = { "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 speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass