; LLVM IR from Dovyski/opengl-demos :: src/texture-simple/main.ll (Z4initv)

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

@texture_bmp = external dso_local global ptr, align 8
@texture_data = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13buildTexturesv() #0

declare void @glEnable(i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  call void @glClearColor(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  call void @glShadeModel(i32 noundef 7425)
  call void @glDepthFunc(i32 noundef 513)
  call void @glEnable(i32 noundef 2929)
  call void @glDisable(i32 noundef 2884)
  %3 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 88) #4
  invoke void @_ZN3BmpC1EPKc(ptr noundef nonnull align 8 dereferenceable(88) %3, ptr noundef @.str)
          to label %4 unwind label %11

4:                                                ; preds = %0
  store ptr %3, ptr @texture_bmp, align 8, !tbaa !5
  %5 = load ptr, ptr @texture_bmp, align 8, !tbaa !5
  call void @_ZN3Bmp15convertBGRtoRGBEv(ptr noundef nonnull align 8 dereferenceable(88) %5)
  %6 = load ptr, ptr @texture_bmp, align 8, !tbaa !5
  %7 = call noundef ptr @_ZN3Bmp8getImageEv(ptr noundef nonnull align 8 dereferenceable(88) %6)
  store ptr %7, ptr @texture_data, align 8, !tbaa !5
  %8 = load ptr, ptr @texture_data, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %15

10:                                               ; preds = %4
  call void @glEnable(i32 noundef 5890)
  call void @glEnable(i32 noundef 3553)
  call void @_Z13buildTexturesv()
  br label %15

11:                                               ; preds = %0
  %12 = landingpad { ptr, i32 }
          cleanup
  %13 = extractvalue { ptr, i32 } %12, 0
  store ptr %13, ptr %1, align 8
  %14 = extractvalue { ptr, i32 } %12, 1
  store i32 %14, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %3, i64 noundef 88) #5
  br label %16

15:                                               ; preds = %10, %4
  ret void

16:                                               ; preds = %11
  %17 = load ptr, ptr %1, align 8
  %18 = load i32, ptr %2, align 4
  %19 = insertvalue { ptr, i32 } poison, ptr %17, 0
  %20 = insertvalue { ptr, i32 } %19, i32 %18, 1
  resume { ptr, i32 } %20
}

declare void @glClearColor(float noundef, float noundef, float noundef, float noundef) #1

declare void @glShadeModel(i32 noundef) #1

declare void @glDepthFunc(i32 noundef) #1

declare void @glDisable(i32 noundef) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

declare void @_ZN3BmpC1EPKc(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

declare void @_ZN3Bmp15convertBGRtoRGBEv(ptr noundef nonnull align 8 dereferenceable(88)) #1

declare noundef ptr @_ZN3Bmp8getImageEv(ptr noundef nonnull align 8 dereferenceable(88)) #1

attributes #0 = { 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 #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 = { nobuiltin 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 #3 = { nobuiltin 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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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"}


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

@texture_bmp = external dso_local local_unnamed_addr global ptr, align 8
@texture_data = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z13buildTexturesv() local_unnamed_addr #0

declare void @glEnable(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  tail call void @glClearColor(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  tail call void @glShadeModel(i32 noundef 7425)
  tail call void @glDepthFunc(i32 noundef 513)
  tail call void @glEnable(i32 noundef 2929)
  tail call void @glDisable(i32 noundef 2884)
  %1 = tail call noalias noundef nonnull dereferenceable(88) ptr @_Znwm(i64 noundef 88) #4
  invoke void @_ZN3BmpC1EPKc(ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull @.str)
          to label %2 unwind label %6

2:                                                ; preds = %0
  store ptr %1, ptr @texture_bmp, align 8, !tbaa !5
  tail call void @_ZN3Bmp15convertBGRtoRGBEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %3 = load ptr, ptr @texture_bmp, align 8, !tbaa !5
  %4 = tail call noundef ptr @_ZN3Bmp8getImageEv(ptr noundef nonnull align 8 dereferenceable(88) %3)
  store ptr %4, ptr @texture_data, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %8, label %5

5:                                                ; preds = %2
  tail call void @glEnable(i32 noundef 5890)
  tail call void @glEnable(i32 noundef 3553)
  tail call void @_Z13buildTexturesv()
  br label %8

6:                                                ; preds = %0
  %7 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %1, i64 noundef 88) #5
  resume { ptr, i32 } %7

8:                                                ; preds = %5, %2
  ret void
}

declare void @glClearColor(float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @glShadeModel(i32 noundef) local_unnamed_addr #1

declare void @glDepthFunc(i32 noundef) local_unnamed_addr #1

declare void @glDisable(i32 noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

declare void @_ZN3BmpC1EPKc(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @_ZN3Bmp15convertBGRtoRGBEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #1

declare noundef ptr @_ZN3Bmp8getImageEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #1

attributes #0 = { 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 #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 = { nobuiltin 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 #3 = { nobuiltin 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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass