; LLVM IR from ThePhysicsGuys/Physics3D :: graphics/renderer.ll (ZN3P3D8Graphics8Renderer8getStateEv)

; 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.P3D::Graphics::Renderer::RenderState" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32], [2 x i32], i8, i8, i8, i8, i8 }

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

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

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

declare zeroext i8 @glIsEnabled(i32 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 @_ZN3P3D8Graphics8Renderer8getStateEv(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Graphics::Renderer::RenderState") align 4 %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  call void @glGetIntegerv(i32 noundef 36006, ptr noundef %2)
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 0
  store i32 %4, ptr %5, align 4, !tbaa !9
  call void @glGetIntegerv(i32 noundef 36010, ptr noundef %2)
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 1
  store i32 %6, ptr %7, align 4, !tbaa !12
  call void @glGetIntegerv(i32 noundef 36007, ptr noundef %2)
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 2
  store i32 %8, ptr %9, align 4, !tbaa !13
  call void @glGetIntegerv(i32 noundef 32873, ptr noundef %2)
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 3
  store i32 %10, ptr %11, align 4, !tbaa !14
  call void @glGetIntegerv(i32 noundef 35725, ptr noundef %2)
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 4
  store i32 %12, ptr %13, align 4, !tbaa !15
  call void @glGetIntegerv(i32 noundef 34229, ptr noundef %2)
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 5
  store i32 %14, ptr %15, align 4, !tbaa !16
  call void @glGetIntegerv(i32 noundef 34964, ptr noundef %2)
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 6
  store i32 %16, ptr %17, align 4, !tbaa !17
  call void @glGetIntegerv(i32 noundef 34965, ptr noundef %2)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 6
  store i32 %18, ptr %19, align 4, !tbaa !17
  call void @glGetBooleanv(i32 noundef 2930, ptr noundef %3)
  %20 = load i8, ptr %3, align 1, !tbaa !18
  %21 = icmp ne i8 %20, 0
  %22 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 15
  %23 = zext i1 %21 to i8
  store i8 %23, ptr %22, align 4, !tbaa !19
  %24 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 8
  call void @glGetIntegerv(i32 noundef 34016, ptr noundef %24)
  %25 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 9
  %26 = getelementptr inbounds [4 x i32], ptr %25, i64 0, i64 0
  call void @glGetIntegerv(i32 noundef 2978, ptr noundef %26)
  %27 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 10
  %28 = getelementptr inbounds [2 x i32], ptr %27, i64 0, i64 0
  call void @glGetIntegerv(i32 noundef 2880, ptr noundef %28)
  %29 = call zeroext i8 @glIsEnabled(i32 noundef 3042)
  %30 = icmp ne i8 %29, 0
  %31 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 11
  %32 = zext i1 %30 to i8
  store i8 %32, ptr %31, align 4, !tbaa !20
  %33 = call zeroext i8 @glIsEnabled(i32 noundef 2884)
  %34 = icmp ne i8 %33, 0
  %35 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 12
  %36 = zext i1 %34 to i8
  store i8 %36, ptr %35, align 1, !tbaa !21
  %37 = call zeroext i8 @glIsEnabled(i32 noundef 2929)
  %38 = icmp ne i8 %37, 0
  %39 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 13
  %40 = zext i1 %38 to i8
  store i8 %40, ptr %39, align 2, !tbaa !22
  %41 = call zeroext i8 @glIsEnabled(i32 noundef 3089)
  %42 = icmp ne i8 %41, 0
  %43 = getelementptr inbounds %"struct.P3D::Graphics::Renderer::RenderState", ptr %0, i32 0, i32 14
  %44 = zext i1 %42 to i8
  store i8 %44, ptr %43, align 1, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret void
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN3P3D8Graphics8Renderer11RenderStateE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !7, i64 36, !7, i64 52, !11, i64 60, !11, i64 61, !11, i64 62, !11, i64 63, !11, i64 64}
!11 = !{!"bool", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 12}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 20}
!17 = !{!10, !6, i64 24}
!18 = !{!7, !7, i64 0}
!19 = !{!10, !11, i64 64}
!20 = !{!10, !11, i64 60}
!21 = !{!10, !11, i64 61}
!22 = !{!10, !11, i64 62}
!23 = !{!10, !11, i64 63}


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

%"struct.P3D::Graphics::Renderer::RenderState" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32], [2 x i32], i8, i8, i8, i8, i8 }

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

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

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

declare zeroext i8 @glIsEnabled(i32 noundef) local_unnamed_addr #1

; 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 @_ZN3P3D8Graphics8Renderer8getStateEv(ptr dead_on_unwind noalias writable sret(%"struct.P3D::Graphics::Renderer::RenderState") align 4 %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #3
  call void @glGetIntegerv(i32 noundef 36006, ptr noundef nonnull %2)
  %4 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %4, ptr %0, align 4, !tbaa !9
  call void @glGetIntegerv(i32 noundef 36010, ptr noundef nonnull %2)
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %5, ptr %6, align 4, !tbaa !12
  call void @glGetIntegerv(i32 noundef 36007, ptr noundef nonnull %2)
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %7, ptr %8, align 4, !tbaa !13
  call void @glGetIntegerv(i32 noundef 32873, ptr noundef nonnull %2)
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %9, ptr %10, align 4, !tbaa !14
  call void @glGetIntegerv(i32 noundef 35725, ptr noundef nonnull %2)
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %11, ptr %12, align 4, !tbaa !15
  call void @glGetIntegerv(i32 noundef 34229, ptr noundef nonnull %2)
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %13, ptr %14, align 4, !tbaa !16
  call void @glGetIntegerv(i32 noundef 34964, ptr noundef nonnull %2)
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  call void @glGetIntegerv(i32 noundef 34965, ptr noundef nonnull %2)
  %16 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %16, ptr %15, align 4, !tbaa !17
  call void @glGetBooleanv(i32 noundef 2930, ptr noundef nonnull %3)
  %17 = load i8, ptr %3, align 1, !tbaa !18
  %18 = icmp ne i8 %17, 0
  %19 = getelementptr inbounds i8, ptr %0, i64 64
  %20 = zext i1 %18 to i8
  store i8 %20, ptr %19, align 4, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  call void @glGetIntegerv(i32 noundef 34016, ptr noundef nonnull %21)
  %22 = getelementptr inbounds i8, ptr %0, i64 36
  call void @glGetIntegerv(i32 noundef 2978, ptr noundef nonnull %22)
  %23 = getelementptr inbounds i8, ptr %0, i64 52
  call void @glGetIntegerv(i32 noundef 2880, ptr noundef nonnull %23)
  %24 = call zeroext i8 @glIsEnabled(i32 noundef 3042)
  %25 = icmp ne i8 %24, 0
  %26 = getelementptr inbounds i8, ptr %0, i64 60
  %27 = zext i1 %25 to i8
  store i8 %27, ptr %26, align 4, !tbaa !20
  %28 = call zeroext i8 @glIsEnabled(i32 noundef 2884)
  %29 = icmp ne i8 %28, 0
  %30 = getelementptr inbounds i8, ptr %0, i64 61
  %31 = zext i1 %29 to i8
  store i8 %31, ptr %30, align 1, !tbaa !21
  %32 = call zeroext i8 @glIsEnabled(i32 noundef 2929)
  %33 = icmp ne i8 %32, 0
  %34 = getelementptr inbounds i8, ptr %0, i64 62
  %35 = zext i1 %33 to i8
  store i8 %35, ptr %34, align 2, !tbaa !22
  %36 = call zeroext i8 @glIsEnabled(i32 noundef 3089)
  %37 = icmp ne i8 %36, 0
  %38 = getelementptr inbounds i8, ptr %0, i64 63
  %39 = zext i1 %37 to i8
  store i8 %39, ptr %38, align 1, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret void
}

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN3P3D8Graphics8Renderer11RenderStateE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !7, i64 36, !7, i64 52, !11, i64 60, !11, i64 61, !11, i64 62, !11, i64 63, !11, i64 64}
!11 = !{!"bool", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 12}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 20}
!17 = !{!10, !6, i64 24}
!18 = !{!7, !7, i64 0}
!19 = !{!10, !11, i64 64}
!20 = !{!10, !11, i64 60}
!21 = !{!10, !11, i64 61}
!22 = !{!10, !11, i64 62}
!23 = !{!10, !11, i64 63}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass