; LLVM IR from Dovyski/opengl-demos :: src/texture-simple-woodbox/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
@texture_bmp2 = external dso_local global ptr, align 8
@texture_data2 = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1

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

; 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 %18

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 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 88) #4
  invoke void @_ZN3BmpC1EPKc(ptr noundef nonnull align 8 dereferenceable(88) %8, ptr noundef @.str.1)
          to label %9 unwind label %22

9:                                                ; preds = %4
  store ptr %8, ptr @texture_bmp2, align 8, !tbaa !5
  %10 = load ptr, ptr @texture_bmp2, align 8, !tbaa !5
  %11 = call noundef ptr @_ZN3Bmp8getImageEv(ptr noundef nonnull align 8 dereferenceable(88) %10)
  store ptr %11, ptr @texture_data2, align 8, !tbaa !5
  %12 = load ptr, ptr @texture_data, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %26

14:                                               ; preds = %9
  %15 = load ptr, ptr @texture_data2, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %26

17:                                               ; preds = %14
  call void @glEnable(i32 noundef 5890)
  call void @glEnable(i32 noundef 3553)
  call void @_Z13buildTexturesv()
  br label %26

18:                                               ; preds = %0
  %19 = landingpad { ptr, i32 }
          cleanup
  %20 = extractvalue { ptr, i32 } %19, 0
  store ptr %20, ptr %1, align 8
  %21 = extractvalue { ptr, i32 } %19, 1
  store i32 %21, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %3, i64 noundef 88) #5
  br label %27

22:                                               ; preds = %4
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %1, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %8, i64 noundef 88) #5
  br label %27

26:                                               ; preds = %17, %14, %9
  ret void

27:                                               ; preds = %22, %18
  %28 = load ptr, ptr %1, align 8
  %29 = load i32, ptr %2, align 4
  %30 = insertvalue { ptr, i32 } poison, ptr %28, 0
  %31 = insertvalue { ptr, i32 } %30, i32 %29, 1
  resume { ptr, i32 } %31
}

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 @glEnable(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
@texture_bmp2 = external dso_local local_unnamed_addr global ptr, align 8
@texture_data2 = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1

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

; 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 %12

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
  %5 = tail call noalias noundef nonnull dereferenceable(88) ptr @_Znwm(i64 noundef 88) #4
  invoke void @_ZN3BmpC1EPKc(ptr noundef nonnull align 8 dereferenceable(88) %5, ptr noundef nonnull @.str.1)
          to label %6 unwind label %14

6:                                                ; preds = %2
  store ptr %5, ptr @texture_bmp2, align 8, !tbaa !5
  %7 = tail call noundef ptr @_ZN3Bmp8getImageEv(ptr noundef nonnull align 8 dereferenceable(88) %5)
  store ptr %7, ptr @texture_data2, align 8, !tbaa !5
  %8 = load ptr, ptr @texture_data, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  %10 = icmp ne ptr %7, null
  %or.cond = and i1 %10, %9
  br i1 %or.cond, label %11, label %16

11:                                               ; preds = %6
  tail call void @glEnable(i32 noundef 5890)
  tail call void @glEnable(i32 noundef 3553)
  tail call void @_Z13buildTexturesv()
  br label %16

12:                                               ; preds = %0
  %13 = landingpad { ptr, i32 }
          cleanup
  br label %17

14:                                               ; preds = %2
  %15 = landingpad { ptr, i32 }
          cleanup
  br label %17

16:                                               ; preds = %11, %6
  ret void

17:                                               ; preds = %14, %12
  %.sink = phi ptr [ %5, %14 ], [ %1, %12 ]
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %13, %12 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %.sink, i64 noundef 88) #5
  resume { ptr, i32 } %.pn
}

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 @glEnable(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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass