; LLVM IR from ElsevierSoftwareX/SOFTX-D-20-00016 :: GameplayFootball/src/libs/glee (GLee)

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

@__GLeeInited = external dso_local global i8, align 1
@__GLeeGLLoadFunction = external dso_local global [409 x ptr], align 16
@__GLeeGLXLoadFunction = external dso_local global [51 x ptr], align 16
@__GLeeInitedLoadFunctions = external dso_local global i8, align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @GLeeInit() #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @initGLLoadFunctions() #0

; Function Attrs: nounwind uwtable
declare dso_local void @initGLXLoadFunctions() #0

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @GLeeForceLink(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call i64 @strlen(ptr noundef %8) #4
  %10 = trunc i64 %9 to i32
  store i32 %10, ptr %6, align 4, !tbaa !9
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 5
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %64

14:                                               ; preds = %1
  %15 = load i8, ptr @__GLeeInitedLoadFunctions, align 1, !tbaa !11
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %23, label %17

17:                                               ; preds = %14
  %18 = load i8, ptr @__GLeeInited, align 1, !tbaa !11
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %22, label %20

20:                                               ; preds = %17
  %21 = call zeroext i8 @GLeeInit()
  br label %22

22:                                               ; preds = %20, %17
  call void @initGLLoadFunctions()
  call void @initGLXLoadFunctions()
  store i8 1, ptr @__GLeeInitedLoadFunctions, align 1, !tbaa !11
  br label %23

23:                                               ; preds = %22, %14
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 0
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 87
  br i1 %28, label %29, label %30

29:                                               ; preds = %23
  store i32 1, ptr %4, align 4, !tbaa !9
  br label %38

30:                                               ; preds = %23
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %31, i64 2
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 88
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store i32 2, ptr %4, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %36, %30
  br label %38

38:                                               ; preds = %37, %29
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = call i32 @__GLeeGetExtensionNumber(ptr noundef %39, i32 noundef %40)
  store i32 %41, ptr %5, align 4, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = icmp eq i32 %42, -1
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %64

45:                                               ; preds = %38
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %54

48:                                               ; preds = %45
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [409 x ptr], ptr @__GLeeGLLoadFunction, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = call i32 %52()
  store i32 %53, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %64

54:                                               ; preds = %45
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 2
  br i1 %56, label %57, label %63

57:                                               ; preds = %54
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [51 x ptr], ptr @__GLeeGLXLoadFunction, i64 0, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = call i32 %61()
  store i32 %62, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %64

63:                                               ; preds = %54
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %64

64:                                               ; preds = %63, %57, %48, %44, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %65 = load i32, ptr %2, align 4
  ret i32 %65
}

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 willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@__GLeeInited = external dso_local local_unnamed_addr global i8, align 1
@__GLeeGLLoadFunction = external dso_local local_unnamed_addr global [409 x ptr], align 16
@__GLeeGLXLoadFunction = external dso_local local_unnamed_addr global [51 x ptr], align 16
@__GLeeInitedLoadFunctions = external dso_local local_unnamed_addr global i8, align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @GLeeInit() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @initGLLoadFunctions() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @initGLXLoadFunctions() local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @__GLeeGetExtensionNumber(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @GLeeForceLink(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #2
  %3 = trunc i64 %2 to i32
  %4 = icmp slt i32 %3, 5
  br i1 %4, label %34, label %5

5:                                                ; preds = %1
  %6 = load i8, ptr @__GLeeInitedLoadFunctions, align 1, !tbaa !5
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %7, label %12

7:                                                ; preds = %5
  %8 = load i8, ptr @__GLeeInited, align 1, !tbaa !5
  %.not13 = icmp eq i8 %8, 0
  br i1 %.not13, label %9, label %11

9:                                                ; preds = %7
  %10 = tail call zeroext i8 @GLeeInit()
  br label %11

11:                                               ; preds = %9, %7
  tail call void @initGLLoadFunctions()
  tail call void @initGLXLoadFunctions()
  store i8 1, ptr @__GLeeInitedLoadFunctions, align 1, !tbaa !5
  br label %12

12:                                               ; preds = %11, %5
  %13 = load i8, ptr %0, align 1, !tbaa !5
  %.not17 = icmp eq i8 %13, 87
  br i1 %.not17, label %.thread18, label %15

.thread18:                                        ; preds = %12
  %14 = tail call i32 @__GLeeGetExtensionNumber(ptr noundef nonnull %0, i32 noundef 1)
  br label %34

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 2
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = icmp eq i8 %17, 88
  br i1 %18, label %19, label %.thread

19:                                               ; preds = %15
  %20 = tail call i32 @__GLeeGetExtensionNumber(ptr noundef nonnull %0, i32 noundef 2)
  %21 = icmp eq i32 %20, -1
  %brmerge = or i1 %.not17, %21
  br i1 %brmerge, label %34, label %29

.thread:                                          ; preds = %15
  %22 = tail call i32 @__GLeeGetExtensionNumber(ptr noundef nonnull %0, i32 noundef 0)
  %23 = icmp eq i32 %22, -1
  br i1 %23, label %34, label %24

24:                                               ; preds = %.thread
  %25 = sext i32 %22 to i64
  %26 = getelementptr inbounds [409 x ptr], ptr @__GLeeGLLoadFunction, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !8
  %28 = tail call i32 %27() #3
  br label %34

29:                                               ; preds = %19
  %30 = sext i32 %20 to i64
  %31 = getelementptr inbounds [51 x ptr], ptr @__GLeeGLXLoadFunction, i64 0, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !8
  %33 = tail call i32 %32() #3
  br label %34

34:                                               ; preds = %.thread18, %19, %.thread, %1, %29, %24
  %.0 = phi i32 [ %28, %24 ], [ %33, %29 ], [ 0, %1 ], [ 0, %19 ], [ 0, %.thread ], [ 0, %.thread18 ]
  ret i32 %.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 nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #3 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass