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

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

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %49

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %11 = load i32, ptr @m_bits, align 16, !tbaa !5
  %12 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 1), align 4, !tbaa !5
  %13 = xor i32 %11, %12
  store i32 %13, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 2), align 8, !tbaa !5
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = xor i32 %15, %14
  store i32 %16, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 3), align 4, !tbaa !5
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = xor i32 %18, %17
  store i32 %19, ptr %5, align 4, !tbaa !5
  %20 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 4), align 16, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = xor i32 %21, %20
  store i32 %22, ptr %5, align 4, !tbaa !5
  %23 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 6), align 8, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = xor i32 %24, %23
  store i32 %25, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = shl i32 %26, 1
  store i32 %27, ptr %3, align 4, !tbaa !5
  %28 = load i32, ptr @m_bits, align 16, !tbaa !5
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %33

30:                                               ; preds = %10
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = add i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %30, %10
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %45, label %36

36:                                               ; preds = %33
  %37 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 1), align 4, !tbaa !5
  store i32 %37, ptr @m_bits, align 16, !tbaa !5
  %38 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 2), align 8, !tbaa !5
  store i32 %38, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 1), align 4, !tbaa !5
  %39 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 3), align 4, !tbaa !5
  store i32 %39, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 2), align 8, !tbaa !5
  %40 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 4), align 16, !tbaa !5
  store i32 %40, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 3), align 4, !tbaa !5
  %41 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 5), align 4, !tbaa !5
  store i32 %41, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 4), align 16, !tbaa !5
  %42 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 6), align 8, !tbaa !5
  store i32 %42, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 5), align 4, !tbaa !5
  %43 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 7), align 4, !tbaa !5
  store i32 %43, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 6), align 8, !tbaa !5
  %44 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %44, ptr getelementptr inbounds ([8 x i32], ptr @m_bits, i64 0, i64 7), align 4, !tbaa !5
  br label %45

45:                                               ; preds = %36, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !9

49:                                               ; preds = %9
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = trunc i32 %50 to i8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i8 %51
}

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 = distinct !{!9, !10}
!10 = !{!"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(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local zeroext i8 @randomizerGetNextByteInSequence(i32 noundef %0) local_unnamed_addr #0 {
  %.not12 = icmp eq i32 %0, 0
  %m_bits.promoted = load i32, ptr @m_bits, align 16, !tbaa !5
  br i1 %.not12, label %.split.us.preheader, label %.split

.split.us.preheader:                              ; preds = %1
  %.promoted18 = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 28), align 4, !tbaa !5
  %.promoted17 = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 20), align 4, !tbaa !5
  %.promoted16 = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 24), align 8, !tbaa !5
  %.promoted15 = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 16), align 16, !tbaa !5
  %.promoted14 = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 12), align 4, !tbaa !5
  %.promoted13 = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 8), align 8, !tbaa !5
  %.promoted = load i32, ptr getelementptr inbounds (i8, ptr @m_bits, i64 4), align 4, !tbaa !5
  %.not.us.not = icmp eq i32 %m_bits.promoted, 0
  %2 = xor i32 %.promoted, %m_bits.promoted
  %3 = xor i32 %2, %.promoted13
  %4 = xor i32 %3, %.promoted14
  %5 = xor i32 %4, %.promoted15
  %6 = xor i32 %5, %.promoted16
  %7 = select i1 %.not.us.not, i8 0, i8 2
  %.not.us.1 = icmp ne i32 %.promoted, 0
  %8 = zext i1 %.not.us.1 to i8
  %spec.select.us.1 = or disjoint i8 %7, %8
  %9 = xor i32 %.promoted13, %.promoted
  %10 = xor i32 %9, %.promoted14
  %11 = xor i32 %10, %.promoted15
  %12 = xor i32 %11, %.promoted17
  %13 = xor i32 %12, %.promoted18
  %.not.us.2.not = icmp eq i32 %.promoted13, 0
  %14 = xor i32 %2, %.promoted17
  %15 = shl nuw nsw i8 %spec.select.us.1, 2
  %16 = select i1 %.not.us.2.not, i8 0, i8 2
  %17 = or disjoint i8 %15, %16
  %.not.us.3 = icmp ne i32 %.promoted14, 0
  %18 = zext i1 %.not.us.3 to i8
  %spec.select.us.3 = or disjoint i8 %17, %18
  %19 = xor i32 %9, %.promoted16
  %.not.us.4.not = icmp eq i32 %.promoted15, 0
  %20 = xor i32 %.promoted17, %.promoted15
  %21 = xor i32 %20, %.promoted16
  %22 = xor i32 %21, %.promoted18
  %23 = xor i32 %22, %6
  %24 = xor i32 %23, %14
  %25 = shl nuw nsw i8 %spec.select.us.3, 2
  %26 = select i1 %.not.us.4.not, i8 0, i8 2
  %27 = or disjoint i8 %25, %26
  %.not.us.5 = icmp ne i32 %.promoted17, 0
  %28 = zext i1 %.not.us.5 to i8
  %spec.select.us.5 = or disjoint i8 %27, %28
  %29 = xor i32 %.promoted16, %.promoted17
  %30 = xor i32 %29, %.promoted18
  %31 = xor i32 %30, %6
  %32 = xor i32 %31, %13
  %33 = xor i32 %32, %19
  %.not.us.6.not = icmp eq i32 %.promoted16, 0
  %34 = xor i32 %12, %5
  %35 = xor i32 %34, %23
  %36 = shl nuw i8 %spec.select.us.5, 2
  %37 = select i1 %.not.us.6.not, i8 0, i8 2
  %38 = or disjoint i8 %36, %37
  %.not.us.7 = icmp ne i32 %.promoted18, 0
  %39 = zext i1 %.not.us.7 to i8
  %spec.select.us.7 = or disjoint i8 %38, %39
  %40 = xor i32 %6, %12
  %41 = xor i32 %40, %14
  %42 = xor i32 %41, %32
  store i32 %6, ptr @m_bits, align 16, !tbaa !5
  store i32 %13, ptr getelementptr inbounds (i8, ptr @m_bits, i64 4), align 4, !tbaa !5
  store i32 %14, ptr getelementptr inbounds (i8, ptr @m_bits, i64 8), align 8, !tbaa !5
  store i32 %19, ptr getelementptr inbounds (i8, ptr @m_bits, i64 12), align 4, !tbaa !5
  store i32 %24, ptr getelementptr inbounds (i8, ptr @m_bits, i64 16), align 16, !tbaa !5
  store i32 %33, ptr getelementptr inbounds (i8, ptr @m_bits, i64 20), align 4, !tbaa !5
  store i32 %35, ptr getelementptr inbounds (i8, ptr @m_bits, i64 24), align 8, !tbaa !5
  store i32 %42, ptr getelementptr inbounds (i8, ptr @m_bits, i64 28), align 4, !tbaa !5
  br label %.split22

.split:                                           ; preds = %1
  %.not = icmp ne i32 %m_bits.promoted, 0
  %43 = zext i1 %.not to i8
  %44 = select i1 %.not, i8 2, i8 0
  %spec.select.1 = or disjoint i8 %44, %43
  %45 = shl nuw nsw i8 %spec.select.1, 2
  %46 = select i1 %.not, i8 2, i8 0
  %47 = or disjoint i8 %45, %46
  %spec.select.3 = or disjoint i8 %47, %43
  %48 = shl nuw nsw i8 %spec.select.3, 2
  %49 = select i1 %.not, i8 2, i8 0
  %50 = or disjoint i8 %48, %49
  %spec.select.5 = or disjoint i8 %50, %43
  %51 = shl nuw i8 %spec.select.5, 2
  %52 = select i1 %.not, i8 2, i8 0
  %53 = or disjoint i8 %51, %52
  %spec.select.7 = or disjoint i8 %53, %43
  br label %.split22

.split22:                                         ; preds = %.split, %.split.us.preheader
  %.us-phi = phi i8 [ %spec.select.us.7, %.split.us.preheader ], [ %spec.select.7, %.split ]
  ret i8 %.us-phi
}

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

!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: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass