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

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

@img1 = external dso_local global ptr, align 8
@data = external dso_local global ptr, align 8
@textureID = external dso_local global [3 x i32], align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13buildTexturesv() #0 {
  %1 = alloca float, align 4
  %2 = alloca [4 x float], align 16
  %3 = alloca [4 x float], align 16
  call void @glGenTextures(i32 noundef 1, ptr noundef @textureID)
  %4 = load i32, ptr @textureID, align 4, !tbaa !5
  call void @glBindTexture(i32 noundef 3553, i32 noundef %4)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10242, i32 noundef 10497)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10243, i32 noundef 10497)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10241, i32 noundef 9985)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10240, i32 noundef 9729)
  %5 = load ptr, ptr @img1, align 8, !tbaa !9
  %6 = call noundef i32 @_ZN3Bmp8getWidthEv(ptr noundef nonnull align 8 dereferenceable(88) %5)
  %7 = load ptr, ptr @img1, align 8, !tbaa !9
  %8 = call noundef i32 @_ZN3Bmp9getHeightEv(ptr noundef nonnull align 8 dereferenceable(88) %7)
  %9 = load ptr, ptr @data, align 8, !tbaa !9
  %10 = call i32 @gluBuild2DMipmaps(i32 noundef 3553, i32 noundef 6407, i32 noundef %6, i32 noundef %8, i32 noundef 6407, i32 noundef 5121, ptr noundef %9)
  call void @glGenTextures(i32 noundef 1, ptr noundef getelementptr inbounds ([3 x i32], ptr @textureID, i64 0, i64 1))
  %11 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @textureID, i64 0, i64 1), align 4, !tbaa !5
  call void @glBindTexture(i32 noundef 3553, i32 noundef %11)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10242, i32 noundef 10496)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10243, i32 noundef 10496)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10240, i32 noundef 9728)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10241, i32 noundef 9728)
  %12 = load ptr, ptr @img1, align 8, !tbaa !9
  %13 = call noundef i32 @_ZN3Bmp8getWidthEv(ptr noundef nonnull align 8 dereferenceable(88) %12)
  %14 = load ptr, ptr @img1, align 8, !tbaa !9
  %15 = call noundef i32 @_ZN3Bmp9getHeightEv(ptr noundef nonnull align 8 dereferenceable(88) %14)
  %16 = load ptr, ptr @data, align 8, !tbaa !9
  call void @glTexImage2D(i32 noundef 3553, i32 noundef 0, i32 noundef 6407, i32 noundef %13, i32 noundef %15, i32 noundef 0, i32 noundef 6407, i32 noundef 5121, ptr noundef %16)
  call void @glGenTextures(i32 noundef 1, ptr noundef getelementptr inbounds ([3 x i32], ptr @textureID, i64 0, i64 2))
  %17 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @textureID, i64 0, i64 2), align 4, !tbaa !5
  call void @glBindTexture(i32 noundef 3553, i32 noundef %17)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store float 0x3FB99999A0000000, ptr %1, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #3
  %18 = load float, ptr %1, align 4, !tbaa !11
  store float %18, ptr %2, align 4, !tbaa !11
  %19 = getelementptr inbounds float, ptr %2, i64 1
  store float 0.000000e+00, ptr %19, align 4, !tbaa !11
  %20 = getelementptr inbounds float, ptr %2, i64 2
  store float 0.000000e+00, ptr %20, align 4, !tbaa !11
  %21 = getelementptr inbounds float, ptr %2, i64 3
  store float 0.000000e+00, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #3
  store float 0.000000e+00, ptr %3, align 4, !tbaa !11
  %22 = getelementptr inbounds float, ptr %3, i64 1
  %23 = load float, ptr %1, align 4, !tbaa !11
  store float %23, ptr %22, align 4, !tbaa !11
  %24 = getelementptr inbounds float, ptr %3, i64 2
  store float 0.000000e+00, ptr %24, align 4, !tbaa !11
  %25 = getelementptr inbounds float, ptr %3, i64 3
  store float 0.000000e+00, ptr %25, align 4, !tbaa !11
  %26 = getelementptr inbounds [4 x float], ptr %2, i64 0, i64 0
  call void @glTexGenfv(i32 noundef 8192, i32 noundef 9473, ptr noundef %26)
  %27 = getelementptr inbounds [4 x float], ptr %3, i64 0, i64 0
  call void @glTexGenfv(i32 noundef 8193, i32 noundef 9473, ptr noundef %27)
  call void @glTexGeni(i32 noundef 8192, i32 noundef 9472, i32 noundef 9217)
  call void @glTexGeni(i32 noundef 8193, i32 noundef 9472, i32 noundef 9217)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10242, i32 noundef 10497)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10243, i32 noundef 10497)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10241, i32 noundef 9985)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10240, i32 noundef 9729)
  %28 = load ptr, ptr @img1, align 8, !tbaa !9
  %29 = call noundef i32 @_ZN3Bmp8getWidthEv(ptr noundef nonnull align 8 dereferenceable(88) %28)
  %30 = load ptr, ptr @img1, align 8, !tbaa !9
  %31 = call noundef i32 @_ZN3Bmp9getHeightEv(ptr noundef nonnull align 8 dereferenceable(88) %30)
  %32 = load ptr, ptr @data, align 8, !tbaa !9
  %33 = call i32 @gluBuild2DMipmaps(i32 noundef 3553, i32 noundef 6407, i32 noundef %29, i32 noundef %31, i32 noundef 6407, i32 noundef 5121, ptr noundef %32)
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

