; LLVM IR from Dovyski/opengl-demos :: src/light-spheres/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"

@Noemit = external dso_local global [4 x float], align 16
@SphShininess = external dso_local global float, align 4
@SphAmbDiff = external dso_local global [6 x [4 x float]], align 16
@SphSpecular = external dso_local global [4 x float], align 16
@Lt0spec = external dso_local global [4 x float], align 16
@zeroPos = external dso_local global [4 x float], align 16
@dirI = external dso_local global [4 x float], align 16
@LightIsPositional = external dso_local global i32, align 4
@RunMode = external dso_local global i32, align 4
@CurrentAngle = external dso_local global float, align 4
@AnimateStep = external dso_local global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7displayv() #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @glClear(i32 noundef 16640)
  %2 = load i32, ptr @RunMode, align 4, !tbaa !5
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %4, label %21

4:                                                ; preds = %0
  %5 = load float, ptr @AnimateStep, align 4, !tbaa !9
  %6 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  %7 = fadd float %6, %5
  store float %7, ptr @CurrentAngle, align 4, !tbaa !9
  %8 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  %9 = fpext float %8 to double
  %10 = fcmp ogt double %9, 3.600000e+02
  br i1 %10, label %11, label %20

11:                                               ; preds = %4
  %12 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  %13 = fpext float %12 to double
  %14 = fdiv double %13, 3.600000e+02
  %15 = call double @llvm.floor.f64(double %14)
  %16 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  %17 = fpext float %16 to double
  %18 = call double @llvm.fmuladd.f64(double -3.600000e+02, double %15, double %17)
  %19 = fptrunc double %18 to float
  store float %19, ptr @CurrentAngle, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %11, %4
  br label %21

21:                                               ; preds = %20, %0
  call void @glMatrixMode(i32 noundef 5888)
  call void @glLoadIdentity()
  call void @glPushMatrix()
  %22 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  call void @glRotatef(float noundef %22, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  call void @glTranslatef(float noundef 7.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glMaterialfv(i32 noundef 1032, i32 noundef 5632, ptr noundef @Lt0spec)
  call void @glutSolidSphere(double noundef 3.000000e-01, i32 noundef 5, i32 noundef 5)
  call void @glMaterialfv(i32 noundef 1032, i32 noundef 5632, ptr noundef @Noemit)
  %23 = load i32, ptr @LightIsPositional, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef @zeroPos)
  br label %27

26:                                               ; preds = %21
  call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef @dirI)
  br label %27

27:                                               ; preds = %26, %25
  call void @glPopMatrix()
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %42, %27
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 6
  br i1 %30, label %31, label %45

