; LLVM IR from jpvt/Computer_Graphics :: Assignment #1/mygl_framework (mygl)

; 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.Pixel = type { %struct.Tuple, %struct.RGBA_Colors }
%struct.Tuple = type { i32, i32 }
%struct.RGBA_Colors = type { i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @LinearColorInterpolation(ptr noundef byval(%struct.Pixel) align 8 %0, ptr noundef %1, ptr noundef byval(%struct.Pixel) align 8 %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %14 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 0
  %15 = getelementptr inbounds %struct.Tuple, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.Pixel, ptr %0, i32 0, i32 0
  %18 = getelementptr inbounds %struct.Tuple, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = sub i32 %16, %19
  store i32 %20, ptr %5, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %21 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 0
  %22 = getelementptr inbounds %struct.Tuple, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !15
  %24 = getelementptr inbounds %struct.Pixel, ptr %0, i32 0, i32 0
  %25 = getelementptr inbounds %struct.Tuple, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = sub i32 %23, %26
  store i32 %27, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %28 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 0
  %29 = getelementptr inbounds %struct.Tuple, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Pixel, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.Tuple, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = sub i32 %30, %34
  store i32 %35, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %36 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 0
  %37 = getelementptr inbounds %struct.Tuple, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Pixel, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.Tuple, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !15
  %43 = sub i32 %38, %42
  store i32 %43, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %44 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %45 = getelementptr inbounds %struct.RGBA_Colors, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !16
  %47 = sub i32 0, %46
  %48 = getelementptr inbounds %struct.Pixel, ptr %0, i32 0, i32 1
  %49 = getelementptr inbounds %struct.RGBA_Colors, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !16
  %51 = add i32 %47, %50
  store i32 %51, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %52 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %53 = getelementptr inbounds %struct.RGBA_Colors, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !17
  %55 = sub i32 0, %54
  %56 = getelementptr inbounds %struct.Pixel, ptr %0, i32 0, i32 1
  %57 = getelementptr inbounds %struct.RGBA_Colors, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !17
  %59 = add i32 %55, %58
  store i32 %59, ptr %10, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %60 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %61 = getelementptr inbounds %struct.RGBA_Colors, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !18
  %63 = sub i32 0, %62
  %64 = getelementptr inbounds %struct.Pixel, ptr %0, i32 0, i32 1
  %65 = getelementptr inbounds %struct.RGBA_Colors, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !18
  %67 = add i32 %63, %66
  store i32 %67, ptr %11, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %68 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %69 = getelementptr inbounds %struct.RGBA_Colors, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 4, !tbaa !19
  %71 = sub i32 0, %70
  %72 = getelementptr inbounds %struct.Pixel, ptr %0, i32 0, i32 1
  %73 = getelementptr inbounds %struct.RGBA_Colors, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !19
  %75 = add i32 %71, %74
  store i32 %75, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %76 = load i32, ptr %7, align 4, !tbaa !14
  %77 = sitofp i32 %76 to double
  %78 = call double @pow(double noundef %77, double noundef 2.000000e+00) #4
  %79 = load i32, ptr %8, align 4, !tbaa !14
  %80 = sitofp i32 %79 to double
  %81 = call double @pow(double noundef %80, double noundef 2.000000e+00) #4
  %82 = fadd double %78, %81
  %83 = call double @sqrt(double noundef %82) #4
  %84 = load i32, ptr %5, align 4, !tbaa !14
  %85 = sitofp i32 %84 to double
  %86 = call double @pow(double noundef %85, double noundef 2.000000e+00) #4
  %87 = load i32, ptr %6, align 4, !tbaa !14
  %88 = sitofp i32 %87 to double
  %89 = call double @pow(double noundef %88, double noundef 2.000000e+00) #4
  %90 = fadd double %86, %89
  %91 = call double @sqrt(double noundef %90) #4
  %92 = fdiv double %83, %91
  store double %92, ptr %13, align 8, !tbaa !20
  %93 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %94 = getelementptr inbounds %struct.RGBA_Colors, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 8, !tbaa !16
  %96 = uitofp i32 %95 to double
  %97 = load i32, ptr %9, align 4, !tbaa !14
  %98 = sitofp i32 %97 to double
  %99 = load double, ptr %13, align 8, !tbaa !20
  %100 = call double @llvm.fmuladd.f64(double %98, double %99, double %96)
  %101 = fptoui double %100 to i32
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.Pixel, ptr %102, i32 0, i32 1
  %104 = getelementptr inbounds %struct.RGBA_Colors, ptr %103, i32 0, i32 0
  store i32 %101, ptr %104, align 4, !tbaa !16
  %105 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %106 = getelementptr inbounds %struct.RGBA_Colors, ptr %105, i32 0, i32 1
  %107 = load i32, ptr %106, align 4, !tbaa !17
  %108 = uitofp i32 %107 to double
  %109 = load i32, ptr %10, align 4, !tbaa !14
  %110 = sitofp i32 %109 to double
  %111 = load double, ptr %13, align 8, !tbaa !20
  %112 = call double @llvm.fmuladd.f64(double %110, double %111, double %108)
  %113 = fptoui double %112 to i32
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.Pixel, ptr %114, i32 0, i32 1
  %116 = getelementptr inbounds %struct.RGBA_Colors, ptr %115, i32 0, i32 1
  store i32 %113, ptr %116, align 4, !tbaa !17
  %117 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %118 = getelementptr inbounds %struct.RGBA_Colors, ptr %117, i32 0, i32 2
  %119 = load i32, ptr %118, align 8, !tbaa !18
  %120 = uitofp i32 %119 to double
  %121 = load i32, ptr %11, align 4, !tbaa !14
  %122 = sitofp i32 %121 to double
  %123 = load double, ptr %13, align 8, !tbaa !20
  %124 = call double @llvm.fmuladd.f64(double %122, double %123, double %120)
  %125 = fptoui double %124 to i32
  %126 = load ptr, ptr %4, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.Pixel, ptr %126, i32 0, i32 1
  %128 = getelementptr inbounds %struct.RGBA_Colors, ptr %127, i32 0, i32 2
  store i32 %125, ptr %128, align 4, !tbaa !18
  %129 = getelementptr inbounds %struct.Pixel, ptr %2, i32 0, i32 1
  %130 = getelementptr inbounds %struct.RGBA_Colors, ptr %129, i32 0, i32 3
  %131 = load i32, ptr %130, align 4, !tbaa !19
  %132 = uitofp i32 %131 to double
  %133 = load i32, ptr %12, align 4, !tbaa !14
  %134 = sitofp i32 %133 to double
  %135 = load double, ptr %13, align 8, !tbaa !20
  %136 = call double @llvm.fmuladd.f64(double %134, double %135, double %132)
  %137 = fptoui double %136 to i32
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.Pixel, ptr %138, i32 0, i32 1
  %140 = getelementptr inbounds %struct.RGBA_Colors, ptr %139, i32 0, i32 3
  store i32 %137, ptr %140, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 0}
!10 = !{!"Pixel", !11, i64 0, !13, i64 8}
!11 = !{!"Tuple", !12, i64 0, !12, i64 4}
!12 = !{!"int", !7, i64 0}
!13 = !{!"RGBA_Colors", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!14 = !{!12, !12, i64 0}
!15 = !{!10, !12, i64 4}
!16 = !{!10, !12, i64 8}
!17 = !{!10, !12, i64 12}
!18 = !{!10, !12, i64 16}
!19 = !{!10, !12, i64 20}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !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"

%struct.Pixel = type { %struct.Tuple, %struct.RGBA_Colors }
%struct.Tuple = type { i32, i32 }
%struct.RGBA_Colors = type { i32, i32, i32, i32 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @LinearColorInterpolation(ptr nocapture noundef readonly byval(%struct.Pixel) align 8 %0, ptr nocapture noundef %1, ptr nocapture noundef readonly byval(%struct.Pixel) align 8 %2) local_unnamed_addr #0 {
  %4 = load <4 x i32>, ptr %2, align 8
  %5 = load i32, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 4
  %7 = load <4 x i32>, ptr %6, align 4
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = shufflevector <4 x i32> %4, <4 x i32> poison, <2 x i32> zeroinitializer
  %16 = insertelement <2 x i32> poison, i32 %10, i64 0
  %17 = insertelement <2 x i32> %16, i32 %5, i64 1
  %18 = sub <2 x i32> %15, %17
  %19 = shufflevector <4 x i32> %7, <4 x i32> poison, <2 x i32> zeroinitializer
  %20 = insertelement <2 x i32> poison, i32 %12, i64 0
  %21 = insertelement <2 x i32> %20, i32 %9, i64 1
  %22 = sub <2 x i32> %19, %21
  %23 = sitofp <2 x i32> %18 to <2 x double>
  %24 = fmul <2 x double> %23, %23
  %25 = sitofp <2 x i32> %22 to <2 x double>
  %26 = fmul <2 x double> %25, %25
  %27 = fadd <2 x double> %24, %26
  %28 = tail call <2 x double> @llvm.sqrt.v2f64(<2 x double> %27)
  %29 = extractelement <2 x double> %28, i64 0
  %30 = extractelement <2 x double> %28, i64 1
  %31 = fdiv double %29, %30
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  %33 = load <4 x i32>, ptr %13, align 8, !tbaa !13
  %34 = load <4 x i32>, ptr %14, align 8, !tbaa !13
  %35 = sub <4 x i32> %34, %33
  %36 = uitofp <4 x i32> %33 to <4 x double>
  %37 = sitofp <4 x i32> %35 to <4 x double>
  %38 = insertelement <4 x double> poison, double %31, i64 0
  %39 = shufflevector <4 x double> %38, <4 x double> poison, <4 x i32> zeroinitializer
  %40 = tail call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %37, <4 x double> %39, <4 x double> %36)
  %41 = fptoui <4 x double> %40 to <4 x i32>
  store <4 x i32> %41, ptr %32, align 4, !tbaa !13
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x double> @llvm.fmuladd.v4f64(<4 x double>, <4 x double>, <4 x double>) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.sqrt.v2f64(<2 x double>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 nosync nounwind speculatable willreturn memory(none) }

!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, !8, i64 0}
!6 = !{!"Pixel", !7, i64 0, !11, i64 8}
!7 = !{!"Tuple", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"RGBA_Colors", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!12 = !{!6, !8, i64 4}
!13 = !{!8, !8, i64 0}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass