; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl (tiny_opengl_fontstashcallbacks)

; 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.sth_texture = type { %union.anon, ptr, [128 x %struct.sth_row], i32, i32, [2048 x %struct.Vertex], ptr }
%union.anon = type { ptr }
%struct.sth_row = type { i16, i16, i16 }
%struct.Vertex = type { %struct.vec4, %struct.vec4, %struct.vec2 }
%struct.vec4 = type { [4 x float] }
%struct.vec2 = type { [2 x float] }

@glad_glGetError = external global ptr, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [133 x i8], align 1
@glad_glUseProgram = external global ptr, align 8
@glad_glBindBuffer = external global ptr, align 8
@_ZL14s_vertexBuffer = external hidden global i32, align 4
@glad_glBindVertexArray = external global ptr, align 8
@_ZL19s_vertexArrayObject = external hidden global i32, align 4
@glad_glBindTexture = external global ptr, align 8
@glad_glTexParameteri = external global ptr, align 8
@glad_glBufferData = external global ptr, align 8
@_ZL13s_indexBuffer = external hidden global i32, align 4
@__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture = external hidden unnamed_addr constant [67 x i8], align 1
@glad_glActiveTexture = external global ptr, align 8
@glad_glDrawElements = external global ptr, align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN30InternalOpenGL2RenderCallbacks8display2Ev(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr 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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @_ZN30InternalOpenGL2RenderCallbacks8display2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sth_texture, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr @glad_glGetError, align 8, !tbaa !5
  %13 = call i32 %12()
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  br label %18

16:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 179, ptr noundef @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #4
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load ptr, ptr @glad_glActiveTexture, align 8, !tbaa !5
  call void %19(i32 noundef 33984)
  %20 = load ptr, ptr @glad_glGetError, align 8, !tbaa !5
  %21 = call i32 %20()
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  br label %26

24:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 182, ptr noundef @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #4
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  %27 = load ptr, ptr @glad_glBindTexture, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load i32, ptr %28, align 4, !tbaa !10
  call void %27(i32 noundef 3553, i32 noundef %29)
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  store i8 0, ptr %6, align 1, !tbaa !12
  %30 = load i8, ptr %6, align 1, !tbaa !12, !range !14, !noundef !15
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %35

32:                                               ; preds = %26
  %33 = load ptr, ptr @glad_glTexParameteri, align 8, !tbaa !5
  call void %33(i32 noundef 3553, i32 noundef 10241, i32 noundef 9987)
  %34 = load ptr, ptr @glad_glTexParameteri, align 8, !tbaa !5
  call void %34(i32 noundef 3553, i32 noundef 10240, i32 noundef 9729)
  br label %38

35:                                               ; preds = %26
  %36 = load ptr, ptr @glad_glTexParameteri, align 8, !tbaa !5
  call void %36(i32 noundef 3553, i32 noundef 10241, i32 noundef 9728)
  %37 = load ptr, ptr @glad_glTexParameteri, align 8, !tbaa !5
  call void %37(i32 noundef 3553, i32 noundef 10240, i32 noundef 9728)
  br label %38

38:                                               ; preds = %35, %32
  %39 = load ptr, ptr @glad_glGetError, align 8, !tbaa !5
  %40 = call i32 %39()
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %38
  br label %45

43:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 194, ptr noundef @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #4
  unreachable

44:                                               ; No predecessors!
  br label %45

45:                                               ; preds = %44, %42
  %46 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %47 = load i32, ptr @_ZL14s_vertexBuffer, align 4, !tbaa !10
  call void %46(i32 noundef 34962, i32 noundef %47)
  %48 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  %49 = load i32, ptr @_ZL19s_vertexArrayObject, align 4, !tbaa !10
  call void %48(i32 noundef %49)
  %50 = load ptr, ptr @glad_glBufferData, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.sth_texture, ptr %51, i32 0, i32 4
  %53 = load i32, ptr %52, align 4, !tbaa !16
  %54 = sext i32 %53 to i64
  %55 = mul i64 %54, 40
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.sth_texture, ptr %56, i32 0, i32 5
  %58 = getelementptr inbounds [2048 x %struct.Vertex], ptr %57, i64 0, i64 0
  %59 = getelementptr inbounds %struct.Vertex, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds %struct.vec4, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds [4 x float], ptr %60, i64 0, i64 0
  call void %50(i32 noundef 34962, i64 noundef %55, ptr noundef %61, i32 noundef 35048)
  %62 = load ptr, ptr @glad_glGetError, align 8, !tbaa !5
  %63 = call i32 %62()
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %45
  br label %68

66:                                               ; preds = %45
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 200, ptr noundef @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #4
  unreachable

67:                                               ; No predecessors!
  br label %68

68:                                               ; preds = %67, %65
  %69 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  %70 = load i32, ptr @_ZL13s_indexBuffer, align 4, !tbaa !10
  call void %69(i32 noundef 34963, i32 noundef %70)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.sth_texture, ptr %71, i32 0, i32 4
  %73 = load i32, ptr %72, align 4, !tbaa !16
  store i32 %73, ptr %7, align 4, !tbaa !10
  %74 = load ptr, ptr @glad_glGetError, align 8, !tbaa !5
  %75 = call i32 %74()
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %68
  br label %80

78:                                               ; preds = %68
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 206, ptr noundef @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #4
  unreachable

79:                                               ; No predecessors!
  br label %80

80:                                               ; preds = %79, %77
  %81 = load ptr, ptr @glad_glDrawElements, align 8, !tbaa !5
  %82 = load i32, ptr %7, align 4, !tbaa !10
  call void %81(i32 noundef 4, i32 noundef %82, i32 noundef 5125, ptr noundef null)
  %83 = load ptr, ptr @glad_glGetError, align 8, !tbaa !5
  %84 = call i32 %83()
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %87

86:                                               ; preds = %80
  br label %89

87:                                               ; preds = %80
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 209, ptr noundef @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #4
  unreachable

88:                                               ; No predecessors!
  br label %89

89:                                               ; preds = %88, %86
  %90 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !5
  call void %90(i32 noundef 0)
  %91 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  call void %91(i32 noundef 34962, i32 noundef 0)
  %92 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !5
  call void %92(i32 noundef 34963, i32 noundef 0)
  %93 = load ptr, ptr @glad_glUseProgram, align 8, !tbaa !5
  call void %93(i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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 = { noreturn 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!17, !11, i64 788}
!17 = !{!"_ZTS11sth_texture", !7, i64 0, !6, i64 8, !7, i64 16, !11, i64 784, !11, i64 788, !7, i64 792, !6, i64 82712}


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

@glad_glGetError = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [133 x i8], align 1
@glad_glUseProgram = external local_unnamed_addr global ptr, align 8
@glad_glBindBuffer = external local_unnamed_addr global ptr, align 8
@_ZL14s_vertexBuffer = external hidden local_unnamed_addr global i32, align 4
@glad_glBindVertexArray = external local_unnamed_addr global ptr, align 8
@_ZL19s_vertexArrayObject = external hidden local_unnamed_addr global i32, align 4
@glad_glBindTexture = external local_unnamed_addr global ptr, align 8
@glad_glTexParameteri = external local_unnamed_addr global ptr, align 8
@glad_glBufferData = external local_unnamed_addr global ptr, align 8
@_ZL13s_indexBuffer = external hidden local_unnamed_addr global i32, align 4
@__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture = external hidden unnamed_addr constant [67 x i8], align 1
@glad_glActiveTexture = external local_unnamed_addr global ptr, align 8
@glad_glDrawElements = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN30InternalOpenGL2RenderCallbacks8display2Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  tail call void @_ZN30InternalOpenGL2RenderCallbacks8display2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = load ptr, ptr @glad_glGetError, align 8, !tbaa !8
  %5 = tail call i32 %4()
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %8, label %7

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 179, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #2
  unreachable

8:                                                ; preds = %2
  %9 = load ptr, ptr @glad_glActiveTexture, align 8, !tbaa !8
  tail call void %9(i32 noundef 33984)
  %10 = load ptr, ptr @glad_glGetError, align 8, !tbaa !8
  %11 = tail call i32 %10()
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 182, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #2
  unreachable

14:                                               ; preds = %8
  %15 = load ptr, ptr @glad_glBindTexture, align 8, !tbaa !8
  %16 = load i32, ptr %3, align 4, !tbaa !10
  tail call void %15(i32 noundef 3553, i32 noundef %16)
  %17 = load ptr, ptr @glad_glTexParameteri, align 8, !tbaa !8
  tail call void %17(i32 noundef 3553, i32 noundef 10241, i32 noundef 9728)
  %18 = load ptr, ptr @glad_glTexParameteri, align 8, !tbaa !8
  tail call void %18(i32 noundef 3553, i32 noundef 10240, i32 noundef 9728)
  %19 = load ptr, ptr @glad_glGetError, align 8, !tbaa !8
  %20 = tail call i32 %19()
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 194, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #2
  unreachable

23:                                               ; preds = %14
  %24 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !8
  %25 = load i32, ptr @_ZL14s_vertexBuffer, align 4, !tbaa !10
  tail call void %24(i32 noundef 34962, i32 noundef %25)
  %26 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !8
  %27 = load i32, ptr @_ZL19s_vertexArrayObject, align 4, !tbaa !10
  tail call void %26(i32 noundef %27)
  %28 = load ptr, ptr @glad_glBufferData, align 8, !tbaa !8
  %29 = getelementptr inbounds i8, ptr %1, i64 788
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = sext i32 %30 to i64
  %32 = mul nsw i64 %31, 40
  %33 = getelementptr inbounds i8, ptr %1, i64 792
  tail call void %28(i32 noundef 34962, i64 noundef %32, ptr noundef nonnull %33, i32 noundef 35048)
  %34 = load ptr, ptr @glad_glGetError, align 8, !tbaa !8
  %35 = tail call i32 %34()
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %23
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 200, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #2
  unreachable

38:                                               ; preds = %23
  %39 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !8
  %40 = load i32, ptr @_ZL13s_indexBuffer, align 4, !tbaa !10
  tail call void %39(i32 noundef 34963, i32 noundef %40)
  %41 = load i32, ptr %29, align 4, !tbaa !12
  %42 = load ptr, ptr @glad_glGetError, align 8, !tbaa !8
  %43 = tail call i32 %42()
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %38
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 206, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #2
  unreachable

46:                                               ; preds = %38
  %47 = load ptr, ptr @glad_glDrawElements, align 8, !tbaa !8
  tail call void %47(i32 noundef 4, i32 noundef %41, i32 noundef 5125, ptr noundef null)
  %48 = load ptr, ptr @glad_glGetError, align 8, !tbaa !8
  %49 = tail call i32 %48()
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %52, label %51

51:                                               ; preds = %46
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 209, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN30InternalOpenGL2RenderCallbacks6renderEP11sth_texture) #2
  unreachable

52:                                               ; preds = %46
  %53 = load ptr, ptr @glad_glBindVertexArray, align 8, !tbaa !8
  tail call void %53(i32 noundef 0)
  %54 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !8
  tail call void %54(i32 noundef 34962, i32 noundef 0)
  %55 = load ptr, ptr @glad_glBindBuffer, align 8, !tbaa !8
  tail call void %55(i32 noundef 34963, i32 noundef 0)
  %56 = load ptr, ptr @glad_glUseProgram, align 8, !tbaa !8
  tail call void %56(i32 noundef 0)
  ret void
}

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 = { noreturn 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 #2 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!13, !11, i64 788}
!13 = !{!"_ZTS11sth_texture", !6, i64 0, !9, i64 8, !6, i64 16, !11, i64 784, !11, i64 788, !6, i64 792, !9, i64 82712}


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