; LLVM IR from Angelo1211/HybridRenderingEngine :: src/engine.ll (ZN6Engine3runEv)

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

%struct.Engine = type { %class.DisplayManager, %class.InputManager, %class.SceneManager, %class.RenderManager }
%class.DisplayManager = type { ptr, ptr, ptr }
%class.InputManager = type { ptr, ptr }
%class.SceneManager = type { %"class.std::__cxx11::basic_string", ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.RenderManager = type { %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.Shader, %struct.ComputeShader, %struct.ComputeShader, ptr, ptr, ptr, ptr, %struct.Quad, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ResolveBuffer, %struct.CaptureBuffer, %struct.QuadHDRBuffer, %struct.DirShadowBuffer, %struct.FrameBufferMultiSampled, ptr }
%struct.Shader = type { i32 }
%struct.ComputeShader = type { %struct.Shader }
%struct.Quad = type { %struct.Primitive.base, [4 x i8] }
%struct.Primitive.base = type <{ ptr, i32, i32, i32 }>
%struct.ResolveBuffer = type { %struct.FrameBuffer, i32 }
%struct.FrameBuffer = type { i32, i32, i32, i32, i32 }
%struct.CaptureBuffer = type { %struct.FrameBuffer }
%struct.QuadHDRBuffer = type { %struct.FrameBuffer }
%struct.DirShadowBuffer = type { %struct.FrameBuffer }
%struct.FrameBufferMultiSampled = type { %struct.FrameBuffer }

@.str.9 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [24 x i8], align 1

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

declare i32 @SDL_GetTicks() #1

declare i32 @printf(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 @_ZN6Engine3runEv(ptr noundef nonnull align 8 dereferenceable(368) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %9 = call i32 @SDL_GetTicks()
  store i32 %9, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %11

11:                                               ; preds = %15, %1
  %12 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  %14 = xor i1 %13, true
  br i1 %14, label %15, label %31

15:                                               ; preds = %11
  %16 = load i32, ptr %4, align 4, !tbaa !11
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %4, align 4, !tbaa !11
  %18 = call i32 @SDL_GetTicks()
  store i32 %18, ptr %6, align 4, !tbaa !11
  %19 = getelementptr inbounds %struct.Engine, ptr %8, i32 0, i32 1
  %20 = load i32, ptr %5, align 4, !tbaa !11
  call void @_ZN12InputManager12processInputERbj(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 1 dereferenceable(1) %3, i32 noundef %20)
  %21 = getelementptr inbounds %struct.Engine, ptr %8, i32 0, i32 2
  %22 = load i32, ptr %5, align 4, !tbaa !11
  call void @_ZN12SceneManager6updateEj(ptr noundef nonnull align 8 dereferenceable(40) %21, i32 noundef %22)
  %23 = getelementptr inbounds %struct.Engine, ptr %8, i32 0, i32 3
  %24 = load i32, ptr %6, align 4, !tbaa !11
  call void @_ZN13RenderManager6renderEj(ptr noundef nonnull align 8 dereferenceable(288) %23, i32 noundef %24)
  %25 = call i32 @SDL_GetTicks()
  %26 = load i32, ptr %6, align 4, !tbaa !11
  %27 = sub i32 %25, %26
  store i32 %27, ptr %5, align 4, !tbaa !11
  %28 = load i32, ptr %5, align 4, !tbaa !11
  %29 = load i32, ptr %7, align 4, !tbaa !11
  %30 = add i32 %29, %28
  store i32 %30, ptr %7, align 4, !tbaa !11
  br label %11, !llvm.loop !15

31:                                               ; preds = %11
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %33 = load i32, ptr %4, align 4, !tbaa !11
  %34 = load i32, ptr %7, align 4, !tbaa !11
  %35 = uitofp i32 %34 to float
  %36 = load i32, ptr %4, align 4, !tbaa !11
  %37 = sitofp i32 %36 to float
  %38 = fdiv float %35, %37
  %39 = fpext float %38 to double
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %33, double noundef %39)
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret void
}

declare void @_ZN12InputManager12processInputERbj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #1

declare void @_ZN12SceneManager6updateEj(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #1

declare void @_ZN13RenderManager6renderEj(ptr noundef nonnull align 8 dereferenceable(288), i32 noundef) #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@.str.9 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [24 x i8], align 1

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

declare i32 @SDL_GetTicks() local_unnamed_addr #1

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

; Function Attrs: mustprogress 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 @_ZN6Engine3runEv(ptr noundef nonnull align 8 dereferenceable(368) %0) local_unnamed_addr #3 align 2 {
.lr.ph:
  %1 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #4
  store i8 0, ptr %1, align 1, !tbaa !5
  %2 = tail call i32 @SDL_GetTicks()
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  br label %7

7:                                                ; preds = %.lr.ph, %7
  %.014 = phi i32 [ 0, %.lr.ph ], [ %12, %7 ]
  %.01013 = phi i32 [ %2, %.lr.ph ], [ %11, %7 ]
  %.01112 = phi i32 [ 0, %.lr.ph ], [ %8, %7 ]
  %8 = add nuw nsw i32 %.01112, 1
  %9 = call i32 @SDL_GetTicks()
  call void @_ZN12InputManager12processInputERbj(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 1 dereferenceable(1) %1, i32 noundef %.01013)
  call void @_ZN12SceneManager6updateEj(ptr noundef nonnull align 8 dereferenceable(40) %5, i32 noundef %.01013)
  call void @_ZN13RenderManager6renderEj(ptr noundef nonnull align 8 dereferenceable(288) %6, i32 noundef %9)
  %10 = call i32 @SDL_GetTicks()
  %11 = sub i32 %10, %9
  %12 = add i32 %11, %.014
  %13 = load i8, ptr %1, align 1, !tbaa !5, !range !9, !noundef !10
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %._crit_edge, label %7, !llvm.loop !11

._crit_edge:                                      ; preds = %7
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %16 = uitofp i32 %12 to float
  %17 = uitofp nneg i32 %8 to float
  %18 = fdiv float %16, %17
  %19 = fpext float %18 to double
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %8, double noundef %19)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #4
  ret void
}

declare void @_ZN12InputManager12processInputERbj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #1

declare void @_ZN12SceneManager6updateEj(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #1

declare void @_ZN13RenderManager6renderEj(ptr noundef nonnull align 8 dereferenceable(288), i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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" }
attributes #3 = { 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 #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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass