; LLVM IR from MidnightBlueLabs/TETRA_crypto :: taa1 (tb5)

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

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.tb5 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @tb5(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [3 x i32], align 4
  %12 = alloca [3 x i32], align 4
  %13 = alloca i16, align 2
  %14 = alloca i16, align 2
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %12) #4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 0
  %21 = load i16, ptr %20, align 2, !tbaa !9
  %22 = call i16 @llvm.bswap.i16(i16 %21)
  %23 = zext i16 %22 to i32
  %24 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 0
  store i32 %23, ptr %24, align 4, !tbaa !11
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 2
  %27 = load i32, ptr %26, align 4, !tbaa !11
  %28 = call i32 @llvm.bswap.i32(i32 %27)
  %29 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 1
  store i32 %28, ptr %29, align 4, !tbaa !11
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 6
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = call i32 @llvm.bswap.i32(i32 %32)
  %34 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 2
  store i32 %33, ptr %34, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #4
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i16, ptr %35, align 2, !tbaa !9
  %37 = call i16 @llvm.bswap.i16(i16 %36)
  store i16 %37, ptr %13, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #4
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i16, ptr %38, align 2, !tbaa !9
  %40 = call i16 @llvm.bswap.i16(i16 %39)
  store i16 %40, ptr %14, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #4
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i8, ptr %41, align 1, !tbaa !13
  store i8 %42, ptr %15, align 1, !tbaa !13
  %43 = load i16, ptr %13, align 2, !tbaa !9
  %44 = zext i16 %43 to i32
  %45 = and i32 %44, -4096
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %5
  br label %49

48:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 492, ptr noundef @__PRETTY_FUNCTION__.tb5) #5
  unreachable

49:                                               ; preds = %47
  %50 = load i16, ptr %14, align 2, !tbaa !9
  %51 = zext i16 %50 to i32
  %52 = and i32 %51, -16384
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  br label %56

55:                                               ; preds = %49
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 493, ptr noundef @__PRETTY_FUNCTION__.tb5) #5
  unreachable

56:                                               ; preds = %54
  %57 = load i8, ptr %15, align 1, !tbaa !13
  %58 = zext i8 %57 to i32
  %59 = and i32 %58, -64
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %56
  br label %63

62:                                               ; preds = %56
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 494, ptr noundef @__PRETTY_FUNCTION__.tb5) #5
  unreachable

63:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %64 = load i16, ptr %14, align 2, !tbaa !9
  %65 = zext i16 %64 to i32
  %66 = shl i32 %65, 2
  %67 = load i16, ptr %13, align 2, !tbaa !9
  %68 = zext i16 %67 to i32
  %69 = ashr i32 %68, 10
  %70 = or i32 %66, %69
  store i32 %70, ptr %16, align 4, !tbaa !11
  %71 = load i16, ptr %13, align 2, !tbaa !9
  %72 = zext i16 %71 to i32
  %73 = shl i32 %72, 22
  %74 = load i8, ptr %15, align 1, !tbaa !13
  %75 = zext i8 %74 to i32
  %76 = shl i32 %75, 16
  %77 = or i32 %73, %76
  %78 = load i16, ptr %13, align 2, !tbaa !9
  %79 = zext i16 %78 to i32
  %80 = shl i32 %79, 4
  %81 = or i32 %77, %80
  %82 = load i8, ptr %15, align 1, !tbaa !13
  %83 = zext i8 %82 to i32
  %84 = ashr i32 %83, 2
  %85 = or i32 %81, %84
  store i32 %85, ptr %17, align 4, !tbaa !11
  %86 = load i8, ptr %15, align 1, !tbaa !13
  %87 = zext i8 %86 to i32
  %88 = shl i32 %87, 30
  %89 = load i16, ptr %13, align 2, !tbaa !9
  %90 = zext i16 %89 to i32
  %91 = shl i32 %90, 18
  %92 = or i32 %88, %91
  %93 = load i8, ptr %15, align 1, !tbaa !13
  %94 = zext i8 %93 to i32
  %95 = shl i32 %94, 12
  %96 = or i32 %92, %95
  %97 = load i16, ptr %13, align 2, !tbaa !9
  %98 = zext i16 %97 to i32
  %99 = or i32 %96, %98
  store i32 %99, ptr %18, align 4, !tbaa !11
  %100 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 0
  %101 = load i32, ptr %100, align 4, !tbaa !11
  %102 = load i32, ptr %16, align 4, !tbaa !11
  %103 = xor i32 %101, %102
  %104 = getelementptr inbounds [3 x i32], ptr %11, i64 0, i64 0
  store i32 %103, ptr %104, align 4, !tbaa !11
  %105 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 1
  %106 = load i32, ptr %105, align 4, !tbaa !11
  %107 = load i32, ptr %17, align 4, !tbaa !11
  %108 = xor i32 %106, %107
  %109 = getelementptr inbounds [3 x i32], ptr %11, i64 0, i64 1
  store i32 %108, ptr %109, align 4, !tbaa !11
  %110 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 2
  %111 = load i32, ptr %110, align 4, !tbaa !11
  %112 = load i32, ptr %18, align 4, !tbaa !11
  %113 = xor i32 %111, %112
  %114 = getelementptr inbounds [3 x i32], ptr %11, i64 0, i64 2
  store i32 %113, ptr %114, align 4, !tbaa !11
  %115 = getelementptr inbounds [3 x i32], ptr %11, i64 0, i64 0
  %116 = load i32, ptr %115, align 4, !tbaa !11
  %117 = trunc i32 %116 to i16
  %118 = call i16 @llvm.bswap.i16(i16 %117)
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = getelementptr inbounds i8, ptr %119, i64 0
  store i16 %118, ptr %120, align 2, !tbaa !9
  %121 = getelementptr inbounds [3 x i32], ptr %11, i64 0, i64 1
  %122 = load i32, ptr %121, align 4, !tbaa !11
  %123 = call i32 @llvm.bswap.i32(i32 %122)
  %124 = load ptr, ptr %10, align 8, !tbaa !5
  %125 = getelementptr inbounds i8, ptr %124, i64 2
  store i32 %123, ptr %125, align 4, !tbaa !11
  %126 = getelementptr inbounds [3 x i32], ptr %11, i64 0, i64 2
  %127 = load i32, ptr %126, align 4, !tbaa !11
  %128 = call i32 @llvm.bswap.i32(i32 %127)
  %129 = load ptr, ptr %10, align 8, !tbaa !5
  %130 = getelementptr inbounds i8, ptr %129, i64 6
  store i32 %128, ptr %130, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.bswap.i16(i16) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.bswap.i32(i32) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}


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

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.tb5 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @tb5(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = load i16, ptr %3, align 2, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 2
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %3, i64 6
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = load i16, ptr %0, align 2, !tbaa !5
  %12 = tail call i16 @llvm.bswap.i16(i16 %11)
  %13 = load i8, ptr %2, align 1, !tbaa !11
  %14 = icmp ult i16 %12, 4096
  br i1 %14, label %16, label %15

15:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 492, ptr noundef nonnull @__PRETTY_FUNCTION__.tb5) #3
  unreachable

16:                                               ; preds = %5
  %17 = load i16, ptr %1, align 2, !tbaa !5
  %18 = tail call i16 @llvm.bswap.i16(i16 %17)
  %19 = icmp ult i16 %18, 16384
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 493, ptr noundef nonnull @__PRETTY_FUNCTION__.tb5) #3
  unreachable

21:                                               ; preds = %16
  %22 = icmp ult i8 %13, 64
  br i1 %22, label %24, label %23

23:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 494, ptr noundef nonnull @__PRETTY_FUNCTION__.tb5) #3
  unreachable

24:                                               ; preds = %21
  %25 = zext nneg i8 %13 to i32
  %26 = zext nneg i16 %12 to i32
  %27 = shl nuw i16 %18, 2
  %28 = lshr i16 %12, 10
  %29 = or disjoint i16 %27, %28
  %30 = shl i32 %26, 22
  %31 = shl nuw nsw i32 %25, 16
  %32 = or disjoint i32 %30, %31
  %33 = shl nuw nsw i32 %26, 4
  %34 = or disjoint i32 %32, %33
  %35 = lshr i32 %25, 2
  %36 = or disjoint i32 %34, %35
  %37 = shl i32 %25, 30
  %38 = shl nuw nsw i32 %26, 18
  %39 = or disjoint i32 %37, %38
  %40 = shl nuw nsw i32 %25, 12
  %41 = or disjoint i32 %39, %40
  %42 = or disjoint i32 %41, %26
  %43 = tail call i16 @llvm.bswap.i16(i16 %29)
  %44 = xor i16 %43, %6
  store i16 %44, ptr %4, align 2, !tbaa !5
  %45 = tail call i32 @llvm.bswap.i32(i32 %36)
  %46 = xor i32 %45, %8
  %47 = getelementptr inbounds i8, ptr %4, i64 2
  store i32 %46, ptr %47, align 4, !tbaa !9
  %48 = tail call i32 @llvm.bswap.i32(i32 %42)
  %49 = xor i32 %48, %10
  %50 = getelementptr inbounds i8, ptr %4, i64 6
  store i32 %49, ptr %50, align 4, !tbaa !9
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.bswap.i16(i16) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.bswap.i32(i32) #2

attributes #0 = { noreturn 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 #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { noreturn 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass