; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl/tiny_x11_opengl_window.ll (ZN19TinyX11OpenGLWindow13enable_openglEv)

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

%class.TinyX11OpenGLWindow = type <{ %class.TinyWindowInterface, ptr, i8, i8, [6 x i8] }>
%class.TinyWindowInterface = type { ptr }
%struct.InternalData2 = type { ptr, i64, ptr, i64, %struct.XSetWindowAttributes, i64, ptr, %struct.XWindowAttributes, %union._XEvent, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr }
%struct.XSetWindowAttributes = type { i64, i64, i64, i64, i32, i32, i32, i64, i64, i32, i64, i64, i32, i64, i64 }
%struct.XWindowAttributes = type { i32, i32, i32, i32, i32, i32, ptr, i64, i32, i32, i32, i32, i64, i64, i32, i64, i32, i32, i64, i64, i64, i32, ptr }
%union._XEvent = type { [24 x i64] }
%struct.anon = type { ptr, ptr, i32, i32, i32, i32, ptr, i64, i64, i64, i32, ptr, i32, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, i32, i64, i64, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, i32, ptr, i64, i64, i32, i32, ptr, ptr, i32, ptr }

@_ZL12forceOpenGL3 = external hidden global i8, align 1
@.str = external hidden unnamed_addr constant [27 x i8], align 1
@_ZL16ctxErrorOccurred = external hidden global i8, align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@__const._ZN19TinyX11OpenGLWindow13enable_openglEv.context_attribs = external hidden unnamed_addr constant [9 x i32], align 16
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [65 x i8], align 1
@stderr = external global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@glad_glGetString = external global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN19TinyX11OpenGLWindow13enable_openglEv(ptr noundef nonnull align 8 dereferenceable(18) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [9 x i32], align 16
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8
  %14 = load i8, ptr @_ZL12forceOpenGL3, align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %131

16:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %17 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.InternalData2, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.InternalData2, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds %struct.anon, ptr %24, i32 0, i32 33
  %26 = load i32, ptr %25, align 8, !tbaa !22
  %27 = call ptr @glXQueryExtensionsString(ptr noundef %20, i32 noundef %26)
  store ptr %27, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store ptr null, ptr %4, align 8, !tbaa !5
  %28 = call ptr @glXGetProcAddressARB(ptr noundef @.str)
  store ptr %28, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store ptr null, ptr %5, align 8, !tbaa !5
  store i8 0, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %29 = call ptr @XSetErrorHandler(ptr noundef @_ZL15ctxErrorHandlerP9_XDisplayP11XErrorEvent)
  store ptr %29, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZL20isExtensionSupportedPKcS0_(ptr noundef %30, ptr noundef @.str.1)
  br i1 %31, label %32, label %35

32:                                               ; preds = %16
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %46, label %35

35:                                               ; preds = %32, %16
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %37 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.InternalData2, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = getelementptr inbounds %struct.InternalData2, ptr %42, i32 0, i32 9
  %44 = load ptr, ptr %43, align 8, !tbaa !24
  %45 = call ptr @glXCreateNewContext(ptr noundef %40, ptr noundef %44, i32 noundef 32788, ptr noundef null, i32 noundef 1)
  store ptr %45, ptr %5, align 8, !tbaa !5
  br label %87

46:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 36, ptr %7) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const._ZN19TinyX11OpenGLWindow13enable_openglEv.context_attribs, i64 36, i1 false)
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = getelementptr inbounds %struct.InternalData2, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = getelementptr inbounds %struct.InternalData2, ptr %54, i32 0, i32 9
  %56 = load ptr, ptr %55, align 8, !tbaa !24
  %57 = getelementptr inbounds [9 x i32], ptr %7, i64 0, i64 0
  %58 = call noundef ptr %48(ptr noundef %52, ptr noundef %56, ptr noundef null, i32 noundef 1, ptr noundef %57)
  store ptr %58, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = getelementptr inbounds %struct.InternalData2, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = call i32 @XSync(ptr noundef %62, i32 noundef 0)
  %64 = load i8, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !9, !range !11, !noundef !12
  %65 = trunc i8 %64 to i1
  br i1 %65, label %71, label %66

66:                                               ; preds = %46
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %71

69:                                               ; preds = %66
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %86

71:                                               ; preds = %66, %46
  %72 = getelementptr inbounds [9 x i32], ptr %7, i64 0, i64 1
  store i32 1, ptr %72, align 4, !tbaa !25
  %73 = getelementptr inbounds [9 x i32], ptr %7, i64 0, i64 3
  store i32 0, ptr %73, align 4, !tbaa !25
  store i8 0, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !9
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !13
  %78 = getelementptr inbounds %struct.InternalData2, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !16
  %80 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %81 = load ptr, ptr %80, align 8, !tbaa !13
  %82 = getelementptr inbounds %struct.InternalData2, ptr %81, i32 0, i32 9
  %83 = load ptr, ptr %82, align 8, !tbaa !24
  %84 = getelementptr inbounds [9 x i32], ptr %7, i64 0, i64 0
  %85 = call noundef ptr %75(ptr noundef %79, ptr noundef %83, ptr noundef null, i32 noundef 1, ptr noundef %84)
  store ptr %85, ptr %5, align 8, !tbaa !5
  br label %86

86:                                               ; preds = %71, %69
  call void @llvm.lifetime.end.p0(i64 36, ptr %7) #7
  br label %87

87:                                               ; preds = %86, %35
  %88 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !13
  %90 = getelementptr inbounds %struct.InternalData2, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !16
  %92 = call i32 @XSync(ptr noundef %91, i32 noundef 0)
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = call ptr @XSetErrorHandler(ptr noundef %93)
  %95 = load i8, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !9, !range !11, !noundef !12
  %96 = trunc i8 %95 to i1
  br i1 %96, label %100, label %97

97:                                               ; preds = %87
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = icmp ne ptr %98, null
  br i1 %99, label %103, label %100

100:                                              ; preds = %97, %87
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.6) #7
  call void @exit(i32 noundef 1) #8
  unreachable

103:                                              ; preds = %97
  %104 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !13
  %106 = getelementptr inbounds %struct.InternalData2, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !16
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = call i32 @glXIsDirect(ptr noundef %107, ptr noundef %108)
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %113, label %111

111:                                              ; preds = %103
  %112 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %115

113:                                              ; preds = %103
  %114 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %115

115:                                              ; preds = %113, %111
  %116 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %117 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %118 = load ptr, ptr %117, align 8, !tbaa !13
  %119 = getelementptr inbounds %struct.InternalData2, ptr %118, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !16
  %121 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !13
  %123 = getelementptr inbounds %struct.InternalData2, ptr %122, i32 0, i32 5
  %124 = load i64, ptr %123, align 8, !tbaa !26
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = call i32 @glXMakeCurrent(ptr noundef %120, i64 noundef %124, ptr noundef %125)
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %129 = load ptr, ptr %128, align 8, !tbaa !13
  %130 = getelementptr inbounds %struct.InternalData2, ptr %129, i32 0, i32 6
  store ptr %127, ptr %130, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %157

131:                                              ; preds = %1
  %132 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %133 = load ptr, ptr %132, align 8, !tbaa !13
  %134 = getelementptr inbounds %struct.InternalData2, ptr %133, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !16
  %136 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %137 = load ptr, ptr %136, align 8, !tbaa !13
  %138 = getelementptr inbounds %struct.InternalData2, ptr %137, i32 0, i32 2
  %139 = load ptr, ptr %138, align 8, !tbaa !28
  %140 = call ptr @glXCreateContext(ptr noundef %135, ptr noundef %139, ptr noundef null, i32 noundef 1)
  %141 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %142 = load ptr, ptr %141, align 8, !tbaa !13
  %143 = getelementptr inbounds %struct.InternalData2, ptr %142, i32 0, i32 6
  store ptr %140, ptr %143, align 8, !tbaa !27
  %144 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %145 = load ptr, ptr %144, align 8, !tbaa !13
  %146 = getelementptr inbounds %struct.InternalData2, ptr %145, i32 0, i32 0
  %147 = load ptr, ptr %146, align 8, !tbaa !16
  %148 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !13
  %150 = getelementptr inbounds %struct.InternalData2, ptr %149, i32 0, i32 5
  %151 = load i64, ptr %150, align 8, !tbaa !26
  %152 = getelementptr inbounds %class.TinyX11OpenGLWindow, ptr %13, i32 0, i32 1
  %153 = load ptr, ptr %152, align 8, !tbaa !13
  %154 = getelementptr inbounds %struct.InternalData2, ptr %153, i32 0, i32 6
  %155 = load ptr, ptr %154, align 8, !tbaa !27
  %156 = call i32 @glXMakeCurrent(ptr noundef %147, i64 noundef %151, ptr noundef %155)
  br label %157

157:                                              ; preds = %131, %115
  %158 = call i32 @gladLoaderLoadGL()
  %159 = icmp ne i32 %158, 0
  br i1 %159, label %162, label %160

160:                                              ; preds = %157
  %161 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @exit(i32 noundef -1) #8
  unreachable

162:                                              ; preds = %157
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %163 = load ptr, ptr @glad_glGetString, align 8, !tbaa !5
  %164 = call ptr %163(i32 noundef 7936)
  store ptr %164, ptr %8, align 8, !tbaa !5
  %165 = load ptr, ptr %8, align 8, !tbaa !5
  %166 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef %165)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %167 = load ptr, ptr @glad_glGetString, align 8, !tbaa !5
  %168 = call ptr %167(i32 noundef 7937)
  store ptr %168, ptr %9, align 8, !tbaa !5
  %169 = load ptr, ptr %9, align 8, !tbaa !5
  %170 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, ptr noundef %169)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %171 = load ptr, ptr @glad_glGetString, align 8, !tbaa !5
  %172 = call ptr %171(i32 noundef 7938)
  store ptr %172, ptr %10, align 8, !tbaa !5
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, ptr noundef %173)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %175 = load ptr, ptr @glad_glGetString, align 8, !tbaa !5
  %176 = call ptr %175(i32 noundef 35724)
  store ptr %176, ptr %11, align 8, !tbaa !5
  %177 = load ptr, ptr %11, align 8, !tbaa !5
  %178 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, ptr noundef %177)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %179 = call i32 @pthread_getconcurrency() #7
  store i32 %179, ptr %12, align 4, !tbaa !25
  %180 = load i32, ptr %12, align 4, !tbaa !25
  %181 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef %180)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  ret void
}

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

declare ptr @glXQueryExtensionsString(ptr noundef, i32 noundef) #2

declare ptr @glXGetProcAddressARB(ptr noundef) #2

