; LLVM IR from unitreerobotics/kinect_teleoperate :: src/sample_helper_libs/window_controller_3d (ViewControl)

; 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.ViewControl = type { %struct.ViewParameters, %struct.Viewport, i8, float, float, float }
%struct.ViewParameters = type { [3 x float], float, [3 x float], float, float, [3 x float], [3 x float], [3 x float] }
%struct.Viewport = type { i32, i32, i32, i32 }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN7linmathL9vec3_copyEPfPKf(ptr noundef, ptr noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ViewControl13GetViewMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ViewControl20GetPerspectiveMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104), ptr noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11ViewControl15ProjectToScreenEPfPKf(ptr noundef nonnull align 4 dereferenceable(104) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [4 x float], align 16
  %9 = alloca [4 x [4 x float]], align 16
  %10 = alloca [4 x [4 x float]], align 16
  %11 = alloca [4 x [4 x float]], align 16
  %12 = alloca [4 x float], align 16
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %15 = getelementptr inbounds [4 x float], ptr %8, i64 0, i64 0
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN7linmathL9vec3_copyEPfPKf(ptr noundef %15, ptr noundef %16)
  %17 = getelementptr inbounds [4 x float], ptr %8, i64 0, i64 3
  store float 1.000000e+00, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 64, ptr %9) #5
  %18 = getelementptr inbounds [4 x [4 x float]], ptr %9, i64 0, i64 0
  call void @_ZN11ViewControl20GetPerspectiveMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104) %14, ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 64, ptr %10) #5
  %19 = getelementptr inbounds [4 x [4 x float]], ptr %10, i64 0, i64 0
  call void @_ZN11ViewControl13GetViewMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104) %14, ptr noundef %19)
  call void @llvm.lifetime.start.p0(i64 64, ptr %11) #5
  %20 = getelementptr inbounds [4 x [4 x float]], ptr %11, i64 0, i64 0
  %21 = getelementptr inbounds [4 x [4 x float]], ptr %9, i64 0, i64 0
  %22 = getelementptr inbounds [4 x [4 x float]], ptr %10, i64 0, i64 0
  call void @_ZN7linmathL10mat4x4_mulEPA4_fS1_S1_(ptr noundef %20, ptr noundef %21, ptr noundef %22)
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  %23 = getelementptr inbounds [4 x float], ptr %12, i64 0, i64 0
  %24 = getelementptr inbounds [4 x [4 x float]], ptr %11, i64 0, i64 0
  %25 = getelementptr inbounds [4 x float], ptr %8, i64 0, i64 0
  call void @_ZN7linmathL15mat4x4_mul_vec4EPfPA4_fS0_(ptr noundef %23, ptr noundef %24, ptr noundef %25)
  %26 = getelementptr inbounds [4 x float], ptr %12, i64 0, i64 3
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = fcmp oeq float %27, 0.000000e+00
  br i1 %28, label %29, label %30

29:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %13, align 4
  br label %69

30:                                               ; preds = %3
  %31 = getelementptr inbounds [4 x float], ptr %12, i64 0, i64 0
  %32 = load float, ptr %31, align 16, !tbaa !9
  %33 = getelementptr inbounds [4 x float], ptr %12, i64 0, i64 3
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = fdiv float %32, %34
  %36 = fadd float 1.000000e+00, %35
  %37 = fdiv float %36, 2.000000e+00
  %38 = getelementptr inbounds %class.ViewControl, ptr %14, i32 0, i32 1
  %39 = getelementptr inbounds %struct.Viewport, ptr %38, i32 0, i32 2
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = sitofp i32 %40 to float
  %42 = getelementptr inbounds %class.ViewControl, ptr %14, i32 0, i32 1
  %43 = getelementptr inbounds %struct.Viewport, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !17
  %45 = sitofp i32 %44 to float
  %46 = call float @llvm.fmuladd.f32(float %37, float %41, float %45)
  %47 = fadd float %46, 5.000000e-01
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds float, ptr %48, i64 0
  store float %47, ptr %49, align 4, !tbaa !9
  %50 = getelementptr inbounds [4 x float], ptr %12, i64 0, i64 1
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = getelementptr inbounds [4 x float], ptr %12, i64 0, i64 3
  %53 = load float, ptr %52, align 4, !tbaa !9
  %54 = fdiv float %51, %53
  %55 = fadd float 1.000000e+00, %54
  %56 = fdiv float %55, 2.000000e+00
  %57 = getelementptr inbounds %class.ViewControl, ptr %14, i32 0, i32 1
  %58 = getelementptr inbounds %struct.Viewport, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !18
  %60 = sitofp i32 %59 to float
  %61 = getelementptr inbounds %class.ViewControl, ptr %14, i32 0, i32 1
  %62 = getelementptr inbounds %struct.Viewport, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !19
  %64 = sitofp i32 %63 to float
  %65 = call float @llvm.fmuladd.f32(float %56, float %60, float %64)
  %66 = fadd float %65, 5.000000e-01
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds float, ptr %67, i64 1
  store float %66, ptr %68, align 4, !tbaa !9
  store i1 true, ptr %4, align 1
  store i32 1, ptr %13, align 4
  br label %69

