; LLVM IR from skywind3000/RenderHelp :: sample_03_box.ll (Z10draw_planeR10RenderHelpiiii)

; 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.VertexAttrib = type { %struct.Vector, %struct.Vector.1, %struct.Vector }
%struct.Vector.1 = type { %union.anon.2 }
%union.anon.2 = type { %struct.anon.3 }
%struct.anon.3 = type { float, float }
%struct.Vector = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float, float }

@vs_input = external dso_local global [3 x %struct.VertexAttrib], align 16
@mesh = external dso_local global [8 x %struct.VertexAttrib], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10draw_planeR10RenderHelpiiii(ptr noundef nonnull align 8 dereferenceable(824) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %12
  %14 = getelementptr inbounds %struct.VertexAttrib, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %struct.Vector.1, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct.anon.3, ptr %15, i32 0, i32 0
  store float 0.000000e+00, ptr %16, align 4, !tbaa !11
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.VertexAttrib, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.Vector.1, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.anon.3, ptr %21, i32 0, i32 1
  store float 0.000000e+00, ptr %22, align 4, !tbaa !11
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.VertexAttrib, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds %struct.Vector.1, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.anon.3, ptr %27, i32 0, i32 0
  store float 0.000000e+00, ptr %28, align 4, !tbaa !11
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.VertexAttrib, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct.Vector.1, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.anon.3, ptr %33, i32 0, i32 1
  store float 1.000000e+00, ptr %34, align 4, !tbaa !11
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.VertexAttrib, ptr %37, i32 0, i32 1
  %39 = getelementptr inbounds %struct.Vector.1, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.anon.3, ptr %39, i32 0, i32 0
  store float 1.000000e+00, ptr %40, align 4, !tbaa !11
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.VertexAttrib, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.Vector.1, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.anon.3, ptr %45, i32 0, i32 1
  store float 1.000000e+00, ptr %46, align 4, !tbaa !11
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.VertexAttrib, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.Vector.1, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon.3, ptr %51, i32 0, i32 0
  store float 1.000000e+00, ptr %52, align 4, !tbaa !11
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.VertexAttrib, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.Vector.1, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds %struct.anon.3, ptr %57, i32 0, i32 1
  store float 0.000000e+00, ptr %58, align 4, !tbaa !11
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %60
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @vs_input, ptr align 16 %61, i64 32, i1 false), !tbaa.struct !12
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %63
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 getelementptr inbounds ([3 x %struct.VertexAttrib], ptr @vs_input, i64 0, i64 1), ptr align 16 %64, i64 32, i1 false), !tbaa.struct !12
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %66
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 getelementptr inbounds ([3 x %struct.VertexAttrib], ptr @vs_input, i64 0, i64 2), ptr align 16 %67, i64 32, i1 false), !tbaa.struct !12
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call noundef zeroext i1 @_ZN10RenderHelp13DrawPrimitiveEv(ptr noundef nonnull align 8 dereferenceable(824) %68)
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %71
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @vs_input, ptr align 16 %72, i64 32, i1 false), !tbaa.struct !12
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %74
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 getelementptr inbounds ([3 x %struct.VertexAttrib], ptr @vs_input, i64 0, i64 1), ptr align 16 %75, i64 32, i1 false), !tbaa.struct !12
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %77
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 getelementptr inbounds ([3 x %struct.VertexAttrib], ptr @vs_input, i64 0, i64 2), ptr align 16 %78, i64 32, i1 false), !tbaa.struct !12
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = call noundef zeroext i1 @_ZN10RenderHelp13DrawPrimitiveEv(ptr noundef nonnull align 8 dereferenceable(824) %79)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN10RenderHelp13DrawPrimitiveEv(ptr noundef nonnull align 8 dereferenceable(824)) #2 align 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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" }

!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 = !{!7, !7, i64 0}
!12 = !{i64 0, i64 12, !11, i64 12, i64 8, !11, i64 20, i64 12, !11}


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

%struct.VertexAttrib = type { %struct.Vector, %struct.Vector.1, %struct.Vector }
%struct.Vector.1 = type { %union.anon.2 }
%union.anon.2 = type { %struct.anon.3 }
%struct.anon.3 = type { float, float }
%struct.Vector = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float, float }

@vs_input = external dso_local local_unnamed_addr global [3 x %struct.VertexAttrib], align 16
@mesh = external dso_local local_unnamed_addr global [8 x %struct.VertexAttrib], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10draw_planeR10RenderHelpiiii(ptr noundef nonnull align 8 dereferenceable(824) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = sext i32 %1 to i64
  %7 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %6
  %8 = getelementptr inbounds i8, ptr %7, i64 12
  store <2 x float> zeroinitializer, ptr %8, align 4, !tbaa !5
  %9 = sext i32 %2 to i64
  %10 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 12
  store <2 x float> <float 0.000000e+00, float 1.000000e+00>, ptr %11, align 4, !tbaa !5
  %12 = sext i32 %3 to i64
  %13 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %12
  %14 = getelementptr inbounds i8, ptr %13, i64 12
  store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %14, align 4, !tbaa !5
  %15 = sext i32 %4 to i64
  %16 = getelementptr inbounds [8 x %struct.VertexAttrib], ptr @mesh, i64 0, i64 %15
  %17 = getelementptr inbounds i8, ptr %16, i64 12
  store <2 x float> <float 1.000000e+00, float 0.000000e+00>, ptr %17, align 4, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @vs_input, ptr noundef nonnull align 16 dereferenceable(32) %7, i64 32, i1 false), !tbaa.struct !8
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) getelementptr inbounds (i8, ptr @vs_input, i64 32), ptr noundef nonnull align 16 dereferenceable(32) %10, i64 32, i1 false), !tbaa.struct !8
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) getelementptr inbounds (i8, ptr @vs_input, i64 64), ptr noundef nonnull align 16 dereferenceable(32) %13, i64 32, i1 false), !tbaa.struct !8
  %18 = tail call noundef zeroext i1 @_ZN10RenderHelp13DrawPrimitiveEv(ptr noundef nonnull align 8 dereferenceable(824) %0)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) @vs_input, ptr noundef nonnull align 16 dereferenceable(32) %13, i64 32, i1 false), !tbaa.struct !8
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) getelementptr inbounds (i8, ptr @vs_input, i64 32), ptr noundef nonnull align 16 dereferenceable(32) %16, i64 32, i1 false), !tbaa.struct !8
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) getelementptr inbounds (i8, ptr @vs_input, i64 64), ptr noundef nonnull align 16 dereferenceable(32) %7, i64 32, i1 false), !tbaa.struct !8
  %19 = tail call noundef zeroext i1 @_ZN10RenderHelp13DrawPrimitiveEv(ptr noundef nonnull align 8 dereferenceable(824) %0)
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN10RenderHelp13DrawPrimitiveEv(ptr noundef nonnull align 8 dereferenceable(824)) local_unnamed_addr #2 align 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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" }

!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 = !{i64 0, i64 12, !5, i64 12, i64 8, !5, i64 20, i64 12, !5}


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