declare ptr @XSetErrorHandler(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL15ctxErrorHandlerP9_XDisplayP11XErrorEvent(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL20isExtensionSupportedPKcS0_(ptr noundef, ptr noundef) #3

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

declare ptr @glXCreateNewContext(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare i32 @XSync(ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #5

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #6

declare i32 @glXIsDirect(ptr noundef, ptr noundef) #2

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

declare ptr @glXCreateContext(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @gladLoaderLoadGL() #2

; Function Attrs: nounwind
declare i32 @pthread_getconcurrency() #5

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { noreturn 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS19TinyX11OpenGLWindow", !15, i64 0, !6, i64 8, !10, i64 16, !10, i64 17}
!15 = !{!"_ZTS19TinyWindowInterface"}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS13InternalData2", !6, i64 0, !18, i64 8, !6, i64 16, !18, i64 24, !19, i64 32, !18, i64 144, !6, i64 152, !21, i64 160, !7, i64 296, !6, i64 488, !20, i64 496, !20, i64 500, !20, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS20XSetWindowAttributes", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24, !20, i64 32, !20, i64 36, !20, i64 40, !18, i64 48, !18, i64 56, !20, i64 64, !18, i64 72, !18, i64 80, !20, i64 88, !18, i64 96, !18, i64 104}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTS17XWindowAttributes", !20, i64 0, !20, i64 4, !20, i64 8, !20, i64 12, !20, i64 16, !20, i64 20, !6, i64 24, !18, i64 32, !20, i64 40, !20, i64 44, !20, i64 48, !20, i64 52, !18, i64 56, !18, i64 64, !20, i64 72, !18, i64 80, !20, i64 88, !20, i64 92, !18, i64 96, !18, i64 104, !18, i64 112, !20, i64 120, !6, i64 128}
!22 = !{!23, !20, i64 224}
!23 = !{!"_ZTS3$_0", !6, i64 0, !6, i64 8, !20, i64 16, !20, i64 20, !20, i64 24, !20, i64 28, !6, i64 32, !18, i64 40, !18, i64 48, !18, i64 56, !20, i64 64, !6, i64 72, !20, i64 80, !20, i64 84, !20, i64 88, !20, i64 92, !20, i64 96, !6, i64 104, !20, i64 112, !20, i64 116, !6, i64 120, !6, i64 128, !20, i64 136, !18, i64 144, !18, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !20, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !20, i64 224, !20, i64 228, !6, i64 232, !18, i64 240, !18, i64 248, !20, i64 256, !20, i64 260, !6, i64 264, !6, i64 272, !20, i64 280, !6, i64 288}
!24 = !{!17, !6, i64 488}
!25 = !{!20, !20, i64 0}
!26 = !{!17, !18, i64 144}
!27 = !{!17, !6, i64 152}
!28 = !{!17, !6, i64 16}


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

@_ZL12forceOpenGL3 = external hidden local_unnamed_addr global i8, align 1
@.str = external hidden unnamed_addr constant [27 x i8], align 1
@_ZL16ctxErrorOccurred = external hidden local_unnamed_addr global i8, align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@__const._ZN19TinyX11OpenGLWindow13enable_openglEv.context_attribs = external hidden unnamed_addr constant [9 x i32], align 16
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [65 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.6 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@glad_glGetString = external local_unnamed_addr global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN19TinyX11OpenGLWindow13enable_openglEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(18) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca [9 x i32], align 16
  %3 = load i8, ptr @_ZL12forceOpenGL3, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = trunc nuw i8 %3 to i1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  br i1 %4, label %8, label %72

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %7, i64 224
  %10 = load i32, ptr %9, align 8, !tbaa !21
  %11 = tail call ptr @glXQueryExtensionsString(ptr noundef %7, i32 noundef %10)
  %12 = tail call ptr @glXGetProcAddressARB(ptr noundef nonnull @.str)
  store i8 0, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !5
  %13 = tail call ptr @XSetErrorHandler(ptr noundef nonnull @_ZL15ctxErrorHandlerP9_XDisplayP11XErrorEvent)
  %14 = tail call noundef zeroext i1 @_ZL20isExtensionSupportedPKcS0_(ptr noundef %11, ptr noundef nonnull @.str.1)
  %15 = icmp ne ptr %12, null
  %or.cond = select i1 %14, i1 %15, i1 false
  br i1 %or.cond, label %23, label %16

16:                                               ; preds = %8
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %18 = load ptr, ptr %5, align 8, !tbaa !11
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %18, i64 488
  %21 = load ptr, ptr %20, align 8, !tbaa !23
  %22 = tail call ptr @glXCreateNewContext(ptr noundef %19, ptr noundef %21, i32 noundef 32788, ptr noundef null, i32 noundef 1)
  br label %48

23:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %2) #8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(36) %2, ptr noundef nonnull align 16 dereferenceable(36) @__const._ZN19TinyX11OpenGLWindow13enable_openglEv.context_attribs, i64 36, i1 false)
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %25 = load ptr, ptr %5, align 8, !tbaa !11
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %25, i64 488
  %28 = load ptr, ptr %27, align 8, !tbaa !23
  %29 = call noundef ptr %12(ptr noundef %26, ptr noundef %28, ptr noundef null, i32 noundef 1, ptr noundef nonnull %2)
  %30 = load ptr, ptr %5, align 8, !tbaa !11
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = call i32 @XSync(ptr noundef %31, i32 noundef 0)
  %33 = load i8, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !5, !range !9, !noundef !10
  %34 = trunc nuw i8 %33 to i1
  %35 = icmp eq ptr %29, null
  %or.cond3.not = or i1 %35, %34
  br i1 %or.cond3.not, label %38, label %36

36:                                               ; preds = %23
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %47

38:                                               ; preds = %23
  %39 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 1, ptr %39, align 4, !tbaa !24
  %40 = getelementptr inbounds i8, ptr %2, i64 12
  store i32 0, ptr %40, align 4, !tbaa !24
  store i8 0, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !5
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %42 = load ptr, ptr %5, align 8, !tbaa !11
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = getelementptr inbounds i8, ptr %42, i64 488
  %45 = load ptr, ptr %44, align 8, !tbaa !23
  %46 = call noundef ptr %12(ptr noundef %43, ptr noundef %45, ptr noundef null, i32 noundef 1, ptr noundef nonnull %2)
  br label %47

47:                                               ; preds = %38, %36
  %.0 = phi ptr [ %29, %36 ], [ %46, %38 ]
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %2) #8
  br label %48

48:                                               ; preds = %47, %16
  %.1 = phi ptr [ %.0, %47 ], [ %22, %16 ]
  %49 = load ptr, ptr %5, align 8, !tbaa !11
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = call i32 @XSync(ptr noundef %50, i32 noundef 0)
  %52 = call ptr @XSetErrorHandler(ptr noundef %13)
  %53 = load i8, ptr @_ZL16ctxErrorOccurred, align 1, !tbaa !5, !range !9, !noundef !10
  %54 = trunc nuw i8 %53 to i1
  %55 = icmp eq ptr %.1, null
  %or.cond6.not = select i1 %54, i1 true, i1 %55
  br i1 %or.cond6.not, label %56, label %59

56:                                               ; preds = %48
  %57 = load ptr, ptr @stderr, align 8, !tbaa !25
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.6) #9
  call void @exit(i32 noundef 1) #10
  unreachable

59:                                               ; preds = %48
  %60 = load ptr, ptr %5, align 8, !tbaa !11
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = call i32 @glXIsDirect(ptr noundef %61, ptr noundef nonnull %.1)
  %.not = icmp eq i32 %62, 0
  %.str.7..str.8 = select i1 %.not, ptr @.str.7, ptr @.str.8
  %63 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.7..str.8)
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %65 = load ptr, ptr %5, align 8, !tbaa !11
  %66 = load ptr, ptr %65, align 8, !tbaa !15
  %67 = getelementptr inbounds i8, ptr %65, i64 144
  %68 = load i64, ptr %67, align 8, !tbaa !26
  %69 = call i32 @glXMakeCurrent(ptr noundef %66, i64 noundef %68, ptr noundef nonnull %.1)
  %70 = load ptr, ptr %5, align 8, !tbaa !11
  %71 = getelementptr inbounds i8, ptr %70, i64 152
  store ptr %.1, ptr %71, align 8, !tbaa !27
  br label %82

72:                                               ; preds = %1
  %73 = getelementptr inbounds i8, ptr %6, i64 16
  %74 = load ptr, ptr %73, align 8, !tbaa !28
  %75 = tail call ptr @glXCreateContext(ptr noundef %7, ptr noundef %74, ptr noundef null, i32 noundef 1)
  %76 = load ptr, ptr %5, align 8, !tbaa !11
  %77 = getelementptr inbounds i8, ptr %76, i64 152
  store ptr %75, ptr %77, align 8, !tbaa !27
  %78 = load ptr, ptr %76, align 8, !tbaa !15
  %79 = getelementptr inbounds i8, ptr %76, i64 144
  %80 = load i64, ptr %79, align 8, !tbaa !26
  %81 = tail call i32 @glXMakeCurrent(ptr noundef %78, i64 noundef %80, ptr noundef %75)
  br label %82

82:                                               ; preds = %72, %59
  %83 = call i32 @gladLoaderLoadGL()
  %.not24 = icmp eq i32 %83, 0
  br i1 %.not24, label %84, label %86

84:                                               ; preds = %82
  %85 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @exit(i32 noundef -1) #10
  unreachable

86:                                               ; preds = %82
  %87 = load ptr, ptr @glad_glGetString, align 8, !tbaa !25
  %88 = call ptr %87(i32 noundef 7936)
  %89 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %88)
  %90 = load ptr, ptr @glad_glGetString, align 8, !tbaa !25
  %91 = call ptr %90(i32 noundef 7937)
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef %91)
  %93 = load ptr, ptr @glad_glGetString, align 8, !tbaa !25
  %94 = call ptr %93(i32 noundef 7938)
  %95 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, ptr noundef %94)
  %96 = load ptr, ptr @glad_glGetString, align 8, !tbaa !25
  %97 = call ptr %96(i32 noundef 35724)
  %98 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, ptr noundef %97)
  %99 = call i32 @pthread_getconcurrency() #8
  %100 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef %99)
  ret void
}

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

declare ptr @glXQueryExtensionsString(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @glXGetProcAddressARB(ptr noundef) local_unnamed_addr #2

declare ptr @XSetErrorHandler(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL15ctxErrorHandlerP9_XDisplayP11XErrorEvent(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL20isExtensionSupportedPKcS0_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare ptr @glXCreateNewContext(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

declare i32 @XSync(ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #6

declare i32 @glXIsDirect(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @glXMakeCurrent(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @glXCreateContext(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @gladLoaderLoadGL() local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @pthread_getconcurrency() local_unnamed_addr #7

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { noreturn 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { cold nounwind }
attributes #10 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTS19TinyX11OpenGLWindow", !13, i64 0, !14, i64 8, !6, i64 16, !6, i64 17}
!13 = !{!"_ZTS19TinyWindowInterface"}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_ZTS13InternalData2", !14, i64 0, !17, i64 8, !14, i64 16, !17, i64 24, !18, i64 32, !17, i64 144, !14, i64 152, !20, i64 160, !7, i64 296, !14, i64 488, !19, i64 496, !19, i64 500, !19, i64 504, !14, i64 512, !14, i64 520, !14, i64 528, !14, i64 536, !14, i64 544}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTS20XSetWindowAttributes", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !19, i64 32, !19, i64 36, !19, i64 40, !17, i64 48, !17, i64 56, !19, i64 64, !17, i64 72, !17, i64 80, !19, i64 88, !17, i64 96, !17, i64 104}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_ZTS17XWindowAttributes", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12, !19, i64 16, !19, i64 20, !14, i64 24, !17, i64 32, !19, i64 40, !19, i64 44, !19, i64 48, !19, i64 52, !17, i64 56, !17, i64 64, !19, i64 72, !17, i64 80, !19, i64 88, !19, i64 92, !17, i64 96, !17, i64 104, !17, i64 112, !19, i64 120, !14, i64 128}
!21 = !{!22, !19, i64 224}
!22 = !{!"_ZTS3$_0", !14, i64 0, !14, i64 8, !19, i64 16, !19, i64 20, !19, i64 24, !19, i64 28, !14, i64 32, !17, i64 40, !17, i64 48, !17, i64 56, !19, i64 64, !14, i64 72, !19, i64 80, !19, i64 84, !19, i64 88, !19, i64 92, !19, i64 96, !14, i64 104, !19, i64 112, !19, i64 116, !14, i64 120, !14, i64 128, !19, i64 136, !17, i64 144, !17, i64 152, !14, i64 160, !14, i64 168, !14, i64 176, !14, i64 184, !19, i64 192, !14, i64 200, !14, i64 208, !14, i64 216, !19, i64 224, !19, i64 228, !14, i64 232, !17, i64 240, !17, i64 248, !19, i64 256, !19, i64 260, !14, i64 264, !14, i64 272, !19, i64 280, !14, i64 288}
!23 = !{!16, !14, i64 488}
!24 = !{!19, !19, i64 0}
!25 = !{!14, !14, i64 0}
!26 = !{!16, !17, i64 144}
!27 = !{!16, !14, i64 152}
!28 = !{!16, !14, i64 16}


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