declare void @glGenTextures(i32 noundef, ptr noundef) #1

declare void @glBindTexture(i32 noundef, i32 noundef) #1

declare void @glTexParameteri(i32 noundef, i32 noundef, i32 noundef) #1

declare i32 @gluBuild2DMipmaps(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #1

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

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

declare void @glTexImage2D(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #1

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

declare void @glTexGenfv(i32 noundef, i32 noundef, ptr noundef) #1

declare void @glTexGeni(i32 noundef, i32 noundef, i32 noundef) #1

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

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


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

@img1 = external dso_local local_unnamed_addr global ptr, align 8
@data = external dso_local local_unnamed_addr global ptr, align 8
@textureID = external dso_local global [3 x i32], align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13buildTexturesv() local_unnamed_addr #0 {
  %1 = alloca [4 x float], align 16
  %2 = alloca [4 x float], align 16
  tail call void @glGenTextures(i32 noundef 1, ptr noundef nonnull @textureID)
  %3 = load i32, ptr @textureID, align 4, !tbaa !5
  tail call void @glBindTexture(i32 noundef 3553, i32 noundef %3)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10242, i32 noundef 10497)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10243, i32 noundef 10497)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10241, i32 noundef 9985)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10240, i32 noundef 9729)
  %4 = load ptr, ptr @img1, align 8, !tbaa !9
  %5 = tail call noundef i32 @_ZN3Bmp8getWidthEv(ptr noundef nonnull align 8 dereferenceable(88) %4)
  %6 = load ptr, ptr @img1, align 8, !tbaa !9
  %7 = tail call noundef i32 @_ZN3Bmp9getHeightEv(ptr noundef nonnull align 8 dereferenceable(88) %6)
  %8 = load ptr, ptr @data, align 8, !tbaa !9
  %9 = tail call i32 @gluBuild2DMipmaps(i32 noundef 3553, i32 noundef 6407, i32 noundef %5, i32 noundef %7, i32 noundef 6407, i32 noundef 5121, ptr noundef %8)
  tail call void @glGenTextures(i32 noundef 1, ptr noundef nonnull getelementptr inbounds (i8, ptr @textureID, i64 4))
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @textureID, i64 4), align 4, !tbaa !5
  tail call void @glBindTexture(i32 noundef 3553, i32 noundef %10)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10242, i32 noundef 10496)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10243, i32 noundef 10496)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10240, i32 noundef 9728)
  tail call void @glTexParameteri(i32 noundef 3553, i32 noundef 10241, i32 noundef 9728)
  %11 = load ptr, ptr @img1, align 8, !tbaa !9
  %12 = tail call noundef i32 @_ZN3Bmp8getWidthEv(ptr noundef nonnull align 8 dereferenceable(88) %11)
  %13 = load ptr, ptr @img1, align 8, !tbaa !9
  %14 = tail call noundef i32 @_ZN3Bmp9getHeightEv(ptr noundef nonnull align 8 dereferenceable(88) %13)
  %15 = load ptr, ptr @data, align 8, !tbaa !9
  tail call void @glTexImage2D(i32 noundef 3553, i32 noundef 0, i32 noundef 6407, i32 noundef %12, i32 noundef %14, i32 noundef 0, i32 noundef 6407, i32 noundef 5121, ptr noundef %15)
  tail call void @glGenTextures(i32 noundef 1, ptr noundef nonnull getelementptr inbounds (i8, ptr @textureID, i64 8))
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @textureID, i64 8), align 4, !tbaa !5
  tail call void @glBindTexture(i32 noundef 3553, i32 noundef %16)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store <4 x float> <float 0x3FB99999A0000000, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00>, ptr %1, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #3
  store <4 x float> <float 0.000000e+00, float 0x3FB99999A0000000, float 0.000000e+00, float 0.000000e+00>, ptr %2, align 16, !tbaa !11
  call void @glTexGenfv(i32 noundef 8192, i32 noundef 9473, ptr noundef nonnull %1)
  call void @glTexGenfv(i32 noundef 8193, i32 noundef 9473, ptr noundef nonnull %2)
  call void @glTexGeni(i32 noundef 8192, i32 noundef 9472, i32 noundef 9217)
  call void @glTexGeni(i32 noundef 8193, i32 noundef 9472, i32 noundef 9217)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10242, i32 noundef 10497)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10243, i32 noundef 10497)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10241, i32 noundef 9985)
  call void @glTexParameteri(i32 noundef 3553, i32 noundef 10240, i32 noundef 9729)
  %17 = load ptr, ptr @img1, align 8, !tbaa !9
  %18 = call noundef i32 @_ZN3Bmp8getWidthEv(ptr noundef nonnull align 8 dereferenceable(88) %17)
  %19 = load ptr, ptr @img1, align 8, !tbaa !9
  %20 = call noundef i32 @_ZN3Bmp9getHeightEv(ptr noundef nonnull align 8 dereferenceable(88) %19)
  %21 = load ptr, ptr @data, align 8, !tbaa !9
  %22 = call i32 @gluBuild2DMipmaps(i32 noundef 3553, i32 noundef 6407, i32 noundef %18, i32 noundef %20, i32 noundef 6407, i32 noundef 5121, ptr noundef %21)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  ret void
}

declare void @glGenTextures(i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @glBindTexture(i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @glTexParameteri(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @gluBuild2DMipmaps(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

declare void @glTexImage2D(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

declare void @glTexGenfv(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @glTexGeni(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"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}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass