; LLVM IR from hbatagelo/abcg :: abcg/external/glslang/OGLCompilersDLL/InitializeDll.ll (ZN7glslang12DetachThreadEv)

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

@_ZN7glslang21ThreadInitializeIndexE = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__._ZN7glslang12DetachThreadEv = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

declare noundef ptr @_ZN7glslang14OS_GetTLSValueEPv(ptr noundef) #1

declare noundef zeroext i1 @_ZN7glslang14OS_SetTLSValueEPvS0_(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7glslang12DetachThreadEv() #2 {
  %1 = alloca i1, align 1
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #4
  store i8 1, ptr %2, align 1, !tbaa !5
  %4 = load ptr, ptr @_ZN7glslang21ThreadInitializeIndexE, align 8, !tbaa !9
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %0
  store i1 true, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %19

7:                                                ; preds = %0
  %8 = load ptr, ptr @_ZN7glslang21ThreadInitializeIndexE, align 8, !tbaa !9
  %9 = call noundef ptr @_ZN7glslang14OS_GetTLSValueEPv(ptr noundef %8)
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %16

11:                                               ; preds = %7
  %12 = load ptr, ptr @_ZN7glslang21ThreadInitializeIndexE, align 8, !tbaa !9
  %13 = call noundef zeroext i1 @_ZN7glslang14OS_SetTLSValueEPvS0_(ptr noundef %12, ptr noundef null)
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 135, ptr noundef @__PRETTY_FUNCTION__._ZN7glslang12DetachThreadEv) #5
  unreachable

15:                                               ; preds = %11
  br label %16

16:                                               ; preds = %15, %7
  %17 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %18 = trunc i8 %17 to i1
  store i1 %18, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %19

19:                                               ; preds = %16, %6
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #4
  %20 = load i1, ptr %1, align 1
  ret i1 %20
}

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

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

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


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

@_ZN7glslang21ThreadInitializeIndexE = external dso_local local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__._ZN7glslang12DetachThreadEv = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare noundef ptr @_ZN7glslang14OS_GetTLSValueEPv(ptr noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN7glslang14OS_SetTLSValueEPvS0_(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7glslang12DetachThreadEv() local_unnamed_addr #2 {
  %1 = load ptr, ptr @_ZN7glslang21ThreadInitializeIndexE, align 8, !tbaa !5
  %2 = icmp eq ptr %1, null
  br i1 %2, label %9, label %3

3:                                                ; preds = %0
  %4 = tail call noundef ptr @_ZN7glslang14OS_GetTLSValueEPv(ptr noundef nonnull %1)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %9, label %5

5:                                                ; preds = %3
  %6 = load ptr, ptr @_ZN7glslang21ThreadInitializeIndexE, align 8, !tbaa !5
  %7 = tail call noundef zeroext i1 @_ZN7glslang14OS_SetTLSValueEPvS0_(ptr noundef %6, ptr noundef null)
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 135, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7glslang12DetachThreadEv) #3
  unreachable

9:                                                ; preds = %3, %5, %0
  ret i1 true
}

attributes #0 = { 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 #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 = { 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 #3 = { 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"}


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