; LLVM IR from erincatto/box2d-lite :: extern/glfw/src/linux_joystick.ll (glfwPlatformPollJoystick)

; 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._GLFWlibrary = type { i32, %struct.anon, ptr, ptr, ptr, ptr, i32, [16 x %struct._GLFWjoystick], ptr, i32, %struct._GLFWtls, %struct._GLFWtls, %struct._GLFWmutex, %struct.anon.4, %struct.anon.5, %struct.anon.6, %struct._GLFWlibraryX11, %struct._GLFWlibraryGLX, %struct._GLFWlibraryLinux, %struct._GLFWlibraryEGL, %struct._GLFWlibraryOSMesa }
%struct.anon = type { %struct._GLFWinitconfig, %struct._GLFWfbconfig, %struct._GLFWwndconfig, %struct._GLFWctxconfig, i32 }
%struct._GLFWinitconfig = type { i32, %struct.anon.0 }
%struct.anon.0 = type { i32, i32 }
%struct._GLFWfbconfig = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }
%struct._GLFWwndconfig = type { i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.anon.1, %struct.anon.2 }
%struct.anon.1 = type { i32, [256 x i8] }
%struct.anon.2 = type { [256 x i8], [256 x i8] }
%struct._GLFWctxconfig = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, %struct.anon.3 }
%struct.anon.3 = type { i32 }
%struct._GLFWjoystick = type { i32, ptr, i32, ptr, i32, ptr, i32, ptr, ptr, [33 x i8], ptr, %struct._GLFWjoystickLinux }
%struct._GLFWjoystickLinux = type { i32, [4096 x i8], [512 x i32], [64 x i32], [64 x %struct.input_absinfo], [4 x [2 x i32]] }
%struct.input_absinfo = type { i32, i32, i32, i32, i32, i32 }
%struct._GLFWtls = type { %struct._GLFWtlsPOSIX }
%struct._GLFWtlsPOSIX = type { i32, i32 }
%struct._GLFWmutex = type { %struct._GLFWmutexPOSIX }
%struct._GLFWmutexPOSIX = type { i32, %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.anon.4 = type { i64, %struct._GLFWtimerPOSIX }
%struct._GLFWtimerPOSIX = type { i32, i64 }
%struct.anon.5 = type { i32, ptr, [2 x ptr], ptr, ptr, i32, i32, i32 }
%struct.anon.6 = type { ptr, ptr }
%struct._GLFWlibraryX11 = type { ptr, i32, i64, float, float, i64, i64, i32, ptr, i32, ptr, ptr, [5 x i8], [256 x i16], [349 x i16], double, double, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, %struct.anon.7, %struct.anon.8, %struct.anon.9, %struct.anon.10, %struct.anon.11, %struct.anon.12, %struct.anon.13, %struct.anon.14, %struct.anon.15, %struct.anon.16 }
%struct.anon.7 = type { i32, ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.anon.8 = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.anon.9 = type { i32, i32, i32, i32, i32 }
%struct.anon.10 = type { i32, i64, i64 }
%struct.anon.11 = type { ptr, ptr, ptr, ptr }
%struct.anon.12 = type { i32, ptr, i32, i32, ptr, ptr, ptr }
%struct.anon.13 = type { ptr, ptr }
%struct.anon.14 = type { i32, ptr, i32, i32, ptr, ptr, ptr, ptr }
%struct.anon.15 = type { i32, ptr, i32, i32, i32, i32, i32, ptr, ptr }
%struct.anon.16 = type { i32, ptr, i32, i32, i32, i32, ptr, ptr, ptr }
%struct._GLFWlibraryGLX = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct._GLFWlibraryLinux = type { i32, i32, %struct.re_pattern_buffer, i32 }
%struct.re_pattern_buffer = type { ptr, i64, i64, i64, ptr, ptr, i64, i8 }
%struct._GLFWlibraryEGL = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._GLFWlibraryOSMesa = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.input_event = type { %struct.timeval, i16, i16, i32 }
%struct.timeval = type { i64, i64 }

@_glfw = external global %struct._GLFWlibrary, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden void @closeJoystick(ptr noundef) #1

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @_glfwPlatformPollJoystick(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.input_event, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %74, %72, %2
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  %8 = call ptr @__errno_location() #5
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._GLFWjoystick, ptr %9, i32 0, i32 11
  %11 = getelementptr inbounds %struct._GLFWjoystickLinux, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = call i64 @read(i32 noundef %12, ptr noundef %5, i64 noundef 24)
  %14 = icmp slt i64 %13, 0
  br i1 %14, label %15, label %22

15:                                               ; preds = %7
  %16 = call ptr @__errno_location() #5
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 19
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @closeJoystick(ptr noundef %20)
  br label %21

21:                                               ; preds = %19, %15
  store i32 2, ptr %6, align 4
  br label %72

22:                                               ; preds = %7
  %23 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 1
  %24 = load i16, ptr %23, align 8, !tbaa !14
  %25 = zext i16 %24 to i32
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %42

27:                                               ; preds = %22
  %28 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 2
  %29 = load i16, ptr %28, align 2, !tbaa !19
  %30 = zext i16 %29 to i32
  %31 = icmp eq i32 %30, 3
  br i1 %31, label %32, label %33

32:                                               ; preds = %27
  store i32 1, ptr getelementptr inbounds (%struct._GLFWlibraryLinux, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), i32 0, i32 3), align 8, !tbaa !20
  br label %41

33:                                               ; preds = %27
  %34 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 2
  %35 = load i16, ptr %34, align 2, !tbaa !19
  %36 = zext i16 %35 to i32
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %33
  store i32 0, ptr getelementptr inbounds (%struct._GLFWlibraryLinux, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), i32 0, i32 3), align 8, !tbaa !20
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  call void @pollAbsState(ptr noundef %39)
  br label %40

40:                                               ; preds = %38, %33
  br label %41

41:                                               ; preds = %40, %32
  br label %42

42:                                               ; preds = %41, %22
  %43 = load i32, ptr getelementptr inbounds (%struct._GLFWlibraryLinux, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), i32 0, i32 3), align 8, !tbaa !20
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  store i32 3, ptr %6, align 4
  br label %72

46:                                               ; preds = %42
  %47 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 1
  %48 = load i16, ptr %47, align 8, !tbaa !14
  %49 = zext i16 %48 to i32
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %51, label %58

51:                                               ; preds = %46
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 2
  %54 = load i16, ptr %53, align 2, !tbaa !19
  %55 = zext i16 %54 to i32
  %56 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 3
  %57 = load i32, ptr %56, align 4, !tbaa !56
  call void @handleKeyEvent(ptr noundef %52, i32 noundef %55, i32 noundef %57)
  br label %71

58:                                               ; preds = %46
  %59 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 1
  %60 = load i16, ptr %59, align 8, !tbaa !14
  %61 = zext i16 %60 to i32
  %62 = icmp eq i32 %61, 3
  br i1 %62, label %63, label %70

63:                                               ; preds = %58
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 2
  %66 = load i16, ptr %65, align 2, !tbaa !19
  %67 = zext i16 %66 to i32
  %68 = getelementptr inbounds %struct.input_event, ptr %5, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !56
  call void @handleAbsEvent(ptr noundef %64, i32 noundef %67, i32 noundef %69)
  br label %70

70:                                               ; preds = %63, %58
  br label %71

71:                                               ; preds = %70, %51
  store i32 0, ptr %6, align 4
  br label %72

72:                                               ; preds = %71, %45, %21
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  %73 = load i32, ptr %6, align 4
  switch i32 %73, label %79 [
    i32 0, label %74
    i32 2, label %75
    i32 3, label %7
  ]

74:                                               ; preds = %72
  br label %7

75:                                               ; preds = %72
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._GLFWjoystick, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !57
  ret i32 %78

79:                                               ; preds = %72
  unreachable
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

; Function Attrs: nounwind uwtable
declare hidden void @pollAbsState(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @handleKeyEvent(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @handleAbsEvent(ptr noundef, i32 noundef, i32 noundef) #1

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 120}
!12 = !{!"_GLFWjoystick", !10, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !6, i64 112, !13, i64 120}
!13 = !{!"_GLFWjoystickLinux", !10, i64 0, !7, i64 4, !7, i64 4100, !7, i64 6148, !7, i64 6404, !7, i64 7940}
!14 = !{!15, !18, i64 16}
!15 = !{!"input_event", !16, i64 0, !18, i64 16, !18, i64 18, !10, i64 20}
!16 = !{!"timeval", !17, i64 0, !17, i64 8}
!17 = !{!"long", !7, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!15, !18, i64 18}
!20 = !{!21, !10, i64 133256}
!21 = !{!"_GLFWlibrary", !10, i64 0, !22, i64 8, !6, i64 992, !6, i64 1000, !6, i64 1008, !6, i64 1016, !10, i64 1024, !7, i64 1032, !6, i64 130568, !10, i64 130576, !31, i64 130580, !31, i64 130588, !33, i64 130600, !35, i64 130648, !37, i64 130672, !38, i64 130736, !39, i64 130752, !51, i64 132960, !52, i64 133184, !54, i64 133264, !55, i64 133440}
!22 = !{!"", !23, i64 0, !25, i64 16, !26, i64 88, !29, i64 920, !10, i64 976}
!23 = !{!"_GLFWinitconfig", !10, i64 0, !24, i64 4}
!24 = !{!"", !10, i64 0, !10, i64 4}
!25 = !{!"_GLFWfbconfig", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !17, i64 64}
!26 = !{!"_GLFWwndconfig", !10, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !27, i64 56, !28, i64 316}
!27 = !{!"", !10, i64 0, !7, i64 4}
!28 = !{!"", !7, i64 0, !7, i64 256}
!29 = !{!"_GLFWctxconfig", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !30, i64 48}
!30 = !{!"", !10, i64 0}
!31 = !{!"_GLFWtls", !32, i64 0}
!32 = !{!"_GLFWtlsPOSIX", !10, i64 0, !10, i64 4}
!33 = !{!"_GLFWmutex", !34, i64 0}
!34 = !{!"_GLFWmutexPOSIX", !10, i64 0, !7, i64 8}
!35 = !{!"", !17, i64 0, !36, i64 8}
!36 = !{!"_GLFWtimerPOSIX", !10, i64 0, !17, i64 8}
!37 = !{!"", !10, i64 0, !6, i64 8, !7, i64 16, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56}
!38 = !{!"", !6, i64 0, !6, i64 8}
!39 = !{!"_GLFWlibraryX11", !6, i64 0, !10, i64 8, !17, i64 16, !40, i64 24, !40, i64 28, !17, i64 32, !17, i64 40, !10, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !6, i64 80, !7, i64 88, !7, i64 94, !7, i64 606, !41, i64 1304, !41, i64 1312, !6, i64 1320, !17, i64 1328, !17, i64 1336, !17, i64 1344, !17, i64 1352, !17, i64 1360, !17, i64 1368, !17, i64 1376, !17, i64 1384, !17, i64 1392, !17, i64 1400, !17, i64 1408, !17, i64 1416, !17, i64 1424, !17, i64 1432, !17, i64 1440, !17, i64 1448, !17, i64 1456, !17, i64 1464, !17, i64 1472, !17, i64 1480, !17, i64 1488, !17, i64 1496, !17, i64 1504, !17, i64 1512, !17, i64 1520, !17, i64 1528, !17, i64 1536, !17, i64 1544, !17, i64 1552, !17, i64 1560, !17, i64 1568, !17, i64 1576, !17, i64 1584, !17, i64 1592, !17, i64 1600, !17, i64 1608, !17, i64 1616, !17, i64 1624, !17, i64 1632, !17, i64 1640, !17, i64 1648, !17, i64 1656, !17, i64 1664, !17, i64 1672, !17, i64 1680, !17, i64 1688, !42, i64 1696, !43, i64 1872, !44, i64 1900, !45, i64 1920, !46, i64 1944, !47, i64 1976, !38, i64 2024, !48, i64 2040, !49, i64 2096, !50, i64 2152}
!40 = !{!"float", !7, i64 0}
!41 = !{!"double", !7, i64 0}
!42 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168}
!43 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!44 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!45 = !{!"", !10, i64 0, !17, i64 8, !17, i64 16}
!46 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!47 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40}
!48 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!49 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !6, i64 48}
!50 = !{!"", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !6, i64 48}
!51 = !{!"_GLFWlibraryGLX", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220}
!52 = !{!"_GLFWlibraryLinux", !10, i64 0, !10, i64 4, !53, i64 8, !10, i64 72}
!53 = !{!"re_pattern_buffer", !6, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !6, i64 32, !6, i64 40, !17, i64 48, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56, !10, i64 56}
!54 = !{!"_GLFWlibraryEGL", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168}
!55 = !{!"_GLFWlibraryOSMesa", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!56 = !{!15, !10, i64 20}
!57 = !{!12, !10, 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"

%struct._GLFWlibrary = type { i32, %struct.anon, ptr, ptr, ptr, ptr, i32, [16 x %struct._GLFWjoystick], ptr, i32, %struct._GLFWtls, %struct._GLFWtls, %struct._GLFWmutex, %struct.anon.4, %struct.anon.5, %struct.anon.6, %struct._GLFWlibraryX11, %struct._GLFWlibraryGLX, %struct._GLFWlibraryLinux, %struct._GLFWlibraryEGL, %struct._GLFWlibraryOSMesa }
%struct.anon = type { %struct._GLFWinitconfig, %struct._GLFWfbconfig, %struct._GLFWwndconfig, %struct._GLFWctxconfig, i32 }
%struct._GLFWinitconfig = type { i32, %struct.anon.0 }
%struct.anon.0 = type { i32, i32 }
%struct._GLFWfbconfig = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64 }
%struct._GLFWwndconfig = type { i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.anon.1, %struct.anon.2 }
%struct.anon.1 = type { i32, [256 x i8] }
%struct.anon.2 = type { [256 x i8], [256 x i8] }
%struct._GLFWctxconfig = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, %struct.anon.3 }
%struct.anon.3 = type { i32 }
%struct._GLFWjoystick = type { i32, ptr, i32, ptr, i32, ptr, i32, ptr, ptr, [33 x i8], ptr, %struct._GLFWjoystickLinux }
%struct._GLFWjoystickLinux = type { i32, [4096 x i8], [512 x i32], [64 x i32], [64 x %struct.input_absinfo], [4 x [2 x i32]] }
%struct.input_absinfo = type { i32, i32, i32, i32, i32, i32 }
%struct._GLFWtls = type { %struct._GLFWtlsPOSIX }
%struct._GLFWtlsPOSIX = type { i32, i32 }
%struct._GLFWmutex = type { %struct._GLFWmutexPOSIX }
%struct._GLFWmutexPOSIX = type { i32, %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.anon.4 = type { i64, %struct._GLFWtimerPOSIX }
%struct._GLFWtimerPOSIX = type { i32, i64 }
%struct.anon.5 = type { i32, ptr, [2 x ptr], ptr, ptr, i32, i32, i32 }
%struct.anon.6 = type { ptr, ptr }
%struct._GLFWlibraryX11 = type { ptr, i32, i64, float, float, i64, i64, i32, ptr, i32, ptr, ptr, [5 x i8], [256 x i16], [349 x i16], double, double, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, %struct.anon.7, %struct.anon.8, %struct.anon.9, %struct.anon.10, %struct.anon.11, %struct.anon.12, %struct.anon.13, %struct.anon.14, %struct.anon.15, %struct.anon.16 }
%struct.anon.7 = type { i32, ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.anon.8 = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.anon.9 = type { i32, i32, i32, i32, i32 }
%struct.anon.10 = type { i32, i64, i64 }
%struct.anon.11 = type { ptr, ptr, ptr, ptr }
%struct.anon.12 = type { i32, ptr, i32, i32, ptr, ptr, ptr }
%struct.anon.13 = type { ptr, ptr }
%struct.anon.14 = type { i32, ptr, i32, i32, ptr, ptr, ptr, ptr }
%struct.anon.15 = type { i32, ptr, i32, i32, i32, i32, i32, ptr, ptr }
%struct.anon.16 = type { i32, ptr, i32, i32, i32, i32, ptr, ptr, ptr }
%struct._GLFWlibraryGLX = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct._GLFWlibraryLinux = type { i32, i32, %struct.re_pattern_buffer, i32 }
%struct.re_pattern_buffer = type { ptr, i64, i64, i64, ptr, ptr, i64, i8 }
%struct._GLFWlibraryEGL = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._GLFWlibraryOSMesa = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.input_event = type { %struct.timeval, i16, i16, i32 }
%struct.timeval = type { i64, i64 }

@_glfw = external local_unnamed_addr global %struct._GLFWlibrary, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden void @closeJoystick(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @_glfwPlatformPollJoystick(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca %struct.input_event, align 8
  %4 = tail call ptr @__errno_location() #4
  %5 = getelementptr inbounds i8, ptr %0, i64 120
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = call i64 @read(i32 noundef %6, ptr noundef nonnull %3, i64 noundef 24) #5
  %8 = icmp slt i64 %7, 0
  br i1 %8, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %3, i64 16
  %10 = getelementptr inbounds i8, ptr %3, i64 18
  %11 = getelementptr inbounds i8, ptr %3, i64 20
  br label %15

._crit_edge:                                      ; preds = %31, %2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 19
  br i1 %13, label %14, label %35

14:                                               ; preds = %._crit_edge
  tail call void @closeJoystick(ptr noundef nonnull %0)
  br label %35

15:                                               ; preds = %.lr.ph, %31
  %16 = load i16, ptr %9, align 8, !tbaa !13
  %17 = icmp eq i16 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = load i16, ptr %10, align 2, !tbaa !18
  switch i16 %19, label %21 [
    i16 3, label %.thread
    i16 0, label %20
  ]

.thread:                                          ; preds = %18
  store i32 1, ptr getelementptr inbounds (i8, ptr @_glfw, i64 133256), align 8, !tbaa !19
  br label %31

20:                                               ; preds = %18
  store i32 0, ptr getelementptr inbounds (i8, ptr @_glfw, i64 133256), align 8, !tbaa !19
  tail call void @pollAbsState(ptr noundef nonnull %0)
  br label %21

21:                                               ; preds = %18, %20, %15
  %.pr = load i32, ptr getelementptr inbounds (i8, ptr @_glfw, i64 133256), align 8, !tbaa !19
  %.not = icmp eq i32 %.pr, 0
  br i1 %.not, label %22, label %31

22:                                               ; preds = %21
  switch i16 %16, label %31 [
    i16 1, label %23
    i16 3, label %27
  ]

23:                                               ; preds = %22
  %24 = load i16, ptr %10, align 2, !tbaa !18
  %25 = zext i16 %24 to i32
  %26 = load i32, ptr %11, align 4, !tbaa !55
  tail call void @handleKeyEvent(ptr noundef nonnull %0, i32 noundef %25, i32 noundef %26)
  br label %31

27:                                               ; preds = %22
  %28 = load i16, ptr %10, align 2, !tbaa !18
  %29 = zext i16 %28 to i32
  %30 = load i32, ptr %11, align 4, !tbaa !55
  tail call void @handleAbsEvent(ptr noundef nonnull %0, i32 noundef %29, i32 noundef %30)
  br label %31

31:                                               ; preds = %.thread, %23, %27, %22, %21
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 8, !tbaa !9
  %33 = call i64 @read(i32 noundef %32, ptr noundef nonnull %3, i64 noundef 24) #5
  %34 = icmp slt i64 %33, 0
  br i1 %34, label %._crit_edge, label %15

35:                                               ; preds = %14, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  %36 = load i32, ptr %0, align 8, !tbaa !56
  ret i32 %36
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @pollAbsState(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @handleKeyEvent(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @handleAbsEvent(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind 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 "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 nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 120}
!10 = !{!"_GLFWjoystick", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !11, i64 56, !11, i64 64, !7, i64 72, !11, i64 112, !12, i64 120}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_GLFWjoystickLinux", !6, i64 0, !7, i64 4, !7, i64 4100, !7, i64 6148, !7, i64 6404, !7, i64 7940}
!13 = !{!14, !17, i64 16}
!14 = !{!"input_event", !15, i64 0, !17, i64 16, !17, i64 18, !6, i64 20}
!15 = !{!"timeval", !16, i64 0, !16, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!14, !17, i64 18}
!19 = !{!20, !6, i64 133256}
!20 = !{!"_GLFWlibrary", !6, i64 0, !21, i64 8, !11, i64 992, !11, i64 1000, !11, i64 1008, !11, i64 1016, !6, i64 1024, !7, i64 1032, !11, i64 130568, !6, i64 130576, !30, i64 130580, !30, i64 130588, !32, i64 130600, !34, i64 130648, !36, i64 130672, !37, i64 130736, !38, i64 130752, !50, i64 132960, !51, i64 133184, !53, i64 133264, !54, i64 133440}
!21 = !{!"", !22, i64 0, !24, i64 16, !25, i64 88, !28, i64 920, !6, i64 976}
!22 = !{!"_GLFWinitconfig", !6, i64 0, !23, i64 4}
!23 = !{!"", !6, i64 0, !6, i64 4}
!24 = !{!"_GLFWfbconfig", !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, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !16, i64 64}
!25 = !{!"_GLFWwndconfig", !6, i64 0, !6, i64 4, !11, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !26, i64 56, !27, i64 316}
!26 = !{!"", !6, i64 0, !7, i64 4}
!27 = !{!"", !7, i64 0, !7, i64 256}
!28 = !{!"_GLFWctxconfig", !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, !6, i64 36, !11, i64 40, !29, i64 48}
!29 = !{!"", !6, i64 0}
!30 = !{!"_GLFWtls", !31, i64 0}
!31 = !{!"_GLFWtlsPOSIX", !6, i64 0, !6, i64 4}
!32 = !{!"_GLFWmutex", !33, i64 0}
!33 = !{!"_GLFWmutexPOSIX", !6, i64 0, !7, i64 8}
!34 = !{!"", !16, i64 0, !35, i64 8}
!35 = !{!"_GLFWtimerPOSIX", !6, i64 0, !16, i64 8}
!36 = !{!"", !6, i64 0, !11, i64 8, !7, i64 16, !11, i64 32, !11, i64 40, !6, i64 48, !6, i64 52, !6, i64 56}
!37 = !{!"", !11, i64 0, !11, i64 8}
!38 = !{!"_GLFWlibraryX11", !11, i64 0, !6, i64 8, !16, i64 16, !39, i64 24, !39, i64 28, !16, i64 32, !16, i64 40, !6, i64 48, !11, i64 56, !6, i64 64, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 94, !7, i64 606, !40, i64 1304, !40, i64 1312, !11, i64 1320, !16, i64 1328, !16, i64 1336, !16, i64 1344, !16, i64 1352, !16, i64 1360, !16, i64 1368, !16, i64 1376, !16, i64 1384, !16, i64 1392, !16, i64 1400, !16, i64 1408, !16, i64 1416, !16, i64 1424, !16, i64 1432, !16, i64 1440, !16, i64 1448, !16, i64 1456, !16, i64 1464, !16, i64 1472, !16, i64 1480, !16, i64 1488, !16, i64 1496, !16, i64 1504, !16, i64 1512, !16, i64 1520, !16, i64 1528, !16, i64 1536, !16, i64 1544, !16, i64 1552, !16, i64 1560, !16, i64 1568, !16, i64 1576, !16, i64 1584, !16, i64 1592, !16, i64 1600, !16, i64 1608, !16, i64 1616, !16, i64 1624, !16, i64 1632, !16, i64 1640, !16, i64 1648, !16, i64 1656, !16, i64 1664, !16, i64 1672, !16, i64 1680, !16, i64 1688, !41, i64 1696, !42, i64 1872, !43, i64 1900, !44, i64 1920, !45, i64 1944, !46, i64 1976, !37, i64 2024, !47, i64 2040, !48, i64 2096, !49, i64 2152}
!39 = !{!"float", !7, i64 0}
!40 = !{!"double", !7, i64 0}
!41 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168}
!42 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24}
!43 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!44 = !{!"", !6, i64 0, !16, i64 8, !16, i64 16}
!45 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!46 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}
!47 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!48 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !11, i64 40, !11, i64 48}
!49 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !11, i64 32, !11, i64 40, !11, i64 48}
!50 = !{!"_GLFWlibraryGLX", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !6, i64 176, !6, i64 180, !6, i64 184, !6, i64 188, !6, i64 192, !6, i64 196, !6, i64 200, !6, i64 204, !6, i64 208, !6, i64 212, !6, i64 216, !6, i64 220}
!51 = !{!"_GLFWlibraryLinux", !6, i64 0, !6, i64 4, !52, i64 8, !6, i64 72}
!52 = !{!"re_pattern_buffer", !11, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !11, i64 32, !11, i64 40, !16, i64 48, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56}
!53 = !{!"_GLFWlibraryEGL", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168}
!54 = !{!"_GLFWlibraryOSMesa", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!55 = !{!14, !6, i64 20}
!56 = !{!10, !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass