; LLVM IR from chriskiefer/libcccrt :: benchmarks/maximilian.ll (ZN12maxiEnvelope4lineEiRSt6vectorIdSaIdEE)

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

%class.maxiEnvelope = type { double, double, double, double, double, i32, i32, double }

@_ZN12maxiSettings10sampleRateE = external dso_local global i64, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN12maxiEnvelope4lineEiRSt6vectorIdSaIdEE(ptr noundef nonnull align 8 dereferenceable(56) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 5
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %115

11:                                               ; preds = %3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = add nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %16) #1
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = fmul double %18, 4.400000e-03
  %20 = fdiv double 4.000000e+00, %19
  %21 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 0
  store double %20, ptr %21, align 8, !tbaa !16
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = add nsw i32 %24, 2
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %26) #1
  %28 = load double, ptr %27, align 8, !tbaa !15
  %29 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 4
  store double %28, ptr %29, align 8, !tbaa !17
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = sext i32 %32 to i64
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %33) #1
  %35 = load double, ptr %34, align 8, !tbaa !15
  %36 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 3
  store double %35, ptr %36, align 8, !tbaa !18
  %37 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 3
  %38 = load double, ptr %37, align 8, !tbaa !18
  %39 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 7
  %40 = load double, ptr %39, align 8, !tbaa !19
  %41 = fsub double %38, %40
  %42 = fcmp ogt double %41, 0x3E7AD7F29ABCAF48
  br i1 %42, label %43, label %63

43:                                               ; preds = %11
  %44 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %45 = load i32, ptr %44, align 4, !tbaa !14
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %48, label %63

48:                                               ; preds = %43
  %49 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 3
  %50 = load double, ptr %49, align 8, !tbaa !18
  %51 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 2
  %52 = load double, ptr %51, align 8, !tbaa !20
  %53 = fsub double %50, %52
  %54 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !21
  %55 = uitofp i64 %54 to double
  %56 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 0
  %57 = load double, ptr %56, align 8, !tbaa !16
  %58 = fdiv double %55, %57
  %59 = fdiv double %53, %58
  %60 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 7
  %61 = load double, ptr %60, align 8, !tbaa !19
  %62 = fadd double %61, %59
  store double %62, ptr %60, align 8, !tbaa !19
  br label %111

63:                                               ; preds = %43, %11
  %64 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 3
  %65 = load double, ptr %64, align 8, !tbaa !18
  %66 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 7
  %67 = load double, ptr %66, align 8, !tbaa !19
  %68 = fsub double %65, %67
  %69 = fcmp olt double %68, 0xBE7AD7F29ABCAF48
  br i1 %69, label %70, label %91

70:                                               ; preds = %63
  %71 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %72 = load i32, ptr %71, align 4, !tbaa !14
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %75, label %91

75:                                               ; preds = %70
  %76 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 3
  %77 = load double, ptr %76, align 8, !tbaa !18
  %78 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 2
  %79 = load double, ptr %78, align 8, !tbaa !20
  %80 = fsub double %77, %79
  %81 = fmul double %80, -1.000000e+00
  %82 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !21
  %83 = uitofp i64 %82 to double
  %84 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 0
  %85 = load double, ptr %84, align 8, !tbaa !16
  %86 = fdiv double %83, %85
  %87 = fdiv double %81, %86
  %88 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 7
  %89 = load double, ptr %88, align 8, !tbaa !19
  %90 = fsub double %89, %87
  store double %90, ptr %88, align 8, !tbaa !19
  br label %110

91:                                               ; preds = %70, %63
  %92 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %93 = load i32, ptr %92, align 4, !tbaa !14
  %94 = load i32, ptr %5, align 4, !tbaa !9
  %95 = sub nsw i32 %94, 1
  %96 = icmp sgt i32 %93, %95
  br i1 %96, label %97, label %101

97:                                               ; preds = %91
  %98 = load i32, ptr %5, align 4, !tbaa !9
  %99 = sub nsw i32 %98, 2
  %100 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  store i32 %99, ptr %100, align 4, !tbaa !14
  br label %109

101:                                              ; preds = %91
  %102 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  %103 = load i32, ptr %102, align 4, !tbaa !14
  %104 = add nsw i32 %103, 2
  %105 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 6
  store i32 %104, ptr %105, align 4, !tbaa !14
  %106 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 3
  %107 = load double, ptr %106, align 8, !tbaa !18
  %108 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 2
  store double %107, ptr %108, align 8, !tbaa !20
  br label %109

109:                                              ; preds = %101, %97
  br label %110

110:                                              ; preds = %109, %75
  br label %111

111:                                              ; preds = %110, %48
  %112 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 7
  %113 = load double, ptr %112, align 8, !tbaa !19
  %114 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 1
  store double %113, ptr %114, align 8, !tbaa !23
  br label %117

115:                                              ; preds = %3
  %116 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 1
  store double 0.000000e+00, ptr %116, align 8, !tbaa !23
  br label %117

117:                                              ; preds = %115, %111
  %118 = getelementptr inbounds %class.maxiEnvelope, ptr %7, i32 0, i32 1
  %119 = load double, ptr %118, align 8, !tbaa !23
  ret double %119
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"_ZTS12maxiEnvelope", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !10, i64 40, !10, i64 44, !13, i64 48}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !10, i64 44}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !13, i64 0}
!17 = !{!12, !13, i64 32}
!18 = !{!12, !13, i64 24}
!19 = !{!12, !13, i64 48}
!20 = !{!12, !13, i64 16}
!21 = !{!22, !22, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!12, !13, i64 8}


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

@_ZN12maxiSettings10sampleRateE = external dso_local local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN12maxiEnvelope4lineEiRSt6vectorIdSaIdEE(ptr nocapture noundef nonnull align 8 dereferenceable(56) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %61

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 44
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = add nsw i32 %9, 1
  %11 = sext i32 %10 to i64
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %11) #1
  %13 = load double, ptr %12, align 8, !tbaa !12
  %14 = fmul double %13, 4.400000e-03
  %15 = fdiv double 4.000000e+00, %14
  store double %15, ptr %0, align 8, !tbaa !13
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = add nsw i32 %16, 2
  %18 = sext i32 %17 to i64
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %18) #1
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  store double %20, ptr %21, align 8, !tbaa !14
  %22 = load i32, ptr %8, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %23) #1
  %25 = load double, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  store double %25, ptr %26, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %0, i64 48
  %28 = load double, ptr %27, align 8, !tbaa !16
  %29 = fsub double %25, %28
  %30 = fcmp ogt double %29, 0x3E7AD7F29ABCAF48
  %31 = load i32, ptr %8, align 4
  %32 = icmp slt i32 %31, %1
  %or.cond = select i1 %30, i1 %32, i1 false
  br i1 %or.cond, label %33, label %43

33:                                               ; preds = %7
  %34 = getelementptr inbounds i8, ptr %0, i64 16
  %35 = load double, ptr %34, align 8, !tbaa !17
  %36 = fsub double %25, %35
  %37 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !18
  %38 = uitofp i64 %37 to double
  %39 = load double, ptr %0, align 8, !tbaa !13
  %40 = fdiv double %38, %39
  %41 = fdiv double %36, %40
  %42 = fadd double %28, %41
  store double %42, ptr %27, align 8, !tbaa !16
  br label %61

43:                                               ; preds = %7
  %44 = fcmp olt double %29, 0xBE7AD7F29ABCAF48
  %or.cond9 = select i1 %44, i1 %32, i1 false
  br i1 %or.cond9, label %45, label %55

45:                                               ; preds = %43
  %46 = getelementptr inbounds i8, ptr %0, i64 16
  %47 = load double, ptr %46, align 8, !tbaa !17
  %48 = fsub double %25, %47
  %49 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !18
  %50 = uitofp i64 %49 to double
  %51 = load double, ptr %0, align 8, !tbaa !13
  %52 = fdiv double %50, %51
  %53 = fdiv double %48, %52
  %54 = fadd double %28, %53
  store double %54, ptr %27, align 8, !tbaa !16
  br label %61

55:                                               ; preds = %43
  br i1 %32, label %58, label %56

56:                                               ; preds = %55
  %57 = add nsw i32 %1, -2
  store i32 %57, ptr %8, align 4, !tbaa !11
  br label %61

58:                                               ; preds = %55
  %59 = add nsw i32 %31, 2
  store i32 %59, ptr %8, align 4, !tbaa !11
  %60 = getelementptr inbounds i8, ptr %0, i64 16
  store double %25, ptr %60, align 8, !tbaa !17
  br label %61

61:                                               ; preds = %3, %33, %56, %58, %45
  %.sink = phi double [ %54, %45 ], [ %28, %58 ], [ %28, %56 ], [ %42, %33 ], [ 0.000000e+00, %3 ]
  %62 = getelementptr inbounds i8, ptr %0, i64 8
  store double %.sink, ptr %62, align 8, !tbaa !20
  ret double %.sink
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(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, !10, i64 40}
!6 = !{!"_ZTS12maxiEnvelope", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !7, i64 48}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 44}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 32}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 48}
!17 = !{!6, !7, i64 16}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !8, i64 0}
!20 = !{!6, !7, i64 8}


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