; LLVM IR from Dovyski/opengl-demos :: src/glut-basic/main.ll (Z6renderv)

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

@largura = external dso_local global i32, align 4
@altura = external dso_local global i32, align 4
@figura = external dso_local global i32, align 4
@rotation = external dso_local global float, align 4
@keyPressed_1 = external dso_local global i32, align 4
@keyPressed_2 = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

declare void @glLoadIdentity() #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6renderv() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load i32, ptr @keyPressed_1, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %6, label %8

6:                                                ; preds = %0
  %7 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %8

8:                                                ; preds = %6, %0
  %9 = load i32, ptr @keyPressed_2, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %13

13:                                               ; preds = %11, %8
  call void @glLoadIdentity()
  %14 = load i32, ptr @largura, align 4, !tbaa !5
  %15 = sdiv i32 %14, 2
  %16 = sitofp i32 %15 to double
  %17 = load i32, ptr @altura, align 4, !tbaa !5
  %18 = sdiv i32 %17, 2
  %19 = sitofp i32 %18 to double
  call void @glTranslated(double noundef %16, double noundef %19, double noundef 0.000000e+00)
  %20 = load float, ptr @rotation, align 4, !tbaa !9
  %21 = fpext float %20 to double
  %22 = fadd double %21, 3.000000e-01
  %23 = fptrunc double %22 to float
  store float %23, ptr @rotation, align 4, !tbaa !9
  %24 = fpext float %23 to double
  call void @glRotated(double noundef %24, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 1.000000e+00)
  %25 = load i32, ptr @figura, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 49
  br i1 %26, label %27, label %52

27:                                               ; preds = %13
  call void @glColor3f(float noundef 1.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glBegin(i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %48, %27
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = load i32, ptr @largura, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %51

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %44, %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = load i32, ptr @altura, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %47

39:                                               ; preds = %34
  %40 = load i32, ptr %1, align 4, !tbaa !5
  %41 = sitofp i32 %40 to double
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sitofp i32 %42 to double
  call void @glVertex2d(double noundef %41, double noundef %43)
  br label %44

44:                                               ; preds = %39
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add nsw i32 %45, 6
  store i32 %46, ptr %3, align 4, !tbaa !5
  br label %34, !llvm.loop !11

47:                                               ; preds = %38
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %1, align 4, !tbaa !5
  %50 = add nsw i32 %49, 6
  store i32 %50, ptr %1, align 4, !tbaa !5
  br label %28, !llvm.loop !13

51:                                               ; preds = %32
  call void @glEnd()
  br label %52

52:                                               ; preds = %51, %13
  %53 = load i32, ptr @figura, align 4, !tbaa !5
  %54 = icmp eq i32 %53, 50
  br i1 %54, label %55, label %63

55:                                               ; preds = %52
  call void @glShadeModel(i32 noundef 7424)
  call void @glBegin(i32 noundef 4)
  call void @glColor3f(float noundef 1.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glVertex2f(float noundef 0.000000e+00, float noundef 0.000000e+00)
  call void @glColor3f(float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %56 = load i32, ptr @largura, align 4, !tbaa !5
  %57 = sitofp i32 %56 to float
  call void @glVertex2f(float noundef %57, float noundef 0.000000e+00)
  call void @glColor3f(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %58 = load i32, ptr @largura, align 4, !tbaa !5
  %59 = sdiv i32 %58, 2
  %60 = sitofp i32 %59 to float
  %61 = load i32, ptr @altura, align 4, !tbaa !5
  %62 = sitofp i32 %61 to float
  call void @glVertex2f(float noundef %60, float noundef %62)
  call void @glEnd()
  br label %63

63:                                               ; preds = %55, %52
  ret void
}

declare i32 @printf(ptr noundef, ...) #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 @glColor3f(float noundef, float noundef, float noundef) #0

declare void @glBegin(i32 noundef) #0

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

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

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

declare void @glEnd() #0

declare void @glShadeModel(i32 noundef) #0

declare void @glVertex2f(float noundef, float noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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"}
!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"

@largura = external dso_local local_unnamed_addr global i32, align 4
@altura = external dso_local local_unnamed_addr global i32, align 4
@figura = external dso_local local_unnamed_addr global i32, align 4
@rotation = external dso_local local_unnamed_addr global float, align 4
@keyPressed_1 = external dso_local local_unnamed_addr global i32, align 4
@keyPressed_2 = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

declare void @glLoadIdentity() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6renderv() local_unnamed_addr #1 {
  %1 = load i32, ptr @keyPressed_1, align 4, !tbaa !5
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %3, label %5

3:                                                ; preds = %0
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %5

5:                                                ; preds = %3, %0
  %6 = load i32, ptr @keyPressed_2, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %10

10:                                               ; preds = %8, %5
  tail call void @glLoadIdentity()
  %11 = load i32, ptr @largura, align 4, !tbaa !5
  %12 = sdiv i32 %11, 2
  %13 = sitofp i32 %12 to double
  %14 = load i32, ptr @altura, align 4, !tbaa !5
  %15 = sdiv i32 %14, 2
  %16 = sitofp i32 %15 to double
  tail call void @glTranslated(double noundef %13, double noundef %16, double noundef 0.000000e+00)
  %17 = load float, ptr @rotation, align 4, !tbaa !9
  %18 = fpext float %17 to double
  %19 = fadd double %18, 3.000000e-01
  %20 = fptrunc double %19 to float
  store float %20, ptr @rotation, align 4, !tbaa !9
  %21 = fpext float %20 to double
  tail call void @glRotated(double noundef %21, double noundef 0.000000e+00, double noundef 0.000000e+00, double noundef 1.000000e+00)
  %22 = load i32, ptr @figura, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 49
  br i1 %23, label %24, label %42

24:                                               ; preds = %10
  tail call void @glColor3f(float noundef 1.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glBegin(i32 noundef 0)
  %25 = load i32, ptr @largura, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  %27 = load i32, ptr @altura, align 4
  %28 = icmp sgt i32 %27, 0
  %or.cond = select i1 %26, i1 %28, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge9

.preheader:                                       ; preds = %24, %._crit_edge
  %29 = phi i32 [ %33, %._crit_edge ], [ %25, %24 ]
  %30 = phi i32 [ %34, %._crit_edge ], [ %27, %24 ]
  %.068 = phi i32 [ %35, %._crit_edge ], [ 0, %24 ]
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %32 = uitofp nneg i32 %.068 to double
  br label %37

._crit_edge9:                                     ; preds = %._crit_edge, %24
  tail call void @glEnd()
  %.pr = load i32, ptr @figura, align 4, !tbaa !5
  br label %42

._crit_edge.loopexit:                             ; preds = %37
  %.pre = load i32, ptr @largura, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %33 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %29, %.preheader ]
  %34 = phi i32 [ %40, %._crit_edge.loopexit ], [ %30, %.preheader ]
  %35 = add nuw nsw i32 %.068, 6
  %36 = icmp slt i32 %35, %33
  br i1 %36, label %.preheader, label %._crit_edge9, !llvm.loop !11

37:                                               ; preds = %.lr.ph, %37
  %.07 = phi i32 [ 0, %.lr.ph ], [ %39, %37 ]
  %38 = uitofp nneg i32 %.07 to double
  tail call void @glVertex2d(double noundef %32, double noundef %38)
  %39 = add nuw nsw i32 %.07, 6
  %40 = load i32, ptr @altura, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %37, label %._crit_edge.loopexit, !llvm.loop !14

42:                                               ; preds = %._crit_edge9, %10
  %43 = phi i32 [ %.pr, %._crit_edge9 ], [ %22, %10 ]
  %44 = icmp eq i32 %43, 50
  br i1 %44, label %45, label %53

45:                                               ; preds = %42
  tail call void @glShadeModel(i32 noundef 7424)
  tail call void @glBegin(i32 noundef 4)
  tail call void @glColor3f(float noundef 1.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glVertex2f(float noundef 0.000000e+00, float noundef 0.000000e+00)
  tail call void @glColor3f(float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %46 = load i32, ptr @largura, align 4, !tbaa !5
  %47 = sitofp i32 %46 to float
  tail call void @glVertex2f(float noundef %47, float noundef 0.000000e+00)
  tail call void @glColor3f(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %48 = load i32, ptr @largura, align 4, !tbaa !5
  %49 = sdiv i32 %48, 2
  %50 = sitofp i32 %49 to float
  %51 = load i32, ptr @altura, align 4, !tbaa !5
  %52 = sitofp i32 %51 to float
  tail call void @glVertex2f(float noundef %50, float noundef %52)
  tail call void @glEnd()
  br label %53

53:                                               ; preds = %45, %42
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 @glColor3f(float noundef, float noundef, float noundef) local_unnamed_addr #0

declare void @glBegin(i32 noundef) local_unnamed_addr #0

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

declare void @glEnd() local_unnamed_addr #0

declare void @glShadeModel(i32 noundef) local_unnamed_addr #0

declare void @glVertex2f(float noundef, float noundef) 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 = { nofree 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" }

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


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass