; LLVM IR from hbatagelo/abcg :: abcg/abcgOpenGLShader.ll (ZN4abcg21checkOpenGLShaderLinkEjb)

; 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.std::experimental::fundamentals_v2::source_location" = type { ptr, ptr, i32, i32 }
%"class.fmt::v10::basic_format_string" = type { %"class.fmt::v10::basic_string_view" }
%"class.fmt::v10::basic_string_view" = type { ptr, i64 }
%"class.std::basic_string_view" = type { i64, ptr }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@_ZTIN4abcg12RuntimeErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@__glewGetProgramiv = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__glewDeleteProgram = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 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

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12experimental15fundamentals_v215source_location7currentEPKcS3_ii(ptr dead_on_unwind noalias writable sret(%"struct.std::experimental::fundamentals_v2::source_location") align 8, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1 align 2

declare void @_ZN4abcg12RuntimeErrorC1ESt17basic_string_viewIcSt11char_traitsIcEERKNSt12experimental15fundamentals_v215source_locationE(ptr noundef nonnull align 8 dereferenceable(40), i64, ptr, ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4abcg9ExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3 align 2

declare void @__cxa_throw(ptr, ptr, ptr)

declare void @__cxa_free_exception(ptr)

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3fmt3v105printIJEEEvNS0_19basic_format_stringIcJDpNS0_13type_identityIT_E4typeEEEEDpOS4_(ptr, i64) #4

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3fmt3v1019basic_format_stringIcJEEC2IA2_cTnNSt9enable_ifIXsr3std14is_convertibleIRKT_NS0_17basic_string_viewIcEEEE5valueEiE4typeELi0EEES8_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(2)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_119printProgramInfoLogEj(i32 noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4abcg21checkOpenGLShaderLinkEjb(i32 noundef %0, i1 noundef zeroext %1) #5 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca %"class.fmt::v10::basic_format_string", align 8
  %8 = alloca %"class.std::basic_string_view", align 8
  %9 = alloca %"struct.std::experimental::fundamentals_v2::source_location", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i1, align 1
  %13 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  %14 = zext i1 %1 to i8
  store i8 %14, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  %15 = load ptr, ptr @__glewGetProgramiv, align 8, !tbaa !11
  %16 = load i32, ptr %4, align 4, !tbaa !5
  call void %15(i32 noundef %16, i32 noundef 35714, ptr noundef %6)
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %46

19:                                               ; preds = %2
  %20 = load i8, ptr %5, align 1, !tbaa !9, !range !13, !noundef !14
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %43

22:                                               ; preds = %19
  call void @_ZN3fmt3v1019basic_format_stringIcJEEC2IA2_cTnNSt9enable_ifIXsr3std14is_convertibleIRKT_NS0_17basic_string_viewIcEEEE5valueEiE4typeELi0EEES8_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 1 dereferenceable(2) @.str.3)
  %23 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8
  %25 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 1
  %26 = load i64, ptr %25, align 8
  call void @_ZN3fmt3v105printIJEEEvNS0_19basic_format_stringIcJDpNS0_13type_identityIT_E4typeEEEEDpOS4_(ptr %24, i64 %26)
  %27 = load i32, ptr %4, align 4, !tbaa !5
  call void @_ZN12_GLOBAL__N_119printProgramInfoLogEj(i32 noundef %27)
  %28 = load ptr, ptr @__glewDeleteProgram, align 8, !tbaa !11
  %29 = load i32, ptr %4, align 4, !tbaa !5
  call void %28(i32 noundef %29)
  store i1 true, ptr %12, align 1
  %30 = call ptr @__cxa_allocate_exception(i64 40) #6
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef @.str.4) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #6
  call void @_ZNSt12experimental15fundamentals_v215source_location7currentEPKcS3_ii(ptr dead_on_unwind writable sret(%"struct.std::experimental::fundamentals_v2::source_location") align 8 %9, ptr noundef @.str.1, ptr noundef @.str.8, i32 noundef 369, i32 noundef 0) #6
  %31 = getelementptr inbounds { i64, ptr }, ptr %8, i32 0, i32 0
  %32 = load i64, ptr %31, align 8
  %33 = getelementptr inbounds { i64, ptr }, ptr %8, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8
  invoke void @_ZN4abcg12RuntimeErrorC1ESt17basic_string_viewIcSt11char_traitsIcEERKNSt12experimental15fundamentals_v215source_locationE(ptr noundef nonnull align 8 dereferenceable(40) %30, i64 %32, ptr %34, ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %35 unwind label %36

35:                                               ; preds = %22
  store i1 false, ptr %12, align 1
  invoke void @__cxa_throw(ptr %30, ptr @_ZTIN4abcg12RuntimeErrorE, ptr @_ZN4abcg9ExceptionD2Ev) #7
          to label %54 unwind label %36

36:                                               ; preds = %35, %22
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %10, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #6
  %40 = load i1, ptr %12, align 1
  br i1 %40, label %41, label %42

41:                                               ; preds = %36
  call void @__cxa_free_exception(ptr %30) #6
  br label %42

42:                                               ; preds = %41, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %49

43:                                               ; preds = %19
  %44 = load ptr, ptr @__glewDeleteProgram, align 8, !tbaa !11
  %45 = load i32, ptr %4, align 4, !tbaa !5
  call void %44(i32 noundef %45)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %13, align 4
  br label %47

46:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  store i32 1, ptr %13, align 4
  br label %47

47:                                               ; preds = %46, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %48 = load i1, ptr %3, align 1
  ret i1 %48

49:                                               ; preds = %42
  %50 = load ptr, ptr %10, align 8
  %51 = load i32, ptr %11, align 4
  %52 = insertvalue { ptr, i32 } poison, ptr %50, 0
  %53 = insertvalue { ptr, i32 } %52, i32 %51, 1
  resume { ptr, i32 } %53

54:                                               ; preds = %35
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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 = { inlinehint mustprogress 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 #4 = { alwaysinline 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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

%"struct.std::experimental::fundamentals_v2::source_location" = type { ptr, ptr, i32, i32 }
%"class.fmt::v10::basic_format_string" = type { %"class.fmt::v10::basic_string_view" }
%"class.fmt::v10::basic_string_view" = type { ptr, i64 }
%"class.std::basic_string_view" = type { i64, ptr }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@_ZTIN4abcg12RuntimeErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@__glewGetProgramiv = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__glewDeleteProgram = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 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

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12experimental15fundamentals_v215source_location7currentEPKcS3_ii(ptr dead_on_unwind noalias writable sret(%"struct.std::experimental::fundamentals_v2::source_location") align 8, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

declare void @_ZN4abcg12RuntimeErrorC1ESt17basic_string_viewIcSt11char_traitsIcEERKNSt12experimental15fundamentals_v215source_locationE(ptr noundef nonnull align 8 dereferenceable(40), i64, ptr, ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4abcg9ExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3 align 2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3fmt3v105printIJEEEvNS0_19basic_format_stringIcJDpNS0_13type_identityIT_E4typeEEEEDpOS4_(ptr, i64) local_unnamed_addr #4

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN3fmt3v1019basic_format_stringIcJEEC2IA2_cTnNSt9enable_ifIXsr3std14is_convertibleIRKT_NS0_17basic_string_viewIcEEEE5valueEiE4typeELi0EEES8_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(2)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_119printProgramInfoLogEj(i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4abcg21checkOpenGLShaderLinkEjb(i32 noundef %0, i1 noundef zeroext %1) local_unnamed_addr #5 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca %"class.fmt::v10::basic_format_string", align 8
  %5 = alloca %"class.std::basic_string_view", align 8
  %6 = alloca %"struct.std::experimental::fundamentals_v2::source_location", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  %7 = load ptr, ptr @__glewGetProgramiv, align 8, !tbaa !9
  call void %7(i32 noundef %0, i32 noundef 35714, ptr noundef nonnull %3)
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %25, label %10

10:                                               ; preds = %2
  br i1 %1, label %11, label %23

11:                                               ; preds = %10
  call void @_ZN3fmt3v1019basic_format_stringIcJEEC2IA2_cTnNSt9enable_ifIXsr3std14is_convertibleIRKT_NS0_17basic_string_viewIcEEEE5valueEiE4typeELi0EEES8_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 1 dereferenceable(2) @.str.3)
  %12 = load ptr, ptr %4, align 8
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = load i64, ptr %13, align 8
  call void @_ZN3fmt3v105printIJEEEvNS0_19basic_format_stringIcJDpNS0_13type_identityIT_E4typeEEEEDpOS4_(ptr %12, i64 %14)
  call void @_ZN12_GLOBAL__N_119printProgramInfoLogEj(i32 noundef %0)
  %15 = load ptr, ptr @__glewDeleteProgram, align 8, !tbaa !9
  call void %15(i32 noundef %0)
  %16 = call ptr @__cxa_allocate_exception(i64 40) #6
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef @.str.4) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #6
  call void @_ZNSt12experimental15fundamentals_v215source_location7currentEPKcS3_ii(ptr dead_on_unwind nonnull writable sret(%"struct.std::experimental::fundamentals_v2::source_location") align 8 %6, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.8, i32 noundef 369, i32 noundef 0) #6
  %17 = load i64, ptr %5, align 8
  %18 = getelementptr inbounds i8, ptr %5, i64 8
  %19 = load ptr, ptr %18, align 8
  invoke void @_ZN4abcg12RuntimeErrorC1ESt17basic_string_viewIcSt11char_traitsIcEERKNSt12experimental15fundamentals_v215source_locationE(ptr noundef nonnull align 8 dereferenceable(40) %16, i64 %17, ptr %19, ptr noundef nonnull align 8 dereferenceable(24) %6)
          to label %20 unwind label %21

20:                                               ; preds = %11
  call void @__cxa_throw(ptr nonnull %16, ptr nonnull @_ZTIN4abcg12RuntimeErrorE, ptr nonnull @_ZN4abcg9ExceptionD2Ev) #7
  unreachable

21:                                               ; preds = %11
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #6
  call void @__cxa_free_exception(ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  resume { ptr, i32 } %22

23:                                               ; preds = %10
  %24 = load ptr, ptr @__glewDeleteProgram, align 8, !tbaa !9
  call void %24(i32 noundef %0)
  br label %25

25:                                               ; preds = %2, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  ret i1 %9
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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 = { inlinehint mustprogress 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 #4 = { alwaysinline 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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