; LLVM IR from Dovyski/opengl-demos :: src/light/main.ll (Z7displayv)

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

@angObj = external dso_local global float, align 4
@angLight = external dso_local global float, align 4
@light_0_position = external dso_local global [4 x float], align 16
@light_1_position = external dso_local global [4 x float], align 16

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7displayv() #1 {
  call void @glClear(i32 noundef 16640)
  call void @glLoadIdentity()
  call void @glPushMatrix()
  call void @glTranslated(double noundef 4.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %1 = load float, ptr @angObj, align 4, !tbaa !5
  %2 = fpext float %1 to double
  %3 = fadd double %2, 1.000000e-01
  %4 = fptrunc double %3 to float
  store float %4, ptr @angObj, align 4, !tbaa !5
  %5 = fpext float %4 to double
  call void @glRotated(double noundef %5, double noundef 1.000000e+00, double noundef 1.000000e+00, double noundef 1.000000e+00)
  call void @glutSolidCube(double noundef 5.000000e+00)
  call void @glPopMatrix()
  call void @glPushMatrix()
  call void @glTranslated(double noundef -4.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %6 = load float, ptr @angObj, align 4, !tbaa !5
  %7 = fpext float %6 to double
  %8 = fadd double %7, 1.000000e-01
  %9 = fptrunc double %8 to float
  store float %9, ptr @angObj, align 4, !tbaa !5
  %10 = fpext float %9 to double
  call void @glRotated(double noundef %10, double noundef 1.000000e+00, double noundef 1.000000e+00, double noundef 0.000000e+00)
  call void @glutSolidSphere(double noundef 3.000000e+00, i32 noundef 20, i32 noundef 16)
  call void @glPopMatrix()
  %11 = load float, ptr @angLight, align 4, !tbaa !5
  %12 = call noundef float @_ZSt3cosf(float noundef %11)
  %13 = fmul float %12, 9.000000e+00
  store float %13, ptr @light_0_position, align 16, !tbaa !5
  %14 = load float, ptr @angLight, align 4, !tbaa !5
  %15 = call noundef float @_ZSt3sinf(float noundef %14)
  %16 = fmul float %15, 9.000000e+00
  store float %16, ptr getelementptr inbounds ([4 x float], ptr @light_0_position, i64 0, i64 1), align 4, !tbaa !5
  store float 0.000000e+00, ptr getelementptr inbounds ([4 x float], ptr @light_0_position, i64 0, i64 2), align 8, !tbaa !5
  store float 0.000000e+00, ptr getelementptr inbounds ([4 x float], ptr @light_0_position, i64 0, i64 3), align 4, !tbaa !5
  %17 = load float, ptr @angLight, align 4, !tbaa !5
  %18 = fpext float %17 to double
  %19 = fadd double %18, 4.000000e-03
  %20 = fptrunc double %19 to float
  store float %20, ptr @angLight, align 4, !tbaa !5
  %21 = load float, ptr @angLight, align 4, !tbaa !5
  %22 = fpext float %21 to double
  %23 = fdiv double %22, 2.200000e+00
  %24 = call double @cos(double noundef %23) #4
  %25 = fmul double %24, 9.000000e+00
  %26 = fptrunc double %25 to float
  store float %26, ptr @light_1_position, align 16, !tbaa !5
  %27 = load float, ptr @angLight, align 4, !tbaa !5
  %28 = fpext float %27 to double
  %29 = fdiv double %28, 2.200000e+00
  %30 = call double @sin(double noundef %29) #4
  %31 = fmul double %30, 9.000000e+00
  %32 = fptrunc double %31 to float
  store float %32, ptr getelementptr inbounds ([4 x float], ptr @light_1_position, i64 0, i64 1), align 4, !tbaa !5
  store float 0.000000e+00, ptr getelementptr inbounds ([4 x float], ptr @light_1_position, i64 0, i64 2), align 8, !tbaa !5
  store float 0.000000e+00, ptr getelementptr inbounds ([4 x float], ptr @light_1_position, i64 0, i64 3), align 4, !tbaa !5
  call void @glPushMatrix()
  call void @glTranslated(double noundef 1.000000e+02, double noundef 0.000000e+00, double noundef 1.000000e+03)
  call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef @light_0_position)
  call void @glLightfv(i32 noundef 16385, i32 noundef 4611, ptr noundef @light_1_position)
  call void @glPopMatrix()
  %33 = load float, ptr @light_0_position, align 16, !tbaa !5
  %34 = fpext float %33 to double
  %35 = load float, ptr getelementptr inbounds ([4 x float], ptr @light_0_position, i64 0, i64 1), align 4, !tbaa !5
  %36 = fpext float %35 to double
  %37 = load float, ptr getelementptr inbounds ([4 x float], ptr @light_0_position, i64 0, i64 2), align 8, !tbaa !5
  %38 = fpext float %37 to double
  call void @glTranslated(double noundef %34, double noundef %36, double noundef %38)
  call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 16)
  call void @glLoadIdentity()
  %39 = load float, ptr @light_1_position, align 16, !tbaa !5
  %40 = fpext float %39 to double
  %41 = load float, ptr getelementptr inbounds ([4 x float], ptr @light_1_position, i64 0, i64 1), align 4, !tbaa !5
  %42 = fpext float %41 to double
  %43 = load float, ptr getelementptr inbounds ([4 x float], ptr @light_1_position, i64 0, i64 2), align 8, !tbaa !5
  %44 = fpext float %43 to double
  call void @glTranslated(double noundef %40, double noundef %42, double noundef %44)
  call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 16)
  call void @glutSwapBuffers()
  ret void
}

declare void @glClear(i32 noundef) #0

declare void @glLoadIdentity() #0

declare void @glPushMatrix() #0

declare void @glTranslated(double noundef, double noundef, double noundef) #0

declare void @glRotated(double noundef, double noundef, double noundef, double noundef) #0

declare void @glutSolidCube(double noundef) #0

declare void @glPopMatrix() #0

declare void @glutSolidSphere(double noundef, i32 noundef, i32 noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nounwind
declare double @sin(double noundef) #3

declare void @glutSwapBuffers() #0

attributes #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 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 = { 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 #3 = { nounwind "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"}


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

@angObj = external dso_local local_unnamed_addr global float, align 4
@angLight = external dso_local local_unnamed_addr global float, align 4
@light_0_position = external dso_local global [4 x float], align 16
@light_1_position = external dso_local global [4 x float], align 16

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7displayv() local_unnamed_addr #1 {
  tail call void @glClear(i32 noundef 16640)
  tail call void @glLoadIdentity()
  tail call void @glPushMatrix()
  tail call void @glTranslated(double noundef 4.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %1 = load float, ptr @angObj, align 4, !tbaa !5
  %2 = fpext float %1 to double
  %3 = fadd double %2, 1.000000e-01
  %4 = fptrunc double %3 to float
  store float %4, ptr @angObj, align 4, !tbaa !5
  %5 = fpext float %4 to double
  tail call void @glRotated(double noundef %5, double noundef 1.000000e+00, double noundef 1.000000e+00, double noundef 1.000000e+00)
  tail call void @glutSolidCube(double noundef 5.000000e+00)
  tail call void @glPopMatrix()
  tail call void @glPushMatrix()
  tail call void @glTranslated(double noundef -4.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %6 = load float, ptr @angObj, align 4, !tbaa !5
  %7 = fpext float %6 to double
  %8 = fadd double %7, 1.000000e-01
  %9 = fptrunc double %8 to float
  store float %9, ptr @angObj, align 4, !tbaa !5
  %10 = fpext float %9 to double
  tail call void @glRotated(double noundef %10, double noundef 1.000000e+00, double noundef 1.000000e+00, double noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 3.000000e+00, i32 noundef 20, i32 noundef 16)
  tail call void @glPopMatrix()
  %11 = load float, ptr @angLight, align 4, !tbaa !5
  %12 = tail call noundef float @_ZSt3cosf(float noundef %11)
  %13 = fmul float %12, 9.000000e+00
  store float %13, ptr @light_0_position, align 16, !tbaa !5
  %14 = load float, ptr @angLight, align 4, !tbaa !5
  %15 = tail call noundef float @_ZSt3sinf(float noundef %14)
  %16 = fmul float %15, 9.000000e+00
  store float %16, ptr getelementptr inbounds (i8, ptr @light_0_position, i64 4), align 4, !tbaa !5
  store <2 x float> zeroinitializer, ptr getelementptr inbounds (i8, ptr @light_0_position, i64 8), align 8, !tbaa !5
  %17 = load float, ptr @angLight, align 4, !tbaa !5
  %18 = fpext float %17 to double
  %19 = fadd double %18, 4.000000e-03
  %20 = fptrunc double %19 to float
  store float %20, ptr @angLight, align 4, !tbaa !5
  %21 = fpext float %20 to double
  %22 = fdiv double %21, 2.200000e+00
  %23 = tail call double @cos(double noundef %22) #4
  %24 = fmul double %23, 9.000000e+00
  %25 = fptrunc double %24 to float
  store float %25, ptr @light_1_position, align 16, !tbaa !5
  %26 = load float, ptr @angLight, align 4, !tbaa !5
  %27 = fpext float %26 to double
  %28 = fdiv double %27, 2.200000e+00
  %29 = tail call double @sin(double noundef %28) #4
  %30 = fmul double %29, 9.000000e+00
  %31 = fptrunc double %30 to float
  store float %31, ptr getelementptr inbounds (i8, ptr @light_1_position, i64 4), align 4, !tbaa !5
  store <2 x float> zeroinitializer, ptr getelementptr inbounds (i8, ptr @light_1_position, i64 8), align 8, !tbaa !5
  tail call void @glPushMatrix()
  tail call void @glTranslated(double noundef 1.000000e+02, double noundef 0.000000e+00, double noundef 1.000000e+03)
  tail call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef nonnull @light_0_position)
  tail call void @glLightfv(i32 noundef 16385, i32 noundef 4611, ptr noundef nonnull @light_1_position)
  tail call void @glPopMatrix()
  %32 = load float, ptr @light_0_position, align 16, !tbaa !5
  %33 = fpext float %32 to double
  %34 = load float, ptr getelementptr inbounds (i8, ptr @light_0_position, i64 4), align 4, !tbaa !5
  %35 = fpext float %34 to double
  %36 = load float, ptr getelementptr inbounds (i8, ptr @light_0_position, i64 8), align 8, !tbaa !5
  %37 = fpext float %36 to double
  tail call void @glTranslated(double noundef %33, double noundef %35, double noundef %37)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 16)
  tail call void @glLoadIdentity()
  %38 = load float, ptr @light_1_position, align 16, !tbaa !5
  %39 = fpext float %38 to double
  %40 = load float, ptr getelementptr inbounds (i8, ptr @light_1_position, i64 4), align 4, !tbaa !5
  %41 = fpext float %40 to double
  %42 = load float, ptr getelementptr inbounds (i8, ptr @light_1_position, i64 8), align 8, !tbaa !5
  %43 = fpext float %42 to double
  tail call void @glTranslated(double noundef %39, double noundef %41, double noundef %43)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 16)
  tail call void @glutSwapBuffers()
  ret void
}

declare void @glClear(i32 noundef) local_unnamed_addr #0

declare void @glLoadIdentity() local_unnamed_addr #0

declare void @glPushMatrix() local_unnamed_addr #0

declare void @glTranslated(double noundef, double noundef, double noundef) local_unnamed_addr #0

declare void @glRotated(double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #0

declare void @glutSolidCube(double noundef) local_unnamed_addr #0

declare void @glPopMatrix() local_unnamed_addr #0

declare void @glutSolidSphere(double noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #3

declare void @glutSwapBuffers() local_unnamed_addr #0

attributes #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 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 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(write) "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,TailCallElimPass