31:                                               ; preds = %28
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [6 x [4 x float]], ptr @SphAmbDiff, i64 0, i64 %33
  %35 = getelementptr inbounds [4 x float], ptr %34, i64 0, i64 0
  call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef %35)
  call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef @SphSpecular)
  %36 = load float, ptr @SphShininess, align 4, !tbaa !9
  call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %36)
  call void @glPushMatrix()
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = sitofp i32 %37 to float
  %39 = fpext float %38 to double
  %40 = fmul double 6.000000e+01, %39
  %41 = fptrunc double %40 to float
  call void @glRotatef(float noundef %41, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  call void @glPopMatrix()
  br label %42

42:                                               ; preds = %31
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %1, align 4, !tbaa !5
  br label %28, !llvm.loop !11

45:                                               ; preds = %28
  call void @glFlush()
  call void @glutSwapBuffers()
  %46 = load i32, ptr @RunMode, align 4, !tbaa !5
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  call void @glutPostRedisplay()
  br label %49

49:                                               ; preds = %48, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

declare void @glClear(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

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

declare void @glMatrixMode(i32 noundef) #2

declare void @glLoadIdentity() #2

declare void @glPushMatrix() #2

declare void @glRotatef(float noundef, float noundef, float noundef, float noundef) #2

declare void @glTranslatef(float noundef, float noundef, float noundef) #2

declare void @glMaterialfv(i32 noundef, i32 noundef, ptr noundef) #2

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

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

declare void @glPopMatrix() #2

declare void @glMaterialf(i32 noundef, i32 noundef, float noundef) #2

declare void @glFlush() #2

declare void @glutSwapBuffers() #2

declare void @glutPostRedisplay() #2

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

@Noemit = external dso_local global [4 x float], align 16
@SphShininess = external dso_local local_unnamed_addr global float, align 4
@SphAmbDiff = external dso_local global [6 x [4 x float]], align 16
@SphSpecular = external dso_local global [4 x float], align 16
@Lt0spec = external dso_local global [4 x float], align 16
@zeroPos = external dso_local global [4 x float], align 16
@dirI = external dso_local global [4 x float], align 16
@LightIsPositional = external dso_local local_unnamed_addr global i32, align 4
@RunMode = external dso_local local_unnamed_addr global i32, align 4
@CurrentAngle = external dso_local local_unnamed_addr global float, align 4
@AnimateStep = external dso_local local_unnamed_addr global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7displayv() local_unnamed_addr #0 {
  tail call void @glClear(i32 noundef 16640)
  %1 = load i32, ptr @RunMode, align 4, !tbaa !5
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %3, label %14

3:                                                ; preds = %0
  %4 = load float, ptr @AnimateStep, align 4, !tbaa !9
  %5 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  %6 = fadd float %4, %5
  store float %6, ptr @CurrentAngle, align 4, !tbaa !9
  %7 = fcmp ogt float %6, 3.600000e+02
  br i1 %7, label %8, label %14

8:                                                ; preds = %3
  %9 = fpext float %6 to double
  %10 = fdiv double %9, 3.600000e+02
  %11 = tail call double @llvm.floor.f64(double %10)
  %12 = tail call double @llvm.fmuladd.f64(double %11, double -3.600000e+02, double %9)
  %13 = fptrunc double %12 to float
  store float %13, ptr @CurrentAngle, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %3, %8, %0
  tail call void @glMatrixMode(i32 noundef 5888)
  tail call void @glLoadIdentity()
  tail call void @glPushMatrix()
  %15 = load float, ptr @CurrentAngle, align 4, !tbaa !9
  tail call void @glRotatef(float noundef %15, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 7.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5632, ptr noundef nonnull @Lt0spec)
  tail call void @glutSolidSphere(double noundef 3.000000e-01, i32 noundef 5, i32 noundef 5)
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5632, ptr noundef nonnull @Noemit)
  %16 = load i32, ptr @LightIsPositional, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 1
  %zeroPos.dirI = select i1 %17, ptr @zeroPos, ptr @dirI
  tail call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef nonnull %zeroPos.dirI)
  tail call void @glPopMatrix()
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef nonnull @SphAmbDiff)
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef nonnull @SphSpecular)
  %18 = load float, ptr @SphShininess, align 4, !tbaa !9
  tail call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %18)
  tail call void @glPushMatrix()
  tail call void @glRotatef(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  tail call void @glPopMatrix()
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef nonnull getelementptr inbounds (i8, ptr @SphAmbDiff, i64 16))
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef nonnull @SphSpecular)
  %19 = load float, ptr @SphShininess, align 4, !tbaa !9
  tail call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %19)
  tail call void @glPushMatrix()
  tail call void @glRotatef(float noundef 6.000000e+01, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  tail call void @glPopMatrix()
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef nonnull getelementptr inbounds (i8, ptr @SphAmbDiff, i64 32))
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef nonnull @SphSpecular)
  %20 = load float, ptr @SphShininess, align 4, !tbaa !9
  tail call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %20)
  tail call void @glPushMatrix()
  tail call void @glRotatef(float noundef 1.200000e+02, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  tail call void @glPopMatrix()
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef nonnull getelementptr inbounds (i8, ptr @SphAmbDiff, i64 48))
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef nonnull @SphSpecular)
  %21 = load float, ptr @SphShininess, align 4, !tbaa !9
  tail call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %21)
  tail call void @glPushMatrix()
  tail call void @glRotatef(float noundef 1.800000e+02, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  tail call void @glPopMatrix()
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef nonnull getelementptr inbounds (i8, ptr @SphAmbDiff, i64 64))
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef nonnull @SphSpecular)
  %22 = load float, ptr @SphShininess, align 4, !tbaa !9
  tail call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %22)
  tail call void @glPushMatrix()
  tail call void @glRotatef(float noundef 2.400000e+02, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  tail call void @glPopMatrix()
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 5634, ptr noundef nonnull getelementptr inbounds (i8, ptr @SphAmbDiff, i64 80))
  tail call void @glMaterialfv(i32 noundef 1032, i32 noundef 4610, ptr noundef nonnull @SphSpecular)
  %23 = load float, ptr @SphShininess, align 4, !tbaa !9
  tail call void @glMaterialf(i32 noundef 1032, i32 noundef 5633, float noundef %23)
  tail call void @glPushMatrix()
  tail call void @glRotatef(float noundef 3.000000e+02, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glTranslatef(float noundef 2.500000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glutSolidSphere(double noundef 1.000000e+00, i32 noundef 20, i32 noundef 20)
  tail call void @glPopMatrix()
  tail call void @glFlush()
  tail call void @glutSwapBuffers()
  %24 = load i32, ptr @RunMode, align 4, !tbaa !5
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %14
  tail call void @glutPostRedisplay()
  br label %27

27:                                               ; preds = %26, %14
  ret void
}

declare void @glClear(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare void @glMatrixMode(i32 noundef) local_unnamed_addr #1

declare void @glLoadIdentity() local_unnamed_addr #1

declare void @glPushMatrix() local_unnamed_addr #1

declare void @glRotatef(float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @glTranslatef(float noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @glMaterialfv(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

declare void @glPopMatrix() local_unnamed_addr #1

declare void @glMaterialf(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

declare void @glFlush() local_unnamed_addr #1

declare void @glutSwapBuffers() local_unnamed_addr #1

declare void @glutPostRedisplay() local_unnamed_addr #1

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" }
attributes #1 = { "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass