; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (gmskframegen)

; 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.gmskframegen_s = type { ptr, i32, i32, float, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, ptr, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @gmskframegen_write_tail(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  %5 = call i32 @rand() #4
  %6 = srem i32 %5, 2
  %7 = trunc i32 %6 to i8
  store i8 %7, ptr %3, align 1, !tbaa !9
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.gmskframegen_s, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !10
  %11 = load i8, ptr %3, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.gmskframegen_s, ptr %13, i32 0, i32 25
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = call i32 @gmskmod_modulate(ptr noundef %10, i32 noundef %12, ptr noundef %15)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.gmskframegen_s, ptr %17, i32 0, i32 24
  %19 = load i32, ptr %18, align 4, !tbaa !15
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.gmskframegen_s, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 4, !tbaa !16
  %23 = icmp uge i32 %19, %22
  br i1 %23, label %24, label %80

24:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !17
  br label %25

25:                                               ; preds = %76, %24
  %26 = load i32, ptr %4, align 4, !tbaa !17
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.gmskframegen_s, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !18
  %30 = icmp ult i32 %26, %29
  br i1 %30, label %31, label %79

31:                                               ; preds = %25
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.gmskframegen_s, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.gmskframegen_s, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !18
  %38 = mul i32 %34, %37
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.gmskframegen_s, ptr %39, i32 0, i32 24
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.gmskframegen_s, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !16
  %45 = sub i32 %41, %44
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.gmskframegen_s, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 8, !tbaa !18
  %49 = mul i32 %45, %48
  %50 = add i32 %38, %49
  %51 = load i32, ptr %4, align 4, !tbaa !17
  %52 = add i32 %50, %51
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.gmskframegen_s, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !16
  %56 = mul i32 2, %55
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.gmskframegen_s, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !18
  %60 = mul i32 %56, %59
  %61 = call float @liquid_hamming(i32 noundef %52, i32 noundef %60)
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.gmskframegen_s, ptr %62, i32 0, i32 25
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = load i32, ptr %4, align 4, !tbaa !17
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds { float, float }, ptr %64, i64 %66
  %68 = getelementptr inbounds { float, float }, ptr %67, i32 0, i32 0
  %69 = load float, ptr %68, align 4
  %70 = getelementptr inbounds { float, float }, ptr %67, i32 0, i32 1
  %71 = load float, ptr %70, align 4
  %72 = fmul float %69, %61
  %73 = fmul float %71, %61
  %74 = getelementptr inbounds { float, float }, ptr %67, i32 0, i32 0
  %75 = getelementptr inbounds { float, float }, ptr %67, i32 0, i32 1
  store float %72, ptr %74, align 4
  store float %73, ptr %75, align 4
  br label %76

76:                                               ; preds = %31
  %77 = load i32, ptr %4, align 4, !tbaa !17
  %78 = add i32 %77, 1
  store i32 %78, ptr %4, align 4, !tbaa !17
  br label %25, !llvm.loop !19

79:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %80

80:                                               ; preds = %79, %1
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.gmskframegen_s, ptr %81, i32 0, i32 24
  %83 = load i32, ptr %82, align 4, !tbaa !15
  %84 = add i32 %83, 1
  store i32 %84, ptr %82, align 4, !tbaa !15
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.gmskframegen_s, ptr %85, i32 0, i32 24
  %87 = load i32, ptr %86, align 4, !tbaa !15
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.gmskframegen_s, ptr %88, i32 0, i32 7
  %90 = load i32, ptr %89, align 8, !tbaa !21
  %91 = icmp eq i32 %87, %90
  br i1 %91, label %92, label %99

92:                                               ; preds = %80
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.gmskframegen_s, ptr %93, i32 0, i32 24
  store i32 0, ptr %94, align 4, !tbaa !15
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.gmskframegen_s, ptr %95, i32 0, i32 23
  store i32 1, ptr %96, align 8, !tbaa !22
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.gmskframegen_s, ptr %97, i32 0, i32 21
  store i32 0, ptr %98, align 8, !tbaa !23
  br label %99

99:                                               ; preds = %92, %80
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret i32 0
}

declare i32 @gmskmod_modulate(ptr noundef, i32 noundef, ptr noundef) #2

declare float @liquid_hamming(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @rand() #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 "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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"gmskframegen_s", !6, i64 0, !12, i64 8, !12, i64 12, !13, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !6, i64 112, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !6, i64 136, !12, i64 144}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!11, !6, i64 136}
!15 = !{!11, !12, i64 132}
!16 = !{!11, !12, i64 12}
!17 = !{!12, !12, i64 0}
!18 = !{!11, !12, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!11, !12, i64 32}
!22 = !{!11, !12, i64 128}
!23 = !{!11, !12, i64 120}


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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @gmskframegen_write_tail(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @rand() #3
  %3 = srem i32 %2, 2
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = and i32 %3, 255
  %6 = getelementptr inbounds i8, ptr %0, i64 136
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = tail call i32 @gmskmod_modulate(ptr noundef %4, i32 noundef %5, ptr noundef %7) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 132
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %.not = icmp ult i32 %10, %12
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !15
  %.not25 = icmp eq i32 %14, 0
  br i1 %.not25, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %15 = phi i32 [ %30, %.lr.ph ], [ %14, %.preheader ]
  %16 = load i32, ptr %11, align 4, !tbaa !14
  %17 = load i32, ptr %9, align 4, !tbaa !13
  %18 = mul i32 %17, %15
  %19 = trunc nuw i64 %indvars.iv to i32
  %20 = add i32 %18, %19
  %21 = shl i32 %15, 1
  %22 = mul i32 %21, %16
  %23 = tail call float @liquid_hamming(i32 noundef %20, i32 noundef %22) #3
  %24 = load ptr, ptr %6, align 8, !tbaa !12
  %25 = getelementptr inbounds { float, float }, ptr %24, i64 %indvars.iv
  %26 = load <2 x float>, ptr %25, align 4
  %27 = insertelement <2 x float> poison, float %23, i64 0
  %28 = shufflevector <2 x float> %27, <2 x float> poison, <2 x i32> zeroinitializer
  %29 = fmul <2 x float> %28, %26
  store <2 x float> %29, ptr %25, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr %13, align 8, !tbaa !15
  %31 = zext i32 %30 to i64
  %32 = icmp ult i64 %indvars.iv.next, %31
  br i1 %32, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !16

.loopexit.loopexit:                               ; preds = %.lr.ph
  %.pre = load i32, ptr %9, align 4, !tbaa !13
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %1
  %33 = phi i32 [ %.pre, %.loopexit.loopexit ], [ %10, %.preheader ], [ %10, %1 ]
  %34 = add i32 %33, 1
  store i32 %34, ptr %9, align 4, !tbaa !13
  %35 = getelementptr inbounds i8, ptr %0, i64 32
  %36 = load i32, ptr %35, align 8, !tbaa !18
  %37 = icmp eq i32 %34, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %.loopexit
  store i32 0, ptr %9, align 4, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %0, i64 128
  store i32 1, ptr %39, align 8, !tbaa !19
  %40 = getelementptr inbounds i8, ptr %0, i64 120
  store i32 0, ptr %40, align 8, !tbaa !20
  br label %41

41:                                               ; preds = %38, %.loopexit
  ret i32 0
}

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

declare float @liquid_hamming(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

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 = { "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 "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, !7, i64 0}
!6 = !{!"gmskframegen_s", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !7, i64 112, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !7, i64 136, !10, i64 144}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 136}
!13 = !{!6, !10, i64 132}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 32}
!19 = !{!6, !10, i64 128}
!20 = !{!6, !10, i64 120}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass