; LLVM IR from rcliftonharvey/dspfilters4juce :: DSPFilters4JUCEDemo/JuceLibraryCode/juce_opengl.ll (ZN4juce19OpenGLShaderProgram4linkEv)

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

%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::OpenGLShaderProgram" = type { ptr, i32, %"class.juce::String" }
%"class.juce::OpenGLContext" = type <{ %"struct.juce::OpenGLExtensionFunctions", ptr, ptr, double, %"class.juce::ScopedPointer.1", %"class.juce::OpenGLPixelFormat", [4 x i8], ptr, i32, [4 x i8], i64, i8, i8, i8, [5 x i8] }>
%"struct.juce::OpenGLExtensionFunctions" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.juce::ScopedPointer.1" = type { ptr }
%"class.juce::OpenGLPixelFormat" = type <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8] }>

declare i32 @__gxx_personality_v0(...)

; 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: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #1

; Function Attrs: nounwind
declare void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce19OpenGLShaderProgram12getProgramIDEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

declare void @_ZN4juce6StringC1EPKcm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) unnamed_addr #4

; Function Attrs: nounwind
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce6StringaSEOS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4juce19OpenGLShaderProgram4linkEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [16384 x i8], align 16
  %6 = alloca i32, align 4
  %7 = alloca %"class.juce::String", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  br label %9

9:                                                ; preds = %1
  br label %10

10:                                               ; preds = %9
  br label %11

11:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %12 = call noundef i32 @_ZNK4juce19OpenGLShaderProgram12getProgramIDEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #5
  store i32 %12, ptr %3, align 4, !tbaa !9
  %13 = getelementptr inbounds %"class.juce::OpenGLShaderProgram", ptr %8, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds %"class.juce::OpenGLContext", ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %"struct.juce::OpenGLExtensionFunctions", ptr %15, i32 0, i32 13
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = load i32, ptr %3, align 4, !tbaa !9
  invoke void %17(i32 noundef %18)
          to label %19 unwind label %47

19:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  %20 = getelementptr inbounds %"class.juce::OpenGLShaderProgram", ptr %8, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %"class.juce::OpenGLContext", ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %"struct.juce::OpenGLExtensionFunctions", ptr %22, i32 0, i32 18
  %24 = load ptr, ptr %23, align 8, !tbaa !24
  %25 = load i32, ptr %3, align 4, !tbaa !9
  invoke void %24(i32 noundef %25, i32 noundef 35714, ptr noundef %4)
          to label %26 unwind label %47

26:                                               ; preds = %19
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %44

29:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 16384, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  %30 = getelementptr inbounds %"class.juce::OpenGLShaderProgram", ptr %8, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %"class.juce::OpenGLContext", ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %"struct.juce::OpenGLExtensionFunctions", ptr %32, i32 0, i32 17
  %34 = load ptr, ptr %33, align 8, !tbaa !25
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = getelementptr inbounds [16384 x i8], ptr %5, i64 0, i64 0
  invoke void %34(i32 noundef %35, i32 noundef 16384, ptr noundef %6, ptr noundef %36)
          to label %37 unwind label %47

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %38 = getelementptr inbounds [16384 x i8], ptr %5, i64 0, i64 0
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  invoke void @_ZN4juce6StringC1EPKcm(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef %38, i64 noundef %40)
          to label %41 unwind label %47

41:                                               ; preds = %37
  %42 = getelementptr inbounds %"class.juce::OpenGLShaderProgram", ptr %8, i32 0, i32 2
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce6StringaSEOS0_(ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 16384, ptr %5) #5
  br label %44

44:                                               ; preds = %41, %26
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret i1 %46

