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

; 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.regmatch_t = type { i32, i32 }
%struct.dirent = type { i64, i64, i16, i8, [256 x i8] }

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@_glfw = external global %struct._GLFWlibrary, align 8
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @_glfwInitJoysticksLinux() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %struct.regmatch_t, align 4
  %8 = alloca [4096 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr @.str, ptr %4, align 8, !tbaa !9
  %9 = call i32 @inotify_init1(i32 noundef 526336) #4
  store i32 %9, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), align 8, !tbaa !11
  %10 = load i32, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), align 8, !tbaa !11
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %16

12:                                               ; preds = %0
  %13 = load i32, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), align 8, !tbaa !11
  %14 = load ptr, ptr %4, align 8, !tbaa !9
  %15 = call i32 @inotify_add_watch(i32 noundef %13, ptr noundef %14, i32 noundef 772) #4
  store i32 %15, ptr getelementptr inbounds (%struct._GLFWlibraryLinux, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), i32 0, i32 1), align 4, !tbaa !48
  br label %16

16:                                               ; preds = %12, %0
  %17 = call i32 @regcomp(ptr noundef getelementptr inbounds (%struct._GLFWlibraryLinux, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), i32 0, i32 2), ptr noundef @.str.1, i32 noundef 0)
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  call void (i32, ptr, ...) @_glfwInputError(i32 noundef 65544, ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %60

20:                                               ; preds = %16
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = call ptr @opendir(ptr noundef %21)
  store ptr %22, ptr %2, align 8, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %57

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  br label %26

26:                                               ; preds = %53, %51, %25
  %27 = load ptr, ptr %2, align 8, !tbaa !9
  %28 = call ptr @readdir(ptr noundef %27)
  store ptr %28, ptr %6, align 8, !tbaa !9
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %54

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.dirent, ptr %31, i32 0, i32 4
  %33 = getelementptr inbounds [256 x i8], ptr %32, i64 0, i64 0
  %34 = call i32 @regexec(ptr noundef getelementptr inbounds (%struct._GLFWlibraryLinux, ptr getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 18), i32 0, i32 2), ptr noundef %33, i64 noundef 1, ptr noundef %7, i32 noundef 0)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store i32 2, ptr %5, align 4
  br label %51, !llvm.loop !49

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4096, ptr %8) #4
  %38 = getelementptr inbounds [4096 x i8], ptr %8, i64 0, i64 0
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.dirent, ptr %40, i32 0, i32 4
  %42 = getelementptr inbounds [256 x i8], ptr %41, i64 0, i64 0
  %43 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %38, i64 noundef 4096, ptr noundef @.str.3, ptr noundef %39, ptr noundef %42) #4
  %44 = getelementptr inbounds [4096 x i8], ptr %8, i64 0, i64 0
  %45 = call i32 @openJoystickDevice(ptr noundef %44)
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %50

47:                                               ; preds = %37
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %3, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %47, %37
  call void @llvm.lifetime.end.p0(i64 4096, ptr %8) #4
  store i32 0, ptr %5, align 4
  br label %51

51:                                               ; preds = %50, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %52 = load i32, ptr %5, align 4
  switch i32 %52, label %62 [
    i32 0, label %53
    i32 2, label %26
  ]

53:                                               ; preds = %51
  br label %26, !llvm.loop !49

54:                                               ; preds = %26
  %55 = load ptr, ptr %2, align 8, !tbaa !9
  %56 = call i32 @closedir(ptr noundef %55)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %57

57:                                               ; preds = %54, %20
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  call void @qsort(ptr noundef getelementptr inbounds (%struct._GLFWlibrary, ptr @_glfw, i32 0, i32 7), i64 noundef %59, i64 noundef 8096, ptr noundef @compareJoysticks)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %60

60:                                               ; preds = %57, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %61 = load i32, ptr %1, align 4
  ret i32 %61

62:                                               ; preds = %51
  unreachable
}

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

; Function Attrs: nounwind
declare i32 @inotify_init1(i32 noundef) #2

; Function Attrs: nounwind
declare i32 @inotify_add_watch(i32 noundef, ptr noundef, i32 noundef) #2

declare i32 @regcomp(ptr noundef, ptr noundef, i32 noundef) #3

declare void @_glfwInputError(i32 noundef, ptr noundef, ...) #3

declare ptr @opendir(ptr noundef) #3

declare ptr @readdir(ptr noundef) #3

declare i32 @regexec(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @openJoystickDevice(ptr noundef) #0

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

declare i32 @closedir(ptr noundef) #3

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @compareJoysticks(ptr noundef, ptr noundef) #0

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 133184}
!12 = !{!"_GLFWlibrary", !6, i64 0, !13, i64 8, !10, i64 992, !10, i64 1000, !10, i64 1008, !10, i64 1016, !6, i64 1024, !7, i64 1032, !10, i64 130568, !6, i64 130576, !23, i64 130580, !23, i64 130588, !25, i64 130600, !27, i64 130648, !29, i64 130672, !30, i64 130736, !31, i64 130752, !43, i64 132960, !44, i64 133184, !46, i64 133264, !47, i64 133440}
!13 = !{!"", !14, i64 0, !16, i64 16, !18, i64 88, !21, i64 920, !6, i64 976}
!14 = !{!"_GLFWinitconfig", !6, i64 0, !15, i64 4}
!15 = !{!"", !6, i64 0, !6, i64 4}
!16 = !{!"_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, !17, i64 64}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_GLFWwndconfig", !6, i64 0, !6, i64 4, !10, 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, !19, i64 56, !20, i64 316}
!19 = !{!"", !6, i64 0, !7, i64 4}
!20 = !{!"", !7, i64 0, !7, i64 256}
!21 = !{!"_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, !10, i64 40, !22, i64 48}
!22 = !{!"", !6, i64 0}
!23 = !{!"_GLFWtls", !24, i64 0}
!24 = !{!"_GLFWtlsPOSIX", !6, i64 0, !6, i64 4}
!25 = !{!"_GLFWmutex", !26, i64 0}
!26 = !{!"_GLFWmutexPOSIX", !6, i64 0, !7, i64 8}
!27 = !{!"", !17, i64 0, !28, i64 8}
!28 = !{!"_GLFWtimerPOSIX", !6, i64 0, !17, i64 8}
!29 = !{!"", !6, i64 0, !10, i64 8, !7, i64 16, !10, i64 32, !10, i64 40, !6, i64 48, !6, i64 52, !6, i64 56}
!30 = !{!"", !10, i64 0, !10, i64 8}
!31 = !{!"_GLFWlibraryX11", !10, i64 0, !6, i64 8, !17, i64 16, !32, i64 24, !32, i64 28, !17, i64 32, !17, i64 40, !6, i64 48, !10, i64 56, !6, i64 64, !10, i64 72, !10, i64 80, !7, i64 88, !7, i64 94, !7, i64 606, !33, i64 1304, !33, i64 1312, !10, 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, !34, i64 1696, !35, i64 1872, !36, i64 1900, !37, i64 1920, !38, i64 1944, !39, i64 1976, !30, i64 2024, !40, i64 2040, !41, i64 2096, !42, i64 2152}
!32 = !{!"float", !7, i64 0}
!33 = !{!"double", !7, i64 0}
!34 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168}
!35 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24}
!36 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!37 = !{!"", !6, i64 0, !17, i64 8, !17, i64 16}
!38 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!39 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !10, i64 24, !10, i64 32, !10, i64 40}
!40 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!41 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !10, i64 48}
!42 = !{!"", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !10, i64 32, !10, i64 40, !10, i64 48}
!43 = !{!"_GLFWlibraryGLX", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, 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}
!44 = !{!"_GLFWlibraryLinux", !6, i64 0, !6, i64 4, !45, i64 8, !6, i64 72}
!45 = !{!"re_pattern_buffer", !10, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !10, i64 32, !10, i64 40, !17, i64 48, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56, !6, i64 56}
!46 = !{!"_GLFWlibraryEGL", !10, 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, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168}
!47 = !{!"_GLFWlibraryOSMesa", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!48 = !{!12, !6, i64 133188}
!49 = distinct !{!49, !50}
!50 = !{!"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"

%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.regmatch_t = type { i32, i32 }

@.str = external hidden unnamed_addr constant [11 x i8], align 1
@_glfw = external global %struct._GLFWlibrary, align 8
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @_glfwInitJoysticksLinux() local_unnamed_addr #0 {
  %1 = alloca %struct.regmatch_t, align 4
  %2 = alloca [4096 x i8], align 16
  %3 = tail call i32 @inotify_init1(i32 noundef 526336) #6
  store i32 %3, ptr getelementptr inbounds (i8, ptr @_glfw, i64 133184), align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %0
  %6 = tail call i32 @inotify_add_watch(i32 noundef %3, ptr noundef nonnull @.str, i32 noundef 772) #6
  store i32 %6, ptr getelementptr inbounds (i8, ptr @_glfw, i64 133188), align 4, !tbaa !46
  br label %7

7:                                                ; preds = %5, %0
  %8 = tail call i32 @regcomp(ptr noundef nonnull getelementptr inbounds (i8, ptr @_glfw, i64 133192), ptr noundef nonnull @.str.1, i32 noundef 0) #6
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %10, label %9

9:                                                ; preds = %7
  tail call void (i32, ptr, ...) @_glfwInputError(i32 noundef 65544, ptr noundef nonnull @.str.2) #6
  br label %25

10:                                               ; preds = %7
  %11 = tail call ptr @opendir(ptr noundef nonnull @.str)
  %.not14 = icmp eq ptr %11, null
  br i1 %.not14, label %24, label %.preheader

.preheader:                                       ; preds = %10
  %12 = tail call ptr @readdir(ptr noundef nonnull %11) #6
  %.not1518 = icmp eq ptr %12, null
  br i1 %.not1518, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %20
  %13 = phi ptr [ %21, %20 ], [ %12, %.preheader ]
  %.01019 = phi i32 [ %.2, %20 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %14 = getelementptr inbounds i8, ptr %13, i64 19
  %15 = call i32 @regexec(ptr noundef nonnull getelementptr inbounds (i8, ptr @_glfw, i64 133192), ptr noundef nonnull %14, i64 noundef 1, ptr noundef nonnull %1, i32 noundef 0) #6
  %.not16 = icmp eq i32 %15, 0
  br i1 %.not16, label %16, label %20, !llvm.loop !47

16:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %2) #6
  %17 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %2, i64 noundef 4096, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str, ptr noundef nonnull %14) #6
  %18 = call i32 @openJoystickDevice(ptr noundef nonnull %2)
  %.not17 = icmp ne i32 %18, 0
  %19 = zext i1 %.not17 to i32
  %spec.select = add nsw i32 %.01019, %19
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %2) #6
  br label %20

20:                                               ; preds = %.lr.ph, %16
  %.2 = phi i32 [ %spec.select, %16 ], [ %.01019, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %21 = call ptr @readdir(ptr noundef nonnull %11) #6
  %.not15 = icmp eq ptr %21, null
  br i1 %.not15, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %20
  %22 = sext i32 %.2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %.010.lcssa = phi i64 [ 0, %.preheader ], [ %22, %._crit_edge.loopexit ]
  %23 = call i32 @closedir(ptr noundef nonnull %11)
  br label %24

24:                                               ; preds = %._crit_edge, %10
  %.3 = phi i64 [ %.010.lcssa, %._crit_edge ], [ 0, %10 ]
  call void @qsort(ptr noundef nonnull getelementptr inbounds (i8, ptr @_glfw, i64 1032), i64 noundef %.3, i64 noundef 8096, ptr noundef nonnull @compareJoysticks) #6
  br label %25

25:                                               ; preds = %24, %9
  %.0 = phi i32 [ 0, %9 ], [ 1, %24 ]
  ret i32 %.0
}

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

; Function Attrs: nounwind
declare i32 @inotify_init1(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @inotify_add_watch(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @regcomp(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @_glfwInputError(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noalias noundef ptr @opendir(ptr nocapture noundef readonly) local_unnamed_addr #4

declare ptr @readdir(ptr noundef) local_unnamed_addr #3

declare i32 @regexec(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @openJoystickDevice(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nofree nounwind
declare noundef i32 @closedir(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden i32 @compareJoysticks(ptr noundef, ptr noundef) #0

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


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