; LLVM IR from Eukky/TRender :: lib/glew/src (visualinfo)

; 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.GLContextStruct = type { ptr, ptr, ptr, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @DestroyContext(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.GLContextStruct, ptr %3, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp ne ptr null, %5
  br i1 %6, label %7, label %19

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.GLContextStruct, ptr %8, i32 0, i32 2
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %19

12:                                               ; preds = %7
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.GLContextStruct, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.GLContextStruct, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  call void @glXDestroyContext(ptr noundef %15, ptr noundef %18)
  br label %19

19:                                               ; preds = %12, %7, %1
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.GLContextStruct, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = icmp ne ptr null, %22
  br i1 %23, label %24, label %37

24:                                               ; preds = %19
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.GLContextStruct, ptr %25, i32 0, i32 3
  %27 = load i64, ptr %26, align 8, !tbaa !13
  %28 = icmp ne i64 0, %27
  br i1 %28, label %29, label %37

29:                                               ; preds = %24
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.GLContextStruct, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.GLContextStruct, ptr %33, i32 0, i32 3
  %35 = load i64, ptr %34, align 8, !tbaa !13
  %36 = call i32 @XDestroyWindow(ptr noundef %32, i64 noundef %35)
  br label %37

37:                                               ; preds = %29, %24, %19
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.GLContextStruct, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = icmp ne ptr null, %40
  br i1 %41, label %42, label %55

42:                                               ; preds = %37
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.GLContextStruct, ptr %43, i32 0, i32 4
  %45 = load i64, ptr %44, align 8, !tbaa !14
  %46 = icmp ne i64 0, %45
  br i1 %46, label %47, label %55

47:                                               ; preds = %42
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.GLContextStruct, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.GLContextStruct, ptr %51, i32 0, i32 4
  %53 = load i64, ptr %52, align 8, !tbaa !14
  %54 = call i32 @XFreeColormap(ptr noundef %50, i64 noundef %53)
  br label %55

55:                                               ; preds = %47, %42, %37
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.GLContextStruct, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = icmp ne ptr null, %58
  br i1 %59, label %60, label %65

60:                                               ; preds = %55
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.GLContextStruct, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = call i32 @XFree(ptr noundef %63)
  br label %65

65:                                               ; preds = %60, %55
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.GLContextStruct, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = icmp ne ptr null, %68
  br i1 %69, label %70, label %75

70:                                               ; preds = %65
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.GLContextStruct, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !9
  %74 = call i32 @XCloseDisplay(ptr noundef %73)
  br label %75

75:                                               ; preds = %70, %65
  ret void
}

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

declare i32 @XDestroyWindow(ptr noundef, i64 noundef) #1

declare i32 @XFreeColormap(ptr noundef, i64 noundef) #1

declare i32 @XFree(ptr noundef) #1

declare i32 @XCloseDisplay(ptr noundef) #1

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 = { "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" }

!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, !6, i64 0}
!10 = !{!"GLContextStruct", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !11, i64 24}
!14 = !{!10, !11, i64 32}
!15 = !{!10, !6, i64 8}


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

; Function Attrs: nounwind uwtable
define dso_local void @DestroyContext(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.thread33, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %.not23 = icmp eq ptr %5, null
  br i1 %.not23, label %.thread, label %6

6:                                                ; preds = %3
  tail call void @glXDestroyContext(ptr noundef nonnull %2, ptr noundef nonnull %5) #2
  %.pr.pre = load ptr, ptr %0, align 8, !tbaa !5
  %.not24 = icmp eq ptr %.pr.pre, null
  br i1 %.not24, label %.thread33, label %.thread

.thread:                                          ; preds = %3, %6
  %.pr39 = phi ptr [ %.pr.pre, %6 ], [ %2, %3 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !12
  %.not25 = icmp eq i64 %8, 0
  br i1 %.not25, label %.thread40, label %9

9:                                                ; preds = %.thread
  %10 = tail call i32 @XDestroyWindow(ptr noundef nonnull %.pr39, i64 noundef %8) #2
  %.pr32.pre = load ptr, ptr %0, align 8, !tbaa !5
  %.not26 = icmp eq ptr %.pr32.pre, null
  br i1 %.not26, label %.thread33, label %.thread40

.thread40:                                        ; preds = %.thread, %9
  %.pr3243 = phi ptr [ %.pr32.pre, %9 ], [ %.pr39, %.thread ]
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i64, ptr %11, align 8, !tbaa !13
  %.not27 = icmp eq i64 %12, 0
  br i1 %.not27, label %.thread33, label %13

13:                                               ; preds = %.thread40
  %14 = tail call i32 @XFreeColormap(ptr noundef nonnull %.pr3243, i64 noundef %12) #2
  br label %.thread33

.thread33:                                        ; preds = %1, %6, %13, %.thread40, %9
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %.not28 = icmp eq ptr %16, null
  br i1 %.not28, label %19, label %17

17:                                               ; preds = %.thread33
  %18 = tail call i32 @XFree(ptr noundef nonnull %16) #2
  br label %19

19:                                               ; preds = %17, %.thread33
  %20 = load ptr, ptr %0, align 8, !tbaa !5
  %.not29 = icmp eq ptr %20, null
  br i1 %.not29, label %23, label %21

21:                                               ; preds = %19
  %22 = tail call i32 @XCloseDisplay(ptr noundef nonnull %20) #2
  br label %23

23:                                               ; preds = %21, %19
  ret void
}

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

declare i32 @XDestroyWindow(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @XFreeColormap(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @XFree(ptr noundef) local_unnamed_addr #1

declare i32 @XCloseDisplay(ptr noundef) local_unnamed_addr #1

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 = { "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 = { 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 0}
!6 = !{!"GLContextStruct", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass