; LLVM IR from oswald2/AURIS :: esa-space-protocols/src/csrc (CLTUcsrc)

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

@m_bits = external hidden global [8 x i32], 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 @randomizerInitialise(i8 noundef zeroext %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  store i8 %0, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %5

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

8:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %26

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  %10 = load i32, ptr %3, align 4, !tbaa !8
  %11 = shl i32 1, %10
  %12 = trunc i32 %11 to i8
  store i8 %12, ptr %4, align 1, !tbaa !5
  %13 = load i8, ptr %4, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = load i8, ptr %2, align 1, !tbaa !5
  %16 = zext i8 %15 to i32
  %17 = and i32 %14, %16
  %18 = load i32, ptr %3, align 4, !tbaa !8
  %19 = ashr i32 %17, %18
  %20 = load i32, ptr %3, align 4, !tbaa !8
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [8 x i32], ptr @m_bits, i64 0, i64 %21
  store i32 %19, ptr %22, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  br label %23

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

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


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

@m_bits = external hidden local_unnamed_addr global [8 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @randomizerInitialise(i8 noundef zeroext %0) local_unnamed_addr #0 {
  %2 = zext i8 %0 to i32
  %3 = and i32 %2, 1
  store i32 %3, ptr @m_bits, align 16, !tbaa !5
  %4 = lshr i32 %2, 1
  %5 = and i32 %4, 1
  store i32 %5, ptr getelementptr inbounds (i8, ptr @m_bits, i64 4), align 4, !tbaa !5
  %6 = lshr i32 %2, 2
  %7 = and i32 %6, 1
  store i32 %7, ptr getelementptr inbounds (i8, ptr @m_bits, i64 8), align 8, !tbaa !5
  %8 = lshr i32 %2, 3
  %9 = and i32 %8, 1
  store i32 %9, ptr getelementptr inbounds (i8, ptr @m_bits, i64 12), align 4, !tbaa !5
  %10 = lshr i32 %2, 4
  %11 = and i32 %10, 1
  store i32 %11, ptr getelementptr inbounds (i8, ptr @m_bits, i64 16), align 16, !tbaa !5
  %12 = lshr i32 %2, 5
  %13 = and i32 %12, 1
  store i32 %13, ptr getelementptr inbounds (i8, ptr @m_bits, i64 20), align 4, !tbaa !5
  %14 = lshr i32 %2, 6
  %15 = and i32 %14, 1
  store i32 %15, ptr getelementptr inbounds (i8, ptr @m_bits, i64 24), align 8, !tbaa !5
  %16 = lshr i32 %2, 7
  store i32 %16, ptr getelementptr inbounds (i8, ptr @m_bits, i64 28), align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, 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" }

!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"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass