; LLVM IR from wojciech-graj/TermGL :: termgl (tgl_point)

; 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.TGLVert = type { i32, i32, float, i8, i8 }
%struct.TGLPixFmt = type { %struct.TGLFmt, %struct.TGLFmt }
%struct.TGLFmt = type { i8, %union.TGLFmtColor }
%union.TGLFmtColor = type { %struct.TGLRGB }
%struct.TGLRGB = type { i8, i8, i8 }
%struct.Pixel = type { i8, %struct.TGLPixFmt }
%struct.TGL = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i8, i8 }

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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @itgl_clip(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @tgl_point(ptr noundef %0, i64 %1, i64 %2, ptr noundef %3, ptr noundef %4) #3 {
  %6 = alloca %struct.TGLVert, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca %struct.TGLPixFmt, align 1
  %12 = alloca %struct.Pixel, align 1
  %13 = alloca %struct.Pixel, align 1
  %14 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 0
  store i64 %1, ptr %14, align 4
  %15 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 1
  store i64 %2, ptr %15, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  store ptr %4, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 0
  %18 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 1
  call void @itgl_clip(ptr noundef %16, ptr noundef %17, ptr noundef %18)
  br label %19

19:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.TGL, ptr %20, i32 0, i32 9
  %22 = load i8, ptr %21, align 4, !tbaa !9, !range !13, !noundef !14
  %23 = trunc i8 %22 to i1
  br i1 %23, label %51, label %24

24:                                               ; preds = %19
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 3
  %27 = load i8, ptr %26, align 4, !tbaa !15
  %28 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 4
  %29 = load i8, ptr %28, align 1, !tbaa !18
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  call void %25(i8 noundef zeroext %27, i8 noundef zeroext %29, ptr noundef %11, ptr noundef %10, ptr noundef %30)
  br label %31

31:                                               ; preds = %24
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.TGL, ptr %32, i32 0, i32 5
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  %35 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !20
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.TGL, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !21
  %40 = mul i32 %36, %39
  %41 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !22
  %43 = add i32 %40, %42
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds %struct.Pixel, ptr %34, i64 %44
  %46 = getelementptr inbounds %struct.Pixel, ptr %12, i32 0, i32 0
  %47 = load i8, ptr %10, align 1, !tbaa !23
  store i8 %47, ptr %46, align 1, !tbaa !24
  %48 = getelementptr inbounds %struct.Pixel, ptr %12, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %48, ptr align 1 %11, i64 8, i1 false), !tbaa.struct !28
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %45, ptr align 1 %12, i64 9, i1 false), !tbaa.struct !29
  br label %49

49:                                               ; preds = %31
  br label %50

50:                                               ; preds = %49
  br label %114

51:                                               ; preds = %19
  %52 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 2
  %53 = load float, ptr %52, align 4, !tbaa !30
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TGL, ptr %54, i32 0, i32 6
  %56 = load ptr, ptr %55, align 8, !tbaa !31
  %57 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !20
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.TGL, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !21
  %62 = mul i32 %58, %61
  %63 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 0
  %64 = load i32, ptr %63, align 4, !tbaa !22
  %65 = add i32 %62, %64
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %56, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !32
  %69 = fcmp oge float %53, %68
  br i1 %69, label %70, label %113

70:                                               ; preds = %51
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 3
  %73 = load i8, ptr %72, align 4, !tbaa !15
  %74 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 4
  %75 = load i8, ptr %74, align 1, !tbaa !18
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  call void %71(i8 noundef zeroext %73, i8 noundef zeroext %75, ptr noundef %11, ptr noundef %10, ptr noundef %76)
  br label %77

77:                                               ; preds = %70
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.TGL, ptr %78, i32 0, i32 5
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  %81 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !20
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TGL, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !21
  %86 = mul i32 %82, %85
  %87 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !22
  %89 = add i32 %86, %88
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds %struct.Pixel, ptr %80, i64 %90
  %92 = getelementptr inbounds %struct.Pixel, ptr %13, i32 0, i32 0
  %93 = load i8, ptr %10, align 1, !tbaa !23
  store i8 %93, ptr %92, align 1, !tbaa !24
  %94 = getelementptr inbounds %struct.Pixel, ptr %13, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %94, ptr align 1 %11, i64 8, i1 false), !tbaa.struct !28
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %91, ptr align 1 %13, i64 9, i1 false), !tbaa.struct !29
  br label %95

95:                                               ; preds = %77
  br label %96

96:                                               ; preds = %95
  %97 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 2
  %98 = load float, ptr %97, align 4, !tbaa !30
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.TGL, ptr %99, i32 0, i32 6
  %101 = load ptr, ptr %100, align 8, !tbaa !31
  %102 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 1
  %103 = load i32, ptr %102, align 4, !tbaa !20
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.TGL, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !21
  %107 = mul i32 %103, %106
  %108 = getelementptr inbounds %struct.TGLVert, ptr %6, i32 0, i32 0
  %109 = load i32, ptr %108, align 4, !tbaa !22
  %110 = add i32 %107, %109
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds float, ptr %101, i64 %111
  store float %98, ptr %112, align 4, !tbaa !32
  br label %113

113:                                              ; preds = %96, %51
  br label %114

114:                                              ; preds = %113, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  br label %115

