; 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
@G = 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_G() #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 = %24, %6
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp ult i32 %8, 12
  br i1 %9, label %10, label %27

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

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

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

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

31:                                               ; preds = %28
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = icmp eq i32 %32, %33
  %35 = zext i1 %34 to i64
  %36 = select i1 %34, i32 1, i32 0
  %37 = trunc i32 %36 to i8
  %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 @G, i64 0, i64 %43
  store i8 %37, ptr %44, align 1, !tbaa !9
  br label %45

45:                                               ; preds = %31
  %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 %28, !llvm.loop !12

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

25:                                               ; 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