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

%struct.ViewParameters = type { [3 x float], float, [3 x float], float, float, [3 x float], [3 x float], [3 x float] }
%class.ViewControl = type { %struct.ViewParameters, %struct.Viewport, i8, float, float, float }
%struct.Viewport = type { i32, i32, i32, i32 }

@_ZL12kDefaultView = external hidden global %struct.ViewParameters, align 4
@_ZL10kRightView = external hidden global %struct.ViewParameters, align 4
@_ZL9kBackView = external hidden global %struct.ViewParameters, align 4
@_ZL9kLeftView = external hidden global %struct.ViewParameters, align 4
@_ZL8kTopView = external hidden global %struct.ViewParameters, align 4

; 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) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11ViewControl12SetViewPointE9ViewPoint(ptr noundef nonnull align 4 dereferenceable(104) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %6, label %22 [
    i32 0, label %7
    i32 1, label %10
    i32 2, label %13
    i32 3, label %16
    i32 4, label %19
  ]

7:                                                ; preds = %2
  %8 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 @_ZL12kDefaultView, i64 72, i1 false), !tbaa.struct !11
  %9 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 5
  store float 1.000000e+00, ptr %9, align 4, !tbaa !15
  br label %22

10:                                               ; preds = %2
  %11 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 @_ZL10kRightView, i64 72, i1 false), !tbaa.struct !11
  %12 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 5
  store float 0x3FD3333340000000, ptr %12, align 4, !tbaa !15
  br label %22

13:                                               ; preds = %2
  %14 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 @_ZL9kLeftView, i64 72, i1 false), !tbaa.struct !11
  %15 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 5
  store float 0x3FD3333340000000, ptr %15, align 4, !tbaa !15
  br label %22

16:                                               ; preds = %2
  %17 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 @_ZL9kBackView, i64 72, i1 false), !tbaa.struct !11
  %18 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 5
  store float 0x3FD3333340000000, ptr %18, align 4, !tbaa !15
  br label %22

19:                                               ; preds = %2
  %20 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 @_ZL8kTopView, i64 72, i1 false), !tbaa.struct !11
  %21 = getelementptr inbounds %class.ViewControl, ptr %5, i32 0, i32 5
  store float 0x3FD3333340000000, ptr %21, align 4, !tbaa !15
  br label %22

22:                                               ; preds = %19, %16, %13, %10, %7, %2
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS9ViewPoint", !7, i64 0}
!11 = !{i64 0, i64 12, !12, i64 12, i64 4, !13, i64 16, i64 12, !12, i64 28, i64 4, !13, i64 32, i64 4, !13, i64 36, i64 12, !12, i64 48, i64 12, !12, i64 60, i64 12, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !14, i64 100}
!16 = !{!"_ZTS11ViewControl", !17, i64 0, !18, i64 72, !20, i64 88, !14, i64 92, !14, i64 96, !14, i64 100}
!17 = !{!"_ZTS14ViewParameters", !7, i64 0, !14, i64 12, !7, i64 16, !14, i64 28, !14, i64 32, !7, i64 36, !7, i64 48, !7, i64 60}
!18 = !{!"_ZTS8Viewport", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12}
!19 = !{!"int", !7, i64 0}
!20 = !{!"bool", !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"

%struct.ViewParameters = type { [3 x float], float, [3 x float], float, float, [3 x float], [3 x float], [3 x float] }

@_ZL12kDefaultView = external hidden local_unnamed_addr global %struct.ViewParameters, align 4
@_ZL10kRightView = external hidden local_unnamed_addr global %struct.ViewParameters, align 4
@_ZL9kBackView = external hidden local_unnamed_addr global %struct.ViewParameters, align 4
@_ZL9kLeftView = external hidden local_unnamed_addr global %struct.ViewParameters, align 4
@_ZL8kTopView = external hidden local_unnamed_addr global %struct.ViewParameters, align 4

; Function Attrs: mustprogress 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) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN11ViewControl12SetViewPointE9ViewPoint(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(104) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  switch i32 %1, label %9 [
    i32 0, label %3
    i32 1, label %4
    i32 2, label %5
    i32 3, label %6
    i32 4, label %7
  ]

3:                                                ; preds = %2
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(72) %0, ptr noundef nonnull align 4 dereferenceable(72) @_ZL12kDefaultView, i64 72, i1 false), !tbaa.struct !5
  br label %.sink.split

4:                                                ; preds = %2
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(72) %0, ptr noundef nonnull align 4 dereferenceable(72) @_ZL10kRightView, i64 72, i1 false), !tbaa.struct !5
  br label %.sink.split

5:                                                ; preds = %2
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(72) %0, ptr noundef nonnull align 4 dereferenceable(72) @_ZL9kLeftView, i64 72, i1 false), !tbaa.struct !5
  br label %.sink.split

6:                                                ; preds = %2
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(72) %0, ptr noundef nonnull align 4 dereferenceable(72) @_ZL9kBackView, i64 72, i1 false), !tbaa.struct !5
  br label %.sink.split

7:                                                ; preds = %2
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(72) %0, ptr noundef nonnull align 4 dereferenceable(72) @_ZL8kTopView, i64 72, i1 false), !tbaa.struct !5
  br label %.sink.split

.sink.split:                                      ; preds = %3, %4, %5, %6, %7
  %.sink = phi float [ 0x3FD3333340000000, %7 ], [ 0x3FD3333340000000, %6 ], [ 0x3FD3333340000000, %5 ], [ 0x3FD3333340000000, %4 ], [ 1.000000e+00, %3 ]
  %8 = getelementptr inbounds i8, ptr %0, i64 100
  store float %.sink, ptr %8, align 4, !tbaa !11
  br label %9

9:                                                ; preds = %.sink.split, %2
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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 = !{i64 0, i64 12, !6, i64 12, i64 4, !9, i64 16, i64 12, !6, i64 28, i64 4, !9, i64 32, i64 4, !9, i64 36, i64 12, !6, i64 48, i64 12, !6, i64 60, i64 12, !6}
!6 = !{!7, !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, !10, i64 100}
!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}


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