; LLVM IR from TheNachoBIT/GeoFenix-Engine :: Libraries/SOIL2/include (SOIL2)

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

@soilGlGetStringiFunc = external hidden global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [13 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 uwtable
declare dso_local ptr @SOIL_GL_GetProcAddress(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @SOIL_GL_ExtensionSupported(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %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
  %11 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call ptr @strchr(ptr noundef %12, i32 noundef 32) #5
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %21, label %16

16:                                               ; preds = %1
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %16, %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %100

22:                                               ; preds = %16
  %23 = call i32 @isAtLeastGL3()
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %57

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %26 = load ptr, ptr @soilGlGetStringiFunc, align 8, !tbaa !5
  %27 = icmp eq ptr null, %26
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = call ptr @SOIL_GL_GetProcAddress(ptr noundef @.str.12)
  store ptr %29, ptr @soilGlGetStringiFunc, align 8, !tbaa !5
  %30 = load ptr, ptr @soilGlGetStringiFunc, align 8, !tbaa !5
  %31 = icmp eq ptr null, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %56

33:                                               ; preds = %28
  br label %34

34:                                               ; preds = %33, %25
  call void @glGetIntegerv(i32 noundef 33309, ptr noundef %9)
  store i32 0, ptr %10, align 4, !tbaa !10
  br label %35

35:                                               ; preds = %52, %34
  %36 = load i32, ptr %10, align 4, !tbaa !10
  %37 = load i32, ptr %9, align 4, !tbaa !10
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %55

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %40 = load ptr, ptr @soilGlGetStringiFunc, align 8, !tbaa !5
  %41 = load i32, ptr %10, align 4, !tbaa !10
  %42 = call ptr %40(i32 noundef 7939, i32 noundef %41)
  store ptr %42, ptr %11, align 8, !tbaa !5
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = call i32 @strcmp(ptr noundef %43, ptr noundef %44) #5
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %39
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %49

48:                                               ; preds = %39
  store i32 0, ptr %8, align 4
  br label %49

49:                                               ; preds = %48, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %50 = load i32, ptr %8, align 4
  switch i32 %50, label %56 [
    i32 0, label %51
  ]

51:                                               ; preds = %49
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %10, align 4, !tbaa !10
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %10, align 4, !tbaa !10
  br label %35, !llvm.loop !12

55:                                               ; preds = %35
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %56

56:                                               ; preds = %55, %49, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %100

57:                                               ; preds = %22
  %58 = call ptr @glGetString(i32 noundef 7939)
  store ptr %58, ptr %4, align 8, !tbaa !5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %100

62:                                               ; preds = %57
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %63, ptr %5, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %97, %62
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = call ptr @strstr(ptr noundef %65, ptr noundef %66) #5
  store ptr %67, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %71, label %70

70:                                               ; preds = %64
  br label %99

71:                                               ; preds = %64
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = call i64 @strlen(ptr noundef %73) #5
  %75 = getelementptr inbounds i8, ptr %72, i64 %74
  store ptr %75, ptr %7, align 8, !tbaa !5
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = icmp eq ptr %76, %77
  br i1 %78, label %85, label %79

79:                                               ; preds = %71
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 -1
  %82 = load i8, ptr %81, align 1, !tbaa !9
  %83 = sext i8 %82 to i32
  %84 = icmp eq i32 %83, 32
  br i1 %84, label %85, label %97

85:                                               ; preds = %79, %71
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = load i8, ptr %86, align 1, !tbaa !9
  %88 = sext i8 %87 to i32
  %89 = icmp eq i32 %88, 32
  br i1 %89, label %95, label %90

90:                                               ; preds = %85
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = load i8, ptr %91, align 1, !tbaa !9
  %93 = sext i8 %92 to i32
  %94 = icmp eq i32 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %90, %85
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %100

96:                                               ; preds = %90
  br label %97

97:                                               ; preds = %96, %79
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %98, ptr %5, align 8, !tbaa !5
  br label %64

99:                                               ; preds = %70
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %100

100:                                              ; preds = %99, %95, %61, %56, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %101 = load i32, ptr %2, align 4
  ret i32 %101
}

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #2

declare void @glGetIntegerv(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

declare ptr @glGetString(i32 noundef) #3

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @isAtLeastGL3() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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 }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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"

@soilGlGetStringiFunc = external hidden local_unnamed_addr global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [13 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @SOIL_GL_ExtensionSupported(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %0, i32 noundef 32) #4
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %.loopexit

4:                                                ; preds = %1
  %5 = load i8, ptr %0, align 1, !tbaa !5
  %6 = icmp eq i8 %5, 0
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %4
  %8 = tail call i32 @isAtLeastGL3()
  %.not28 = icmp eq i32 %8, 0
  br i1 %.not28, label %25, label %9

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4, !tbaa !8
  %10 = load ptr, ptr @soilGlGetStringiFunc, align 8, !tbaa !10
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %15

12:                                               ; preds = %9
  %13 = tail call ptr @SOIL_GL_GetProcAddress(ptr noundef nonnull @.str.12)
  store ptr %13, ptr @soilGlGetStringiFunc, align 8, !tbaa !10
  %14 = icmp eq ptr %13, null
  br i1 %14, label %.loopexit32, label %15

15:                                               ; preds = %12, %9
  call void @glGetIntegerv(i32 noundef 33309, ptr noundef nonnull %2) #5
  %16 = load i32, ptr %2, align 4, !tbaa !8
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %.loopexit32

18:                                               ; preds = %.lr.ph
  %19 = add nuw nsw i32 %.02233, 1
  %20 = load i32, ptr %2, align 4, !tbaa !8
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %.lr.ph, label %.loopexit32, !llvm.loop !12

.lr.ph:                                           ; preds = %15, %18
  %.02233 = phi i32 [ %19, %18 ], [ 0, %15 ]
  %22 = load ptr, ptr @soilGlGetStringiFunc, align 8, !tbaa !10
  %23 = call ptr %22(i32 noundef 7939, i32 noundef %.02233) #5
  %24 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %23, ptr noundef nonnull dereferenceable(1) %0) #4
  %.not31 = icmp eq i32 %24, 0
  br i1 %.not31, label %.loopexit32, label %18

.loopexit32:                                      ; preds = %.lr.ph, %18, %15, %12
  %.2 = phi i32 [ 0, %12 ], [ 0, %15 ], [ 1, %.lr.ph ], [ 0, %18 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %.loopexit

25:                                               ; preds = %7
  %26 = tail call ptr @glGetString(i32 noundef 7939) #5
  %.not29 = icmp eq ptr %26, null
  br i1 %.not29, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %25
  %27 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %26, ptr noundef nonnull dereferenceable(1) %0) #4
  %.not3036 = icmp eq ptr %27, null
  br i1 %.not3036, label %.loopexit, label %.lr.ph38

.lr.ph38:                                         ; preds = %.preheader
  %28 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #4
  br label %29

29:                                               ; preds = %.lr.ph38, %39
  %30 = phi ptr [ %27, %.lr.ph38 ], [ %40, %39 ]
  %.02437 = phi ptr [ %26, %.lr.ph38 ], [ %31, %39 ]
  %31 = getelementptr inbounds i8, ptr %30, i64 %28
  %32 = icmp eq ptr %30, %.02437
  br i1 %32, label %37, label %33

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %30, i64 -1
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = icmp eq i8 %35, 32
  br i1 %36, label %37, label %39

37:                                               ; preds = %33, %29
  %38 = load i8, ptr %31, align 1, !tbaa !5
  switch i8 %38, label %39 [
    i8 32, label %.loopexit
    i8 0, label %.loopexit
  ]

39:                                               ; preds = %37, %33
  %40 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %31, ptr noundef nonnull dereferenceable(1) %0) #4
  %.not30 = icmp eq ptr %40, null
  br i1 %.not30, label %.loopexit, label %29

.loopexit:                                        ; preds = %37, %37, %39, %.preheader, %25, %1, %4, %.loopexit32
  %.3 = phi i32 [ %.2, %.loopexit32 ], [ 0, %4 ], [ 0, %1 ], [ 0, %25 ], [ 0, %.preheader ], [ 1, %37 ], [ 1, %37 ], [ 0, %39 ]
  ret i32 %.3
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

declare ptr @glGetString(i32 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @isAtLeastGL3() local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 willreturn memory(read) }
attributes #5 = { 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 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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