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

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

@.str.28 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @__GLeeExtList_add(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local ptr @__GLeeGetExtStrPlat() #2

; Function Attrs: nounwind uwtable
declare dso_local void @__GLeeWriteError(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @__GLeeGetExtensions(ptr noundef %0) #2 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %11 = call ptr @__GLeeGetExtStrPlat()
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %1
  store ptr @.str.28, ptr %4, align 8, !tbaa !5
  br label %19

15:                                               ; preds = %1
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i64 @strlen(ptr noundef %16) #7
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %15, %14
  %20 = call ptr @glGetString(i32 noundef 7939)
  store ptr %20, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  call void @__GLeeWriteError(ptr noundef @.str.29)
  store i8 0, ptr %2, align 1
  store i32 1, ptr %10, align 4
  br label %88

24:                                               ; preds = %19
  store i32 0, ptr %9, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %40

27:                                               ; preds = %24
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = sub nsw i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %28, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = icmp ne i32 %34, 32
  br i1 %35, label %36, label %39

36:                                               ; preds = %27
  store i32 1, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %8, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %36, %27
  br label %40

40:                                               ; preds = %39, %24
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call i64 @strlen(ptr noundef %41) #7
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = add i64 %44, %42
  %46 = trunc i64 %45 to i32
  store i32 %46, ptr %8, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = call noalias ptr @malloc(i64 noundef %49) #8
  store ptr %50, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = icmp ne i32 %55, 0
  %57 = zext i1 %56 to i64
  %58 = select i1 %56, ptr @.str.30, ptr @.str.31
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %51, i64 noundef %54, ptr noundef %58, ptr noundef %59, ptr noundef %60) #6
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  store ptr %65, ptr %7, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %81, %40
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = icmp ugt ptr %67, %68
  br i1 %69, label %70, label %84

70:                                               ; preds = %66
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load i8, ptr %71, align 1, !tbaa !11
  %73 = sext i8 %72 to i32
  %74 = icmp eq i32 %73, 32
  br i1 %74, label %75, label %80

75:                                               ; preds = %70
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 1
  call void @__GLeeExtList_add(ptr noundef %76, ptr noundef %78)
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %79, align 1, !tbaa !11
  br label %80

80:                                               ; preds = %75, %70
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %82, i32 -1
  store ptr %83, ptr %7, align 8, !tbaa !5
  br label %66, !llvm.loop !12

84:                                               ; preds = %66
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  call void @__GLeeExtList_add(ptr noundef %85, ptr noundef %86)
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %87) #6
  store i8 1, ptr %2, align 1
  store i32 1, ptr %10, align 4
  br label %88

88:                                               ; preds = %84, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %89 = load i8, ptr %2, align 1
  ret i8 %89
}

declare ptr @glGetString(i32 noundef) #5

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

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

!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}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@.str.28 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @__GLeeExtList_add(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @__GLeeGetExtStrPlat() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @__GLeeGetExtensions(ptr noundef %0) local_unnamed_addr #1 {
  %2 = tail call ptr @__GLeeGetExtStrPlat()
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.thread, label %3

3:                                                ; preds = %1
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #6
  %5 = trunc i64 %4 to i32
  %6 = tail call ptr @glGetString(i32 noundef 7939) #7
  %7 = icmp eq ptr %6, null
  br i1 %7, label %10, label %11

.thread:                                          ; preds = %1
  %8 = tail call ptr @glGetString(i32 noundef 7939) #7
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %.thread42

10:                                               ; preds = %.thread, %3
  tail call void @__GLeeWriteError(ptr noundef nonnull @.str.29)
  br label %36

11:                                               ; preds = %3
  %.not34 = icmp eq i32 %5, 0
  br i1 %.not34, label %.thread42, label %12

12:                                               ; preds = %11
  %13 = shl i64 %4, 32
  %sext = add i64 %13, -4294967296
  %14 = ashr exact i64 %sext, 32
  %15 = getelementptr inbounds i8, ptr %2, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not35 = icmp ne i8 %16, 32
  %17 = zext i1 %.not35 to i32
  %spec.select = add nsw i32 %17, %5
  %spec.select37 = select i1 %.not35, ptr @.str.30, ptr @.str.31
  br label %.thread42

.thread42:                                        ; preds = %.thread, %12, %11
  %.0304046 = phi ptr [ %2, %11 ], [ %2, %12 ], [ @.str.28, %.thread ]
  %18 = phi ptr [ %6, %11 ], [ %6, %12 ], [ %8, %.thread ]
  %.1 = phi i32 [ 0, %11 ], [ %spec.select, %12 ], [ 0, %.thread ]
  %.not36 = phi ptr [ @.str.31, %11 ], [ %spec.select37, %12 ], [ @.str.31, %.thread ]
  %19 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %18) #6
  %20 = trunc i64 %19 to i32
  %21 = add i32 %.1, %20
  %22 = add nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = tail call noalias ptr @malloc(i64 noundef %23) #8
  %25 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %24, i64 noundef %23, ptr noundef nonnull %.not36, ptr noundef nonnull %.0304046, ptr noundef nonnull %18) #7
  %26 = icmp sgt i32 %21, 0
  br i1 %26, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.thread42
  %27 = zext nneg i32 %21 to i64
  %28 = getelementptr inbounds i8, ptr %24, i64 %27
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %33
  %.02847 = phi ptr [ %34, %33 ], [ %28, %.lr.ph.preheader ]
  %29 = load i8, ptr %.02847, align 1, !tbaa !5
  %30 = icmp eq i8 %29, 32
  br i1 %30, label %31, label %33

31:                                               ; preds = %.lr.ph
  %32 = getelementptr inbounds i8, ptr %.02847, i64 1
  tail call void @__GLeeExtList_add(ptr noundef %0, ptr noundef nonnull %32)
  store i8 0, ptr %.02847, align 1, !tbaa !5
  br label %33

33:                                               ; preds = %.lr.ph, %31
  %34 = getelementptr inbounds i8, ptr %.02847, i64 -1
  %35 = icmp ugt ptr %34, %24
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %33, %.thread42
  tail call void @__GLeeExtList_add(ptr noundef %0, ptr noundef %24)
  tail call void @free(ptr noundef %24) #7
  br label %36

36:                                               ; preds = %._crit_edge, %10
  %.029 = phi i8 [ 0, %10 ], [ 1, %._crit_edge ]
  ret i8 %.029
}

declare ptr @glGetString(i32 noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 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 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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