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

@light_0_position = external dso_local global [4 x float], align 16
@light_0_direction = external dso_local global [3 x float], align 4
@rx = external dso_local global float, align 4
@rz = external dso_local global float, align 4

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

declare void @glLoadIdentity() #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7displayv() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @glClear(i32 noundef 16640)
  call void @glLoadIdentity()
  call void @gluLookAt(double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 3.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 1.000000e+00, double noundef 0.000000e+00)
  call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef @light_0_position)
  call void @glLightfv(i32 noundef 16384, i32 noundef 4612, ptr noundef @light_0_direction)
  %3 = load float, ptr @rx, align 4, !tbaa !5
  call void @glRotatef(float noundef %3, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %4 = load float, ptr @rz, align 4, !tbaa !5
  call void @glRotatef(float noundef %4, float noundef 1.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glScalef(float noundef 0x3FC99999A0000000, float noundef 0x3FC99999A0000000, float noundef 0x3FC99999A0000000)
  call void @glTranslatef(float noundef -5.000000e+00, float noundef 0.000000e+00, float noundef -5.000000e+00)
  call void @glNormal3f(float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  call void @glBegin(i32 noundef 7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !9
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %37, %0
  %6 = load i32, ptr %1, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 10
  br i1 %7, label %8, label %40

8:                                                ; preds = %5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %33, %8
  %10 = load i32, ptr %2, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 10
  br i1 %11, label %12, label %36

12:                                               ; preds = %9
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = sitofp i32 %13 to float
  %15 = load i32, ptr %2, align 4, !tbaa !9
  %16 = sitofp i32 %15 to float
  call void @glVertex3f(float noundef %14, float noundef 0.000000e+00, float noundef %16)
  %17 = load i32, ptr %1, align 4, !tbaa !9
  %18 = sitofp i32 %17 to float
  %19 = load i32, ptr %2, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  %21 = sitofp i32 %20 to float
  call void @glVertex3f(float noundef %18, float noundef 0.000000e+00, float noundef %21)
  %22 = load i32, ptr %1, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  %24 = sitofp i32 %23 to float
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = add nsw i32 %25, 1
  %27 = sitofp i32 %26 to float
  call void @glVertex3f(float noundef %24, float noundef 0.000000e+00, float noundef %27)
  %28 = load i32, ptr %1, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  %30 = sitofp i32 %29 to float
  %31 = load i32, ptr %2, align 4, !tbaa !9
  %32 = sitofp i32 %31 to float
  call void @glVertex3f(float noundef %30, float noundef 0.000000e+00, float noundef %32)
  br label %33

33:                                               ; preds = %12
  %34 = load i32, ptr %2, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !9
  br label %9, !llvm.loop !11

36:                                               ; preds = %9
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %1, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %1, align 4, !tbaa !9
  br label %5, !llvm.loop !13

40:                                               ; preds = %5
  call void @glEnd()
  call void @glPushMatrix()
  call void @glTranslated(double noundef 4.000000e+00, double noundef 1.000000e+00, double noundef 4.000000e+00)
  call void @glutSolidTeapot(double noundef 2.000000e+00)
  call void @glPopMatrix()
  call void @glutSwapBuffers()
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

declare void @glClear(i32 noundef) #1

declare void @gluLookAt(double noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef) #1

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

declare void @glScalef(float noundef, float noundef, float noundef) #1

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

declare void @glNormal3f(float noundef, float noundef, float noundef) #1

declare void @glBegin(i32 noundef) #1

declare void @glVertex3f(float noundef, float noundef, float noundef) #1

declare void @glEnd() #1

declare void @glPushMatrix() #1

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

declare void @glutSolidTeapot(double noundef) #1

declare void @glPopMatrix() #1

declare void @glutSwapBuffers() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 }

!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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@light_0_position = external dso_local global [4 x float], align 16
@light_0_direction = external dso_local global [3 x float], align 4
@rx = external dso_local local_unnamed_addr global float, align 4
@rz = external dso_local local_unnamed_addr global float, align 4

declare void @glLoadIdentity() local_unnamed_addr #0

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 @gluLookAt(double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 3.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 1.000000e+00, double noundef 0.000000e+00)
  tail call void @glLightfv(i32 noundef 16384, i32 noundef 4611, ptr noundef nonnull @light_0_position)
  tail call void @glLightfv(i32 noundef 16384, i32 noundef 4612, ptr noundef nonnull @light_0_direction)
  %1 = load float, ptr @rx, align 4, !tbaa !5
  tail call void @glRotatef(float noundef %1, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %2 = load float, ptr @rz, align 4, !tbaa !5
  tail call void @glRotatef(float noundef %2, float noundef 1.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glScalef(float noundef 0x3FC99999A0000000, float noundef 0x3FC99999A0000000, float noundef 0x3FC99999A0000000)
  tail call void @glTranslatef(float noundef -5.000000e+00, float noundef 0.000000e+00, float noundef -5.000000e+00)
  tail call void @glNormal3f(float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  tail call void @glBegin(i32 noundef 7)
  br label %.preheader

.preheader:                                       ; preds = %0, %.preheader
  %.01214 = phi i32 [ 0, %0 ], [ %4, %.preheader ]
  %3 = uitofp nneg i32 %.01214 to float
  %4 = add nuw nsw i32 %.01214, 1
  %5 = uitofp nneg i32 %4 to float
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 2.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 2.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 2.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 3.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 3.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 2.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 3.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 4.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 4.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 3.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 4.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 5.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 5.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 4.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 5.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 6.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 6.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 5.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 6.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 7.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 7.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 6.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 7.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 8.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 8.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 7.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 8.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 9.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 9.000000e+00)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 8.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 9.000000e+00)
  tail call void @glVertex3f(float noundef %3, float noundef 0.000000e+00, float noundef 1.000000e+01)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 1.000000e+01)
  tail call void @glVertex3f(float noundef %5, float noundef 0.000000e+00, float noundef 9.000000e+00)
  %exitcond.not = icmp eq i32 %4, 10
  br i1 %exitcond.not, label %6, label %.preheader, !llvm.loop !9

6:                                                ; preds = %.preheader
  tail call void @glEnd()
  tail call void @glPushMatrix()
  tail call void @glTranslated(double noundef 4.000000e+00, double noundef 1.000000e+00, double noundef 4.000000e+00)
  tail call void @glutSolidTeapot(double noundef 2.000000e+00)
  tail call void @glPopMatrix()
  tail call void @glutSwapBuffers()
  ret void
}

declare void @glClear(i32 noundef) local_unnamed_addr #0

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

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

declare void @glScalef(float noundef, float noundef, float noundef) local_unnamed_addr #0

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

declare void @glNormal3f(float noundef, float noundef, float noundef) local_unnamed_addr #0

declare void @glBegin(i32 noundef) local_unnamed_addr #0

declare void @glVertex3f(float noundef, float noundef, float noundef) local_unnamed_addr #0

declare void @glEnd() 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 @glutSolidTeapot(double noundef) local_unnamed_addr #0

declare void @glPopMatrix() local_unnamed_addr #0

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

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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