; LLVM IR from PetarV-/Algorithms :: Greedy Algorithms/First-Fit Bin Packing.ll (Z6Updateiidii)

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

@ST = external dso_local global [4000004 x double], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6Updateiidii(i32 noundef %0, i32 noundef %1, double noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  %11 = load i32, ptr %9, align 4, !tbaa !5
  %12 = load i32, ptr %10, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %21

14:                                               ; preds = %5
  %15 = load double, ptr %8, align 8, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fadd double %19, %15
  store double %20, ptr %18, align 8, !tbaa !9
  br label %65

21:                                               ; preds = %5
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  %26 = sdiv i32 %25, 2
  %27 = icmp sle i32 %22, %26
  br i1 %27, label %28, label %38

28:                                               ; preds = %21
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = mul nsw i32 2, %29
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = load double, ptr %8, align 8, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = add nsw i32 %34, %35
  %37 = sdiv i32 %36, 2
  call void @_Z6Updateiidii(i32 noundef %30, i32 noundef %31, double noundef %32, i32 noundef %33, i32 noundef %37)
  br label %50

38:                                               ; preds = %21
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = mul nsw i32 2, %39
  %41 = add nsw i32 %40, 1
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = load double, ptr %8, align 8, !tbaa !9
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = load i32, ptr %10, align 4, !tbaa !5
  %46 = add nsw i32 %44, %45
  %47 = sdiv i32 %46, 2
  %48 = add nsw i32 %47, 1
  %49 = load i32, ptr %10, align 4, !tbaa !5
  call void @_Z6Updateiidii(i32 noundef %41, i32 noundef %42, double noundef %43, i32 noundef %48, i32 noundef %49)
  br label %50

50:                                               ; preds = %38, %28
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = mul nsw i32 2, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %53
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = mul nsw i32 2, %55
  %57 = add nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %58
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %54, ptr noundef nonnull align 8 dereferenceable(8) %59)
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %63
  store double %61, ptr %64, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %50, %14
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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"

@ST = external dso_local global [4000004 x double], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6Updateiidii(i32 noundef %0, i32 noundef %1, double noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq i32 %3, %4
  br i1 %6, label %7, label %12

7:                                                ; preds = %5
  %8 = sext i32 %0 to i64
  %9 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fadd double %10, %2
  store double %11, ptr %9, align 8, !tbaa !5
  br label %29

12:                                               ; preds = %5
  %13 = add nsw i32 %4, %3
  %14 = sdiv i32 %13, 2
  %.not = icmp slt i32 %14, %1
  %15 = shl nsw i32 %0, 1
  br i1 %.not, label %17, label %16

16:                                               ; preds = %12
  tail call void @_Z6Updateiidii(i32 noundef %15, i32 noundef %1, double noundef %2, i32 noundef %3, i32 noundef %14)
  %.pre = or disjoint i32 %15, 1
  br label %20

17:                                               ; preds = %12
  %18 = or disjoint i32 %15, 1
  %19 = add nsw i32 %14, 1
  tail call void @_Z6Updateiidii(i32 noundef %18, i32 noundef %1, double noundef %2, i32 noundef %19, i32 noundef %4)
  br label %20

20:                                               ; preds = %17, %16
  %.pre-phi25 = phi i32 [ %18, %17 ], [ %.pre, %16 ]
  %21 = sext i32 %15 to i64
  %22 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %21
  %23 = sext i32 %.pre-phi25 to i64
  %24 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %23
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = sext i32 %0 to i64
  %28 = getelementptr inbounds [4000004 x double], ptr @ST, i64 0, i64 %27
  store double %26, ptr %28, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %20, %7
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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 = { 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 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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