; LLVM IR from jgaeddert/liquid-dsp :: sandbox (fec_golay2412_test)

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

@P = external dso_local global [144 x i8], align 16
@H = external dso_local global [288 x i8], align 16

; 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 void @golay_init_H() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %49, %0
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp ult i32 %4, 12
  br i1 %5, label %6, label %52

6:                                                ; preds = %3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %23, %6
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp ult i32 %8, 12
  br i1 %9, label %10, label %26

10:                                               ; preds = %7
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 1, i32 0
  %16 = trunc i32 %15 to i8
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = mul i32 %17, 24
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = add i32 %18, %19
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %21
  store i8 %16, ptr %22, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %10
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %7, !llvm.loop !10

26:                                               ; preds = %7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %45, %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = icmp ult i32 %28, 12
  br i1 %29, label %30, label %48

30:                                               ; preds = %27
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = mul i32 %31, 12
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add i32 %32, %33
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [144 x i8], ptr @P, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %39 = mul i32 %38, 24
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = add i32 %39, %40
  %42 = add i32 %41, 12
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %43
  store i8 %37, ptr %44, align 1, !tbaa !9
  br label %45

45:                                               ; preds = %30
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = add i32 %46, 1
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %27, !llvm.loop !12

48:                                               ; preds = %27
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %1, align 4, !tbaa !5
  %51 = add i32 %50, 1
  store i32 %51, ptr %1, align 4, !tbaa !5
  br label %3, !llvm.loop !13

52:                                               ; preds = %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret void
}

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !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"

@P = external dso_local local_unnamed_addr global [144 x i8], align 16
@H = external dso_local local_unnamed_addr global [288 x i8], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @golay_init_H() local_unnamed_addr #0 {
  br label %.preheader15

.preheader15:                                     ; preds = %0, %.preheader15
  %indvar = phi i64 [ 0, %0 ], [ %indvar.next, %.preheader15 ]
  %1 = mul nuw nsw i64 %indvar, 24
  %gep = getelementptr i8, ptr getelementptr inbounds (i8, ptr @H, i64 12), i64 %1
  %2 = mul nuw nsw i64 %indvar, 12
  %scevgep20 = getelementptr i8, ptr @P, i64 %2
  %3 = insertelement <8 x i64> poison, i64 %indvar, i64 0
  %4 = shufflevector <8 x i64> %3, <8 x i64> poison, <8 x i32> zeroinitializer
  %5 = icmp eq <8 x i64> %4, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>
  %6 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %1
  %7 = zext <8 x i1> %5 to <8 x i8>
  store <8 x i8> %7, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i64 %indvar, 8
  %9 = zext i1 %8 to i8
  %10 = add nuw nsw i64 %1, 8
  %11 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %10
  store i8 %9, ptr %11, align 8, !tbaa !5
  %12 = icmp eq i64 %indvar, 9
  %13 = zext i1 %12 to i8
  %14 = add nuw nsw i64 %1, 9
  %15 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %14
  store i8 %13, ptr %15, align 1, !tbaa !5
  %16 = icmp eq i64 %indvar, 10
  %17 = zext i1 %16 to i8
  %18 = add nuw nsw i64 %1, 10
  %19 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %18
  store i8 %17, ptr %19, align 2, !tbaa !5
  %20 = icmp eq i64 %indvar, 11
  %21 = zext i1 %20 to i8
  %22 = add nuw nsw i64 %1, 11
  %23 = getelementptr inbounds [288 x i8], ptr @H, i64 0, i64 %22
  store i8 %21, ptr %23, align 1, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %gep, ptr noundef nonnull align 4 dereferenceable(12) %scevgep20, i64 12, i1 false), !tbaa !5
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond.not = icmp eq i64 %indvar.next, 12
  br i1 %exitcond.not, label %24, label %.preheader15, !llvm.loop !8

24:                                               ; preds = %.preheader15
  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

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

!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/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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