47:                                               ; preds = %37, %29, %19, %11
  %48 = landingpad { ptr, i32 }
          catch ptr null
  %49 = extractvalue { ptr, i32 } %48, 0
  call void @__clang_call_terminate(ptr %49) #6
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noinline noreturn nounwind uwtable "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 "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 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 = { "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 = { nounwind }
attributes #6 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN4juce19OpenGLShaderProgramE", !6, i64 0, !10, i64 8, !13, i64 16}
!13 = !{!"_ZTSN4juce6StringE", !14, i64 0}
!14 = !{!"_ZTSN4juce16CharPointer_UTF8E", !6, i64 0}
!15 = !{!16, !6, i64 104}
!16 = !{!"_ZTSN4juce13OpenGLContextE", !17, i64 0, !6, i64 384, !6, i64 392, !18, i64 400, !19, i64 408, !20, i64 416, !6, i64 464, !21, i64 472, !22, i64 480, !23, i64 488, !23, i64 489, !23, i64 490}
!17 = !{!"_ZTSN4juce24OpenGLExtensionFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !6, i64 376}
!18 = !{!"double", !7, i64 0}
!19 = !{!"_ZTSN4juce13ScopedPointerINS_13OpenGLContext10AttachmentEEE", !6, i64 0}
!20 = !{!"_ZTSN4juce17OpenGLPixelFormatE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40}
!21 = !{!"_ZTSN4juce13OpenGLContext13OpenGLVersionE", !7, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!16, !6, i64 144}
!25 = !{!16, !6, i64 136}


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

%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; 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: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce19OpenGLShaderProgram12getProgramIDEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

declare void @_ZN4juce6StringC1EPKcm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) unnamed_addr #4

; Function Attrs: nounwind
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce6StringaSEOS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4juce19OpenGLShaderProgram4linkEv(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca [16384 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca %"class.juce::String", align 8
  %6 = tail call noundef i32 @_ZNK4juce19OpenGLShaderProgram12getProgramIDEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 104
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  invoke void %9(i32 noundef %6)
          to label %10 unwind label %30

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4, !tbaa !22
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 144
  %13 = load ptr, ptr %12, align 8, !tbaa !23
  invoke void %13(i32 noundef %6, i32 noundef 35714, ptr noundef nonnull %2)
          to label %14 unwind label %30

14:                                               ; preds = %10
  %15 = load i32, ptr %2, align 4, !tbaa !22
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %28

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 16384, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 0, ptr %4, align 4, !tbaa !22
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 136
  %20 = load ptr, ptr %19, align 8, !tbaa !24
  invoke void %20(i32 noundef %6, i32 noundef 16384, ptr noundef nonnull %4, ptr noundef nonnull %3)
          to label %21 unwind label %30

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %22 = load i32, ptr %4, align 4, !tbaa !22
  %23 = sext i32 %22 to i64
  invoke void @_ZN4juce6StringC1EPKcm(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull %3, i64 noundef %23)
          to label %24 unwind label %30

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4juce6StringaSEOS0_(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 16384, ptr nonnull %3) #5
  %.pre = load i32, ptr %2, align 4, !tbaa !22
  %27 = icmp ne i32 %.pre, 0
  br label %28

28:                                               ; preds = %24, %14
  %29 = phi i1 [ %27, %24 ], [ true, %14 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  ret i1 %29

30:                                               ; preds = %21, %17, %10, %1
  %31 = landingpad { ptr, i32 }
          catch ptr null
  %32 = extractvalue { ptr, i32 } %31, 0
  call void @__clang_call_terminate(ptr %32) #6
  unreachable
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noinline noreturn nounwind uwtable "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 "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 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 = { "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 = { nounwind }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"_ZTSN4juce19OpenGLShaderProgramE", !7, i64 0, !10, i64 8, !11, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSN4juce6StringE", !12, i64 0}
!12 = !{!"_ZTSN4juce16CharPointer_UTF8E", !7, i64 0}
!13 = !{!14, !7, i64 104}
!14 = !{!"_ZTSN4juce13OpenGLContextE", !15, i64 0, !7, i64 384, !7, i64 392, !16, i64 400, !17, i64 408, !18, i64 416, !7, i64 464, !19, i64 472, !20, i64 480, !21, i64 488, !21, i64 489, !21, i64 490}
!15 = !{!"_ZTSN4juce24OpenGLExtensionFunctionsE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376}
!16 = !{!"double", !8, i64 0}
!17 = !{!"_ZTSN4juce13ScopedPointerINS_13OpenGLContext10AttachmentEEE", !7, i64 0}
!18 = !{!"_ZTSN4juce17OpenGLPixelFormatE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !8, i64 40}
!19 = !{!"_ZTSN4juce13OpenGLContext13OpenGLVersionE", !8, i64 0}
!20 = !{!"long", !8, i64 0}
!21 = !{!"bool", !8, i64 0}
!22 = !{!10, !10, i64 0}
!23 = !{!14, !7, i64 144}
!24 = !{!14, !7, i64 136}


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