; LLVM IR from blat-blatnik/Painted-Portal-Ray-Tracing :: src/game.ll (Z9gameOnKeyP10GLFWwindowiiii)

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

@_ZL6window = external hidden global ptr, align 8
@_ZL9velocityY = external hidden global float, align 4
@_ZL15doubleJumpReady = external hidden global i8, align 1
@_ZL8gameMode = external hidden global i32, align 4
@.str = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 x i8], align 1
@_ZL8material = external hidden global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9gameOnKeyP10GLFWwindowiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  br label %66

18:                                               ; preds = %5
  %19 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %19, label %65 [
    i32 256, label %20
    i32 70, label %22
    i32 32, label %43
    i32 80, label %53
    i32 66, label %55
    i32 48, label %57
    i32 49, label %57
    i32 50, label %57
    i32 51, label %57
    i32 52, label %57
    i32 53, label %57
    i32 54, label %57
    i32 55, label %57
    i32 56, label %57
    i32 57, label %57
  ]

20:                                               ; preds = %18
  %21 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  call void @glfwSetWindowShouldClose(ptr noundef %21, i32 noundef 1)
  br label %66

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %23 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  %24 = call ptr @glfwGetWindowMonitor(ptr noundef %23)
  store ptr %24, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %25 = call ptr @glfwGetPrimaryMonitor()
  store ptr %25, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  call void @glfwGetMonitorWorkarea(ptr noundef %26, ptr noundef null, ptr noundef null, ptr noundef %13, ptr noundef %14)
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %34, label %29

29:                                               ; preds = %22
  %30 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = load i32, ptr %14, align 4, !tbaa !9
  call void @glfwSetWindowMonitor(ptr noundef %30, ptr noundef %31, i32 noundef 0, i32 noundef 0, i32 noundef %32, i32 noundef %33, i32 noundef 60)
  br label %42

34:                                               ; preds = %22
  %35 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  %36 = load i32, ptr %13, align 4, !tbaa !9
  %37 = sub nsw i32 %36, 1280
  %38 = sdiv i32 %37, 2
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = sub nsw i32 %39, 720
  %41 = sdiv i32 %40, 2
  call void @glfwSetWindowMonitor(ptr noundef %35, ptr noundef null, i32 noundef %38, i32 noundef %41, i32 noundef 1280, i32 noundef 720, i32 noundef 60)
  br label %42

42:                                               ; preds = %34, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %66

43:                                               ; preds = %18
  %44 = load float, ptr @_ZL9velocityY, align 4, !tbaa !11
  %45 = fcmp oeq float %44, 0.000000e+00
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store float 1.000000e+01, ptr @_ZL9velocityY, align 4, !tbaa !11
  br label %52

47:                                               ; preds = %43
  %48 = load i8, ptr @_ZL15doubleJumpReady, align 1, !tbaa !13, !range !15, !noundef !16
  %49 = trunc i8 %48 to i1
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  store float 1.000000e+01, ptr @_ZL9velocityY, align 4, !tbaa !11
  store i8 0, ptr @_ZL15doubleJumpReady, align 1, !tbaa !13
  br label %51

51:                                               ; preds = %50, %47
  br label %52

52:                                               ; preds = %51, %46
  br label %66

53:                                               ; preds = %18
  store i32 0, ptr @_ZL8gameMode, align 4, !tbaa !17
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %66

55:                                               ; preds = %18
  store i32 1, ptr @_ZL8gameMode, align 4, !tbaa !17
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  br label %66

57:                                               ; preds = %18, %18, %18, %18, %18, %18, %18, %18, %18, %18
  %58 = load i32, ptr @_ZL8gameMode, align 4, !tbaa !17
  %59 = icmp eq i32 %58, 1
  br i1 %59, label %60, label %64

60:                                               ; preds = %57
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = add nsw i32 1, %61
  %63 = sub nsw i32 %62, 48
  store i32 %63, ptr @_ZL8material, align 4, !tbaa !9
  call void @_ZL19printPickedMaterialv()
  br label %64

64:                                               ; preds = %60, %57
  br label %66

65:                                               ; preds = %18
  br label %66

66:                                               ; preds = %65, %64, %55, %53, %52, %42, %20, %17
  ret void
}

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

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

declare ptr @glfwGetWindowMonitor(ptr noundef) #1

declare ptr @glfwGetPrimaryMonitor() #1

declare void @glfwGetMonitorWorkarea(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19printPickedMaterialv() #0

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !18, i64 0}
!18 = !{!"_ZTS8GameMode", !7, i64 0}


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

@_ZL6window = external hidden local_unnamed_addr global ptr, align 8
@_ZL9velocityY = external hidden local_unnamed_addr global float, align 4
@_ZL15doubleJumpReady = external hidden local_unnamed_addr global i8, align 1
@_ZL8gameMode = external hidden local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [19 x i8], align 1
@_ZL8material = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9gameOnKeyP10GLFWwindowiiii(ptr nocapture noundef readnone %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %.not = icmp eq i32 %3, 1
  br i1 %.not, label %8, label %43

8:                                                ; preds = %5
  switch i32 %1, label %43 [
    i32 256, label %9
    i32 70, label %11
    i32 32, label %26
    i32 80, label %34
    i32 66, label %36
    i32 48, label %38
    i32 49, label %38
    i32 50, label %38
    i32 51, label %38
    i32 52, label %38
    i32 53, label %38
    i32 54, label %38
    i32 55, label %38
    i32 56, label %38
    i32 57, label %38
  ]

9:                                                ; preds = %8
  %10 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  tail call void @glfwSetWindowShouldClose(ptr noundef %10, i32 noundef 1)
  br label %43

11:                                               ; preds = %8
  %12 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  %13 = tail call ptr @glfwGetWindowMonitor(ptr noundef %12)
  %14 = tail call ptr @glfwGetPrimaryMonitor()
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  call void @glfwGetMonitorWorkarea(ptr noundef %14, ptr noundef null, ptr noundef null, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %.not5 = icmp eq ptr %13, null
  %15 = load ptr, ptr @_ZL6window, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !9
  br i1 %.not5, label %17, label %19

17:                                               ; preds = %11
  %18 = load i32, ptr %7, align 4, !tbaa !9
  call void @glfwSetWindowMonitor(ptr noundef %15, ptr noundef %14, i32 noundef 0, i32 noundef 0, i32 noundef %16, i32 noundef %18, i32 noundef 60)
  br label %25

19:                                               ; preds = %11
  %20 = add nsw i32 %16, -1280
  %21 = sdiv i32 %20, 2
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = add nsw i32 %22, -720
  %24 = sdiv i32 %23, 2
  call void @glfwSetWindowMonitor(ptr noundef %15, ptr noundef null, i32 noundef %21, i32 noundef %24, i32 noundef 1280, i32 noundef 720, i32 noundef 60)
  br label %25

25:                                               ; preds = %19, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  br label %43

26:                                               ; preds = %8
  %27 = load float, ptr @_ZL9velocityY, align 4, !tbaa !11
  %28 = fcmp oeq float %27, 0.000000e+00
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store float 1.000000e+01, ptr @_ZL9velocityY, align 4, !tbaa !11
  br label %43

30:                                               ; preds = %26
  %31 = load i8, ptr @_ZL15doubleJumpReady, align 1, !tbaa !13, !range !15, !noundef !16
  %32 = trunc nuw i8 %31 to i1
  br i1 %32, label %33, label %43

33:                                               ; preds = %30
  store float 1.000000e+01, ptr @_ZL9velocityY, align 4, !tbaa !11
  store i8 0, ptr @_ZL15doubleJumpReady, align 1, !tbaa !13
  br label %43

34:                                               ; preds = %8
  store i32 0, ptr @_ZL8gameMode, align 4, !tbaa !17
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %43

36:                                               ; preds = %8
  store i32 1, ptr @_ZL8gameMode, align 4, !tbaa !17
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  br label %43

38:                                               ; preds = %8, %8, %8, %8, %8, %8, %8, %8, %8, %8
  %39 = load i32, ptr @_ZL8gameMode, align 4, !tbaa !17
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = add nsw i32 %1, -47
  store i32 %42, ptr @_ZL8material, align 4, !tbaa !9
  tail call void @_ZL19printPickedMaterialv()
  br label %43

43:                                               ; preds = %8, %38, %41, %29, %33, %30, %5, %36, %34, %25, %9
  ret void
}

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

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

declare ptr @glfwGetWindowMonitor(ptr noundef) local_unnamed_addr #1

declare ptr @glfwGetPrimaryMonitor() local_unnamed_addr #1

declare void @glfwGetMonitorWorkarea(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @glfwSetWindowMonitor(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, 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) #2

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL19printPickedMaterialv() local_unnamed_addr #0

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 willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !18, i64 0}
!18 = !{!"_ZTS8GameMode", !7, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass