; LLVM IR from openanolis/openssl :: ssl/quic (quic_statm)

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

%struct.OSSL_TIME = type { i64 }
%struct.ossl_statm_st = type { %struct.OSSL_TIME, %struct.OSSL_TIME, %struct.OSSL_TIME, %struct.OSSL_TIME, i8 }

; Function Attrs: nounwind uwtable
define dso_local void @ossl_statm_update_rtt(ptr noundef %0, i64 %1, i64 %2) #0 {
  %4 = alloca %struct.OSSL_TIME, align 8
  %5 = alloca %struct.OSSL_TIME, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.OSSL_TIME, align 8
  %8 = alloca %struct.OSSL_TIME, align 8
  %9 = alloca %struct.OSSL_TIME, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.OSSL_TIME, align 8
  %12 = alloca %struct.OSSL_TIME, align 8
  %13 = alloca %struct.OSSL_TIME, align 8
  %14 = alloca %struct.OSSL_TIME, align 8
  %15 = alloca %struct.OSSL_TIME, align 8
  %16 = alloca %struct.OSSL_TIME, align 8
  %17 = alloca %struct.OSSL_TIME, align 8
  %18 = alloca %struct.OSSL_TIME, align 8
  %19 = alloca %struct.OSSL_TIME, align 8
  %20 = getelementptr inbounds %struct.OSSL_TIME, ptr %4, i32 0, i32 0
  store i64 %1, ptr %20, align 8
  %21 = getelementptr inbounds %struct.OSSL_TIME, ptr %5, i32 0, i32 0
  store i64 %2, ptr %21, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %5, i64 8, i1 false), !tbaa.struct !9
  %22 = getelementptr inbounds %struct.OSSL_TIME, ptr %8, i32 0, i32 0
  %23 = load i64, ptr %22, align 8
  %24 = call i32 @ossl_time_is_zero(i64 %23)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %3
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ossl_statm_st, ptr %27, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %28, i64 8, i1 false), !tbaa.struct !9
  br label %32

29:                                               ; preds = %3
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ossl_statm_st, ptr %30, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %31, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !9
  br label %32

32:                                               ; preds = %29, %26
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ossl_statm_st, ptr %33, i32 0, i32 4
  %35 = load i8, ptr %34, align 8, !tbaa !12
  %36 = icmp ne i8 %35, 0
  br i1 %36, label %50, label %37

37:                                               ; preds = %32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ossl_statm_st, ptr %38, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %39, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !9
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ossl_statm_st, ptr %40, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %41, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ossl_statm_st, ptr %42, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %44 = getelementptr inbounds %struct.OSSL_TIME, ptr %8, i32 0, i32 0
  %45 = load i64, ptr %44, align 8
  %46 = call i64 @ossl_time_divide(i64 %45, i64 noundef 2)
  %47 = getelementptr inbounds %struct.OSSL_TIME, ptr %9, i32 0, i32 0
  store i64 %46, ptr %47, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %43, ptr align 8 %9, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ossl_statm_st, ptr %48, i32 0, i32 4
  store i8 1, ptr %49, align 8, !tbaa !12
  store i32 1, ptr %10, align 4
  br label %129

50:                                               ; preds = %32
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ossl_statm_st, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds %struct.OSSL_TIME, ptr %8, i32 0, i32 0
  %54 = load i64, ptr %53, align 8
  %55 = getelementptr inbounds %struct.OSSL_TIME, ptr %52, i32 0, i32 0
  %56 = load i64, ptr %55, align 8
  %57 = call i32 @ossl_time_compare(i64 %54, i64 %56)
  %58 = icmp slt i32 %57, 0
  br i1 %58, label %59, label %62

59:                                               ; preds = %50
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ossl_statm_st, ptr %60, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !9
  br label %62

62:                                               ; preds = %59, %50
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %8, i64 8, i1 false), !tbaa.struct !9
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ossl_statm_st, ptr %63, i32 0, i32 2
  %65 = getelementptr inbounds %struct.OSSL_TIME, ptr %64, i32 0, i32 0
  %66 = load i64, ptr %65, align 8
  %67 = getelementptr inbounds %struct.OSSL_TIME, ptr %4, i32 0, i32 0
  %68 = load i64, ptr %67, align 8
  %69 = call i64 @ossl_time_add(i64 %66, i64 %68)
  %70 = getelementptr inbounds %struct.OSSL_TIME, ptr %11, i32 0, i32 0
  store i64 %69, ptr %70, align 8
  %71 = getelementptr inbounds %struct.OSSL_TIME, ptr %8, i32 0, i32 0
  %72 = load i64, ptr %71, align 8
  %73 = getelementptr inbounds %struct.OSSL_TIME, ptr %11, i32 0, i32 0
  %74 = load i64, ptr %73, align 8
  %75 = call i32 @ossl_time_compare(i64 %72, i64 %74)
  %76 = icmp sge i32 %75, 0
  br i1 %76, label %77, label %84

77:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %78 = getelementptr inbounds %struct.OSSL_TIME, ptr %8, i32 0, i32 0
  %79 = load i64, ptr %78, align 8
  %80 = getelementptr inbounds %struct.OSSL_TIME, ptr %4, i32 0, i32 0
  %81 = load i64, ptr %80, align 8
  %82 = call i64 @ossl_time_subtract(i64 %79, i64 %81)
  %83 = getelementptr inbounds %struct.OSSL_TIME, ptr %12, i32 0, i32 0
  store i64 %82, ptr %83, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %12, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %84

84:                                               ; preds = %77, %62
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ossl_statm_st, ptr %85, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ossl_statm_st, ptr %87, i32 0, i32 3
  %89 = getelementptr inbounds %struct.OSSL_TIME, ptr %88, i32 0, i32 0
  %90 = load i64, ptr %89, align 8
  %91 = call i64 @ossl_time_multiply(i64 %90, i64 noundef 3)
  %92 = getelementptr inbounds %struct.OSSL_TIME, ptr %15, i32 0, i32 0
  store i64 %91, ptr %92, align 8
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.ossl_statm_st, ptr %93, i32 0, i32 0
  %95 = getelementptr inbounds %struct.OSSL_TIME, ptr %94, i32 0, i32 0
  %96 = load i64, ptr %95, align 8
  %97 = getelementptr inbounds %struct.OSSL_TIME, ptr %7, i32 0, i32 0
  %98 = load i64, ptr %97, align 8
  %99 = call i64 @ossl_time_abs_difference(i64 %96, i64 %98)
  %100 = getelementptr inbounds %struct.OSSL_TIME, ptr %16, i32 0, i32 0
  store i64 %99, ptr %100, align 8
  %101 = getelementptr inbounds %struct.OSSL_TIME, ptr %15, i32 0, i32 0
  %102 = load i64, ptr %101, align 8
  %103 = getelementptr inbounds %struct.OSSL_TIME, ptr %16, i32 0, i32 0
  %104 = load i64, ptr %103, align 8
  %105 = call i64 @ossl_time_add(i64 %102, i64 %104)
  %106 = getelementptr inbounds %struct.OSSL_TIME, ptr %14, i32 0, i32 0
  store i64 %105, ptr %106, align 8
  %107 = getelementptr inbounds %struct.OSSL_TIME, ptr %14, i32 0, i32 0
  %108 = load i64, ptr %107, align 8
  %109 = call i64 @ossl_time_divide(i64 %108, i64 noundef 4)
  %110 = getelementptr inbounds %struct.OSSL_TIME, ptr %13, i32 0, i32 0
  store i64 %109, ptr %110, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %86, ptr align 8 %13, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.ossl_statm_st, ptr %111, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.ossl_statm_st, ptr %113, i32 0, i32 0
  %115 = getelementptr inbounds %struct.OSSL_TIME, ptr %114, i32 0, i32 0
  %116 = load i64, ptr %115, align 8
  %117 = call i64 @ossl_time_multiply(i64 %116, i64 noundef 7)
  %118 = getelementptr inbounds %struct.OSSL_TIME, ptr %19, i32 0, i32 0
  store i64 %117, ptr %118, align 8
  %119 = getelementptr inbounds %struct.OSSL_TIME, ptr %19, i32 0, i32 0
  %120 = load i64, ptr %119, align 8
  %121 = getelementptr inbounds %struct.OSSL_TIME, ptr %7, i32 0, i32 0
  %122 = load i64, ptr %121, align 8
  %123 = call i64 @ossl_time_add(i64 %120, i64 %122)
  %124 = getelementptr inbounds %struct.OSSL_TIME, ptr %18, i32 0, i32 0
  store i64 %123, ptr %124, align 8
  %125 = getelementptr inbounds %struct.OSSL_TIME, ptr %18, i32 0, i32 0
  %126 = load i64, ptr %125, align 8
  %127 = call i64 @ossl_time_divide(i64 %126, i64 noundef 8)
  %128 = getelementptr inbounds %struct.OSSL_TIME, ptr %17, i32 0, i32 0
  store i64 %127, ptr %128, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %112, ptr align 8 %17, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  store i32 0, ptr %10, align 4
  br label %129

129:                                              ; preds = %84, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %130 = load i32, ptr %10, align 4
  switch i32 %130, label %132 [
    i32 0, label %131
    i32 1, label %131
  ]

131:                                              ; preds = %129, %129
  ret void

132:                                              ; preds = %129
  unreachable
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ossl_time_is_zero(i64) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_divide(i64, i64 noundef) #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ossl_time_compare(i64, i64) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_add(i64, i64) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_subtract(i64, i64) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_multiply(i64, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_abs_difference(i64, i64) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !7, i64 32}
!13 = !{!"ossl_statm_st", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !7, i64 32}
!14 = !{!"", !11, 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"

; Function Attrs: nounwind uwtable
define dso_local void @ossl_statm_update_rtt(ptr nocapture noundef %0, i64 %1, i64 %2) local_unnamed_addr #0 {
  %4 = tail call i32 @ossl_time_is_zero(i64 %2)
  %.not = icmp eq i32 %4, 0
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %.not, label %7, label %6

6:                                                ; preds = %3
  %.sroa.010.0.copyload11 = load i64, ptr %5, align 8, !tbaa !5
  br label %8

7:                                                ; preds = %3
  store i64 %2, ptr %5, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %7, %6
  %.sroa.010.0 = phi i64 [ %.sroa.010.0.copyload11, %6 ], [ %2, %7 ]
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i8, ptr %9, align 8, !tbaa !9
  %.not40 = icmp eq i8 %10, 0
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  br i1 %.not40, label %12, label %15

12:                                               ; preds = %8
  store i64 %.sroa.010.0, ptr %11, align 8, !tbaa !5
  store i64 %.sroa.010.0, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = tail call i64 @ossl_time_divide(i64 %.sroa.010.0, i64 noundef 2)
  store i64 %14, ptr %13, align 8, !tbaa !5
  store i8 1, ptr %9, align 8, !tbaa !9
  br label %39

15:                                               ; preds = %8
  %16 = load i64, ptr %11, align 8
  %17 = tail call i32 @ossl_time_compare(i64 %.sroa.010.0, i64 %16)
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %._crit_edge

._crit_edge:                                      ; preds = %15
  %.pre = load i64, ptr %11, align 8
  br label %20

19:                                               ; preds = %15
  store i64 %.sroa.010.0, ptr %11, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %._crit_edge, %19
  %21 = phi i64 [ %.pre, %._crit_edge ], [ %.sroa.010.0, %19 ]
  %22 = tail call i64 @ossl_time_add(i64 %21, i64 %1)
  %23 = tail call i32 @ossl_time_compare(i64 %.sroa.010.0, i64 %22)
  %24 = icmp sgt i32 %23, -1
  br i1 %24, label %25, label %27

25:                                               ; preds = %20
  %26 = tail call i64 @ossl_time_subtract(i64 %.sroa.010.0, i64 %1)
  br label %27

27:                                               ; preds = %25, %20
  %.sroa.021.0 = phi i64 [ %26, %25 ], [ %.sroa.010.0, %20 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = load i64, ptr %28, align 8
  %30 = tail call i64 @ossl_time_multiply(i64 %29, i64 noundef 3)
  %31 = load i64, ptr %0, align 8
  %32 = tail call i64 @ossl_time_abs_difference(i64 %31, i64 %.sroa.021.0)
  %33 = tail call i64 @ossl_time_add(i64 %30, i64 %32)
  %34 = tail call i64 @ossl_time_divide(i64 %33, i64 noundef 4)
  store i64 %34, ptr %28, align 8, !tbaa !5
  %35 = load i64, ptr %0, align 8
  %36 = tail call i64 @ossl_time_multiply(i64 %35, i64 noundef 7)
  %37 = tail call i64 @ossl_time_add(i64 %36, i64 %.sroa.021.0)
  %38 = tail call i64 @ossl_time_divide(i64 %37, i64 noundef 8)
  store i64 %38, ptr %0, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %27, %12
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ossl_time_is_zero(i64) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_divide(i64, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ossl_time_compare(i64, i64) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_add(i64, i64) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_subtract(i64, i64) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_multiply(i64, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @ossl_time_abs_difference(i64, i64) local_unnamed_addr #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 = { inlinehint 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 32}
!10 = !{!"ossl_statm_st", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32}
!11 = !{!"", !6, i64 0}


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