; LLVM IR from unitreerobotics/kinect_teleoperate :: src/mujoco-3.1.5/simulate (platform_ui_adapter)

; 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.std::pair" = type { i32, i32 }
%"class.mujoco::PlatformUIAdapter" = type <{ ptr, %struct.mjuiState_, i32, [4 x i8], ptr, ptr, %struct.mjrContext_, ptr, i32, [4 x i8] }>
%struct.mjuiState_ = type { i32, [25 x %struct.mjrRect_], ptr, i32, i32, i32, i32, i32, i32, double, double, double, double, double, double, double, i32, i32, i32, i32, double, i32, i32, i32, i32, ptr }
%struct.mjrRect_ = type { i32, i32, i32, i32 }
%struct.mjrContext_ = type { float, float, float, float, float, [4 x float], i32, i32, i32, i32, i32, [10 x i32], [10 x i32], [10 x i32], i32, i32, i32, i32, i32, i32, i32, i32, [10 x i32], [10 x i32], [10 x i32], [10 x i32], i32, [100 x i32], [100 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, [127 x i32], [127 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6mujoco17PlatformUIAdapter15UpdateMjuiStateEv(ptr noundef nonnull align 8 dereferenceable(2900)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6mujoco17PlatformUIAdapter8OnScrollEdd(ptr noundef nonnull align 8 dereferenceable(2900) %0, double noundef %1, double noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca %"struct.std::pair", align 4
  %9 = alloca %"struct.std::pair", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  call void @_ZN6mujoco17PlatformUIAdapter15UpdateMjuiStateEv(ptr noundef nonnull align 8 dereferenceable(2900) %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds ptr, ptr %11, i64 6
  %13 = load ptr, ptr %12, align 8
  %14 = call i64 %13(ptr noundef nonnull align 8 dereferenceable(2900) %10)
  store i64 %14, ptr %8, align 4
  %15 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 0
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = sitofp i32 %16 to double
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %18 = load ptr, ptr %10, align 8, !tbaa !11
  %19 = getelementptr inbounds ptr, ptr %18, i64 7
  %20 = load ptr, ptr %19, align 8
  %21 = call i64 %20(ptr noundef nonnull align 8 dereferenceable(2900) %10)
  store i64 %21, ptr %9, align 4
  %22 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %17, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  store double %25, ptr %7, align 8, !tbaa !9
  %26 = getelementptr inbounds %"class.mujoco::PlatformUIAdapter", ptr %10, i32 0, i32 1
  %27 = getelementptr inbounds %struct.mjuiState_, ptr %26, i32 0, i32 3
  store i32 4, ptr %27, align 8, !tbaa !16
  %28 = load double, ptr %5, align 8, !tbaa !9
  %29 = load double, ptr %7, align 8, !tbaa !9
  %30 = fmul double %28, %29
  %31 = getelementptr inbounds %"class.mujoco::PlatformUIAdapter", ptr %10, i32 0, i32 1
  %32 = getelementptr inbounds %struct.mjuiState_, ptr %31, i32 0, i32 14
  store double %30, ptr %32, align 8, !tbaa !21
  %33 = load double, ptr %6, align 8, !tbaa !9
  %34 = load double, ptr %7, align 8, !tbaa !9
  %35 = fmul double %33, %34
  %36 = getelementptr inbounds %"class.mujoco::PlatformUIAdapter", ptr %10, i32 0, i32 1
  %37 = getelementptr inbounds %struct.mjuiState_, ptr %36, i32 0, i32 15
  store double %35, ptr %37, align 8, !tbaa !22
  %38 = getelementptr inbounds %"class.mujoco::PlatformUIAdapter", ptr %10, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !23
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %45

41:                                               ; preds = %3
  %42 = getelementptr inbounds %"class.mujoco::PlatformUIAdapter", ptr %10, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !23
  %44 = getelementptr inbounds %"class.mujoco::PlatformUIAdapter", ptr %10, i32 0, i32 1
  call void %43(ptr noundef %44)
  br label %45

45:                                               ; preds = %41, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSSt4pairIiiE", !15, i64 0, !15, i64 4}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !15, i64 424}
!17 = !{!"_ZTSN6mujoco17PlatformUIAdapterE", !18, i64 8, !15, i64 552, !6, i64 560, !6, i64 568, !19, i64 576, !6, i64 2888, !15, i64 2896}
!18 = !{!"_ZTS10mjuiState_", !15, i64 0, !7, i64 4, !6, i64 408, !15, i64 416, !15, i64 420, !15, i64 424, !15, i64 428, !15, i64 432, !15, i64 436, !10, i64 440, !10, i64 448, !10, i64 456, !10, i64 464, !10, i64 472, !10, i64 480, !10, i64 488, !15, i64 496, !15, i64 500, !15, i64 504, !15, i64 508, !10, i64 512, !15, i64 520, !15, i64 524, !15, i64 528, !15, i64 532, !6, i64 536}
!19 = !{!"_ZTS11mjrContext_", !20, i64 0, !20, i64 4, !20, i64 8, !20, i64 12, !20, i64 16, !7, i64 20, !15, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !7, i64 56, !7, i64 96, !7, i64 136, !15, i64 176, !15, i64 180, !15, i64 184, !15, i64 188, !15, i64 192, !15, i64 196, !15, i64 200, !15, i64 204, !7, i64 208, !7, i64 248, !7, i64 288, !7, i64 328, !15, i64 368, !7, i64 372, !7, i64 772, !15, i64 1172, !15, i64 1176, !15, i64 1180, !15, i64 1184, !15, i64 1188, !15, i64 1192, !15, i64 1196, !15, i64 1200, !15, i64 1204, !15, i64 1208, !15, i64 1212, !15, i64 1216, !15, i64 1220, !6, i64 1224, !6, i64 1232, !6, i64 1240, !6, i64 1248, !7, i64 1256, !7, i64 1764, !15, i64 2272, !15, i64 2276, !15, i64 2280, !15, i64 2284, !15, i64 2288, !15, i64 2292, !15, i64 2296, !15, i64 2300, !15, i64 2304, !15, i64 2308}
!20 = !{!"float", !7, i64 0}
!21 = !{!17, !10, i64 488}
!22 = !{!17, !10, i64 496}
!23 = !{!17, !6, i64 560}


; 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: mustprogress uwtable
declare dso_local void @_ZN6mujoco17PlatformUIAdapter15UpdateMjuiStateEv(ptr noundef nonnull align 8 dereferenceable(2900)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6mujoco17PlatformUIAdapter8OnScrollEdd(ptr noundef nonnull align 8 dereferenceable(2900) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN6mujoco17PlatformUIAdapter15UpdateMjuiStateEv(ptr noundef nonnull align 8 dereferenceable(2900) %0)
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 48
  %6 = load ptr, ptr %5, align 8
  %7 = tail call i64 %6(ptr noundef nonnull align 8 dereferenceable(2900) %0)
  %.sroa.01.0.extract.trunc = trunc i64 %7 to i32
  %8 = sitofp i32 %.sroa.01.0.extract.trunc to double
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 56
  %11 = load ptr, ptr %10, align 8
  %12 = tail call i64 %11(ptr noundef nonnull align 8 dereferenceable(2900) %0)
  %.sroa.0.0.extract.trunc = trunc i64 %12 to i32
  %13 = sitofp i32 %.sroa.0.0.extract.trunc to double
  %14 = fdiv double %8, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 424
  store i32 4, ptr %15, align 8, !tbaa !8
  %16 = getelementptr inbounds i8, ptr %0, i64 488
  %17 = insertelement <2 x double> poison, double %14, i64 0
  %18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
  %19 = insertelement <2 x double> poison, double %1, i64 0
  %20 = insertelement <2 x double> %19, double %2, i64 1
  %21 = fmul <2 x double> %18, %20
  store <2 x double> %21, ptr %16, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %0, i64 560
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %26, label %24

24:                                               ; preds = %3
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void %23(ptr noundef nonnull %25)
  br label %26

26:                                               ; preds = %24, %3
  ret void
}

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 424}
!9 = !{!"_ZTSN6mujoco17PlatformUIAdapterE", !10, i64 8, !11, i64 552, !13, i64 560, !13, i64 568, !15, i64 576, !13, i64 2888, !11, i64 2896}
!10 = !{!"_ZTS10mjuiState_", !11, i64 0, !12, i64 4, !13, i64 408, !11, i64 416, !11, i64 420, !11, i64 424, !11, i64 428, !11, i64 432, !11, i64 436, !14, i64 440, !14, i64 448, !14, i64 456, !14, i64 464, !14, i64 472, !14, i64 480, !14, i64 488, !11, i64 496, !11, i64 500, !11, i64 504, !11, i64 508, !14, i64 512, !11, i64 520, !11, i64 524, !11, i64 528, !11, i64 532, !13, i64 536}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"any pointer", !12, i64 0}
!14 = !{!"double", !12, i64 0}
!15 = !{!"_ZTS11mjrContext_", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !12, i64 20, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !12, i64 56, !12, i64 96, !12, i64 136, !11, i64 176, !11, i64 180, !11, i64 184, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !12, i64 208, !12, i64 248, !12, i64 288, !12, i64 328, !11, i64 368, !12, i64 372, !12, i64 772, !11, i64 1172, !11, i64 1176, !11, i64 1180, !11, i64 1184, !11, i64 1188, !11, i64 1192, !11, i64 1196, !11, i64 1200, !11, i64 1204, !11, i64 1208, !11, i64 1212, !11, i64 1216, !11, i64 1220, !13, i64 1224, !13, i64 1232, !13, i64 1240, !13, i64 1248, !12, i64 1256, !12, i64 1764, !11, i64 2272, !11, i64 2276, !11, i64 2280, !11, i64 2284, !11, i64 2288, !11, i64 2292, !11, i64 2296, !11, i64 2300, !11, i64 2304, !11, i64 2308}
!16 = !{!"float", !12, i64 0}
!17 = !{!14, !14, i64 0}
!18 = !{!9, !13, i64 560}


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