115:                                              ; preds = %114
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint nounwind 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 #3 = { nounwind 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 #4 = { 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/C++ TBAA"}
!9 = !{!10, !12, i64 52}
!10 = !{!"TGL", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !12, i64 52, !7, i64 53}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !7, i64 12}
!16 = !{!"TGLVert", !11, i64 0, !11, i64 4, !17, i64 8, !7, i64 12, !7, i64 13}
!17 = !{!"float", !7, i64 0}
!18 = !{!16, !7, i64 13}
!19 = !{!10, !6, i64 24}
!20 = !{!16, !11, i64 4}
!21 = !{!10, !11, i64 0}
!22 = !{!16, !11, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!25, !7, i64 0}
!25 = !{!"Pixel", !7, i64 0, !26, i64 1}
!26 = !{!"TGLPixFmt", !27, i64 0, !27, i64 4}
!27 = !{!"TGLFmt", !7, i64 0, !7, i64 1}
!28 = !{i64 0, i64 1, !23, i64 1, i64 3, !23, i64 4, i64 1, !23, i64 5, i64 3, !23}
!29 = !{i64 0, i64 1, !23, i64 1, i64 1, !23, i64 2, i64 3, !23, i64 5, i64 1, !23, i64 6, i64 3, !23}
!30 = !{!16, !17, i64 8}
!31 = !{!10, !6, i64 32}
!32 = !{!17, !17, 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"

%struct.TGLVert = type { i32, i32, float, i8, i8 }
%struct.TGLPixFmt = type { %struct.TGLFmt, %struct.TGLFmt }
%struct.TGLFmt = type { i8, %union.TGLFmtColor }
%union.TGLFmtColor = type { %struct.TGLRGB }
%struct.TGLRGB = type { i8, i8, i8 }
%struct.Pixel = type { i8, %struct.TGLPixFmt }

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @itgl_clip(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @tgl_point(ptr noundef %0, i64 %1, i64 %2, ptr nocapture noundef readonly %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca %struct.TGLVert, align 8
  %7 = alloca i8, align 1
  %8 = alloca %struct.TGLPixFmt, align 8
  store i64 %1, ptr %6, align 8
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  store i64 %2, ptr %9, align 8
  %10 = getelementptr inbounds i8, ptr %6, i64 4
  call void @itgl_clip(ptr noundef %0, ptr noundef nonnull %6, ptr noundef nonnull %10)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 52
  %12 = load i8, ptr %11, align 4, !tbaa !5, !range !12, !noundef !13
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %30, label %14

14:                                               ; preds = %5
  %15 = getelementptr inbounds i8, ptr %6, i64 12
  %16 = load i8, ptr %15, align 4, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %6, i64 13
  %18 = load i8, ptr %17, align 1, !tbaa !17
  call void %3(i8 noundef zeroext %16, i8 noundef zeroext %18, ptr noundef nonnull %8, ptr noundef nonnull %7, ptr noundef %4) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  %21 = load i32, ptr %10, align 4, !tbaa !19
  %22 = load i32, ptr %0, align 8, !tbaa !20
  %23 = mul i32 %22, %21
  %24 = load i32, ptr %6, align 8, !tbaa !21
  %25 = add i32 %23, %24
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds %struct.Pixel, ptr %20, i64 %26
  %28 = load i8, ptr %7, align 1, !tbaa !22
  %29 = load i64, ptr %8, align 8
  store i8 %28, ptr %27, align 1, !tbaa !22
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %27, i64 1
  store i64 %29, ptr %.sroa.22.0..sroa_idx, align 1
  br label %68

30:                                               ; preds = %5
  %31 = load float, ptr %9, align 8, !tbaa !23
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  %34 = load i32, ptr %10, align 4, !tbaa !19
  %35 = load i32, ptr %0, align 8, !tbaa !20
  %36 = mul i32 %35, %34
  %37 = load i32, ptr %6, align 8, !tbaa !21
  %38 = add i32 %36, %37
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %33, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !25
  %42 = fcmp ult float %31, %41
  br i1 %42, label %68, label %43

43:                                               ; preds = %30
  %44 = getelementptr inbounds i8, ptr %6, i64 12
  %45 = load i8, ptr %44, align 4, !tbaa !14
  %46 = getelementptr inbounds i8, ptr %6, i64 13
  %47 = load i8, ptr %46, align 1, !tbaa !17
  call void %3(i8 noundef zeroext %45, i8 noundef zeroext %47, ptr noundef nonnull %8, ptr noundef nonnull %7, ptr noundef %4) #3
  %48 = getelementptr inbounds i8, ptr %0, i64 24
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load i32, ptr %10, align 4, !tbaa !19
  %51 = load i32, ptr %0, align 8, !tbaa !20
  %52 = mul i32 %51, %50
  %53 = load i32, ptr %6, align 8, !tbaa !21
  %54 = add i32 %52, %53
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds %struct.Pixel, ptr %49, i64 %55
  %57 = load i8, ptr %7, align 1, !tbaa !22
  %58 = load i64, ptr %8, align 8
  store i8 %57, ptr %56, align 1, !tbaa !22
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %56, i64 1
  store i64 %58, ptr %.sroa.2.0..sroa_idx, align 1
  %59 = load float, ptr %9, align 8, !tbaa !23
  %60 = load ptr, ptr %32, align 8, !tbaa !24
  %61 = load i32, ptr %10, align 4, !tbaa !19
  %62 = load i32, ptr %0, align 8, !tbaa !20
  %63 = mul i32 %62, %61
  %64 = load i32, ptr %6, align 8, !tbaa !21
  %65 = add i32 %63, %64
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %60, i64 %66
  store float %59, ptr %67, align 4, !tbaa !25
  br label %68

68:                                               ; preds = %30, %43, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint nounwind 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 #2 = { nounwind 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 #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, !11, i64 52}
!6 = !{!"TGL", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !7, i64 48, !11, i64 52, !8, i64 53}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!15, !8, i64 12}
!15 = !{!"TGLVert", !7, i64 0, !7, i64 4, !16, i64 8, !8, i64 12, !8, i64 13}
!16 = !{!"float", !8, i64 0}
!17 = !{!15, !8, i64 13}
!18 = !{!6, !10, i64 24}
!19 = !{!15, !7, i64 4}
!20 = !{!6, !7, i64 0}
!21 = !{!15, !7, i64 0}
!22 = !{!8, !8, i64 0}
!23 = !{!15, !16, i64 8}
!24 = !{!6, !10, i64 32}
!25 = !{!16, !16, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass