; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Graphics/R3DirectionalLight.ll (ZNK18R3DirectionalLight4DrawEi)

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK18R3DirectionalLight4DrawEi(ptr noundef nonnull align 8 dereferenceable(104) %0, i32 noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca [4 x float], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = add nsw i32 16384, %9
  store i32 %10, ptr %5, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp ugt i32 %11, 16391
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  store i32 1, ptr %6, align 4
  br label %61

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  %15 = call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %16 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %17 = call noundef double @_ZNK5RNRgb1REv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  %18 = fmul double %15, %17
  %19 = fptrunc double %18 to float
  %20 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  store float %19, ptr %20, align 16, !tbaa !11
  %21 = call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %22 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %23 = call noundef double @_ZNK5RNRgb1GEv(ptr noundef nonnull align 8 dereferenceable(24) %22)
  %24 = fmul double %21, %23
  %25 = fptrunc double %24 to float
  %26 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 1
  store float %25, ptr %26, align 4, !tbaa !11
  %27 = call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76) %8)
  %29 = call noundef double @_ZNK5RNRgb1BEv(ptr noundef nonnull align 8 dereferenceable(24) %28)
  %30 = fmul double %27, %29
  %31 = fptrunc double %30 to float
  %32 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 2
  store float %31, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 3
  store float 1.000000e+00, ptr %33, align 4, !tbaa !11
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  call void @glLightfv(i32 noundef %34, i32 noundef 4609, ptr noundef %35)
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  call void @glLightfv(i32 noundef %36, i32 noundef 4610, ptr noundef %37)
  %38 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104) %8)
  %39 = call noundef double @_ZNK8R3Vector1XEv(ptr noundef nonnull align 8 dereferenceable(24) %38)
  %40 = fneg double %39
  %41 = fptrunc double %40 to float
  %42 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  store float %41, ptr %42, align 16, !tbaa !11
  %43 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104) %8)
  %44 = call noundef double @_ZNK8R3Vector1YEv(ptr noundef nonnull align 8 dereferenceable(24) %43)
  %45 = fneg double %44
  %46 = fptrunc double %45 to float
  %47 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 1
  store float %46, ptr %47, align 4, !tbaa !11
  %48 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104) %8)
  %49 = call noundef double @_ZNK8R3Vector1ZEv(ptr noundef nonnull align 8 dereferenceable(24) %48)
  %50 = fneg double %49
  %51 = fptrunc double %50 to float
  %52 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 2
  store float %51, ptr %52, align 8, !tbaa !11
  %53 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 3
  store float 0.000000e+00, ptr %53, align 4, !tbaa !11
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  call void @glLightfv(i32 noundef %54, i32 noundef 4611, ptr noundef %55)
  %56 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  store float 1.800000e+02, ptr %56, align 16, !tbaa !11
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  %59 = load float, ptr %58, align 16, !tbaa !11
  call void @glLightf(i32 noundef %57, i32 noundef 4614, float noundef %59)
  %60 = load i32, ptr %5, align 4, !tbaa !9
  call void @glEnable(i32 noundef %60)
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  store i32 0, ptr %6, align 4
  br label %61

61:                                               ; preds = %14, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %62 = load i32, ptr %6, align 4
  switch i32 %62, label %64 [
    i32 0, label %63
    i32 1, label %63
  ]

63:                                               ; preds = %61, %61
  ret void

64:                                               ; preds = %61
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb1REv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb1GEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb1BEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

declare void @glLightfv(i32 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Vector1XEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Vector1YEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Vector1ZEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

declare void @glLightf(i32 noundef, i32 noundef, float noundef) #3

declare void @glEnable(i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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"

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK18R3DirectionalLight4DrawEi(ptr noundef nonnull align 8 dereferenceable(104) %0, i32 noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca [4 x float], align 16
  %4 = add nsw i32 %1, 16384
  %5 = icmp ugt i32 %4, 16391
  br i1 %5, label %39, label %6

6:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %7 = tail call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %9 = tail call noundef double @_ZNK5RNRgb1REv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = tail call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %11 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %12 = tail call noundef double @_ZNK5RNRgb1GEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = getelementptr inbounds i8, ptr %3, i64 4
  %14 = insertelement <2 x double> poison, double %7, i64 0
  %15 = insertelement <2 x double> %14, double %10, i64 1
  %16 = insertelement <2 x double> poison, double %9, i64 0
  %17 = insertelement <2 x double> %16, double %12, i64 1
  %18 = fmul <2 x double> %15, %17
  %19 = fptrunc <2 x double> %18 to <2 x float>
  store <2 x float> %19, ptr %3, align 16, !tbaa !5
  %20 = tail call noundef double @_ZNK7R3Light9IntensityEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %21 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK7R3Light5ColorEv(ptr noundef nonnull align 8 dereferenceable(76) %0)
  %22 = tail call noundef double @_ZNK5RNRgb1BEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  %23 = fmul double %20, %22
  %24 = fptrunc double %23 to float
  %25 = getelementptr inbounds i8, ptr %3, i64 8
  store float %24, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %3, i64 12
  store float 1.000000e+00, ptr %26, align 4, !tbaa !5
  call void @glLightfv(i32 noundef %4, i32 noundef 4609, ptr noundef nonnull %3)
  call void @glLightfv(i32 noundef %4, i32 noundef 4610, ptr noundef nonnull %3)
  %27 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %28 = call noundef double @_ZNK8R3Vector1XEv(ptr noundef nonnull align 8 dereferenceable(24) %27)
  %29 = fptrunc double %28 to float
  %30 = fneg float %29
  store float %30, ptr %3, align 16, !tbaa !5
  %31 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %32 = call noundef double @_ZNK8R3Vector1YEv(ptr noundef nonnull align 8 dereferenceable(24) %31)
  %33 = fptrunc double %32 to float
  %34 = fneg float %33
  store float %34, ptr %13, align 4, !tbaa !5
  %35 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK18R3DirectionalLight9DirectionEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %36 = call noundef double @_ZNK8R3Vector1ZEv(ptr noundef nonnull align 8 dereferenceable(24) %35)
  %37 = fptrunc double %36 to float
  %38 = fneg float %37
  store float %38, ptr %25, align 8, !tbaa !5
  store float 0.000000e+00, ptr %26, align 4, !tbaa !5
  call void @glLightfv(i32 noundef %4, i32 noundef 4611, ptr noundef nonnull %3)
  store float 1.800000e+02, ptr %3, align 16, !tbaa !5
  call void @glLightf(i32 noundef %4, i32 noundef 4614, float noundef 1.800000e+02)
  call void @glEnable(i32 noundef %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br label %39

39:                                               ; preds = %2, %6
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb1REv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb1GEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb1BEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

declare void @glLightfv(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Vector1XEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Vector1YEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK8R3Vector1ZEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

declare void @glLightf(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #3

declare void @glEnable(i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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