69:                                               ; preds = %30, %29
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  %70 = load i1, ptr %4, align 1
  ret i1 %70
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZN7linmathL10mat4x4_mulEPA4_fS1_S1_(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN7linmathL15mat4x4_mul_vec4EPfPA4_fS0_(ptr noundef, ptr noundef, ptr noundef) #0

attributes #0 = { 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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { inlinehint 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 #5 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !15, i64 80}
!12 = !{!"_ZTS11ViewControl", !13, i64 0, !14, i64 72, !16, i64 88, !10, i64 92, !10, i64 96, !10, i64 100}
!13 = !{!"_ZTS14ViewParameters", !7, i64 0, !10, i64 12, !7, i64 16, !10, i64 28, !10, i64 32, !7, i64 36, !7, i64 48, !7, i64 60}
!14 = !{!"_ZTS8Viewport", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!12, !15, i64 72}
!18 = !{!12, !15, i64 84}
!19 = !{!12, !15, i64 76}


; 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: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN7linmathL9vec3_copyEPfPKf(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ViewControl13GetViewMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11ViewControl20GetPerspectiveMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11ViewControl15ProjectToScreenEPfPKf(ptr noundef nonnull align 4 dereferenceable(104) %0, ptr nocapture noundef writeonly %1, ptr noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca [4 x float], align 16
  %5 = alloca [4 x [4 x float]], align 16
  %6 = alloca [4 x [4 x float]], align 16
  %7 = alloca [4 x [4 x float]], align 16
  %8 = alloca [4 x float], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  call void @_ZN7linmathL9vec3_copyEPfPKf(ptr noundef nonnull %4, ptr noundef %2)
  %9 = getelementptr inbounds i8, ptr %4, i64 12
  store float 1.000000e+00, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #5
  call void @_ZN11ViewControl20GetPerspectiveMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104) %0, ptr noundef nonnull %5)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #5
  call void @_ZN11ViewControl13GetViewMatrixEPA4_f(ptr noundef nonnull align 4 dereferenceable(104) %0, ptr noundef nonnull %6)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %7) #5
  call void @_ZN7linmathL10mat4x4_mulEPA4_fS1_S1_(ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %6)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  call void @_ZN7linmathL15mat4x4_mul_vec4EPfPA4_fS0_(ptr noundef nonnull %8, ptr noundef nonnull %7, ptr noundef nonnull %4)
  %10 = getelementptr inbounds i8, ptr %8, i64 12
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fcmp une float %11, 0.000000e+00
  br i1 %12, label %13, label %28

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  %15 = getelementptr inbounds i8, ptr %0, i64 80
  %16 = load <2 x float>, ptr %8, align 16, !tbaa !5
  %17 = insertelement <2 x float> poison, float %11, i64 0
  %18 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> zeroinitializer
  %19 = fdiv <2 x float> %16, %18
  %20 = fadd <2 x float> %19, <float 1.000000e+00, float 1.000000e+00>
  %21 = fmul <2 x float> %20, <float 5.000000e-01, float 5.000000e-01>
  %22 = load <2 x i32>, ptr %15, align 4, !tbaa !9
  %23 = sitofp <2 x i32> %22 to <2 x float>
  %24 = load <2 x i32>, ptr %14, align 4, !tbaa !9
  %25 = sitofp <2 x i32> %24 to <2 x float>
  %26 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %21, <2 x float> %23, <2 x float> %25)
  %27 = fadd <2 x float> %26, <float 5.000000e-01, float 5.000000e-01>
  store <2 x float> %27, ptr %1, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %3, %13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  ret i1 %12
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZN7linmathL10mat4x4_mulEPA4_fS1_S1_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZN7linmathL15mat4x4_mul_vec4EPfPA4_fS0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #4

attributes #0 = { 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass