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

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

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.bswap.i16(i16) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @tb6(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [3 x i32], align 4
  %10 = alloca [3 x i32], align 4
  %11 = alloca i16, align 2
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 0
  %18 = load i16, ptr %17, align 2, !tbaa !9
  %19 = call i16 @llvm.bswap.i16(i16 %18)
  %20 = zext i16 %19 to i32
  %21 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 0
  store i32 %20, ptr %21, align 4, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 2
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = call i32 @llvm.bswap.i32(i32 %24)
  %26 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 1
  store i32 %25, ptr %26, align 4, !tbaa !11
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 6
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = call i32 @llvm.bswap.i32(i32 %29)
  %31 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 2
  store i32 %30, ptr %31, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #3
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i16, ptr %32, align 2, !tbaa !9
  %34 = call i16 @llvm.bswap.i16(i16 %33)
  store i16 %34, ptr %11, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i16, ptr %35, align 2, !tbaa !9
  %37 = call i16 @llvm.bswap.i16(i16 %36)
  %38 = zext i16 %37 to i32
  %39 = shl i32 %38, 8
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 2
  %42 = load i8, ptr %41, align 1, !tbaa !13
  %43 = zext i8 %42 to i32
  %44 = or i32 %39, %43
  store i32 %44, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %45 = load i16, ptr %11, align 2, !tbaa !9
  %46 = zext i16 %45 to i32
  %47 = shl i32 %46, 4
  %48 = load i32, ptr %12, align 4, !tbaa !11
  %49 = lshr i32 %48, 20
  %50 = or i32 %47, %49
  store i32 %50, ptr %13, align 4, !tbaa !11
  %51 = load i32, ptr %12, align 4, !tbaa !11
  %52 = shl i32 %51, 12
  %53 = load i16, ptr %11, align 2, !tbaa !9
  %54 = zext i16 %53 to i32
  %55 = or i32 %52, %54
  store i32 %55, ptr %14, align 4, !tbaa !11
  %56 = load i32, ptr %12, align 4, !tbaa !11
  %57 = shl i32 %56, 8
  %58 = load i32, ptr %12, align 4, !tbaa !11
  %59 = and i32 %58, 255
  %60 = or i32 %57, %59
  store i32 %60, ptr %15, align 4, !tbaa !11
  %61 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 0
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = load i32, ptr %13, align 4, !tbaa !11
  %64 = xor i32 %62, %63
  %65 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 0
  store i32 %64, ptr %65, align 4, !tbaa !11
  %66 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 1
  %67 = load i32, ptr %66, align 4, !tbaa !11
  %68 = load i32, ptr %14, align 4, !tbaa !11
  %69 = xor i32 %67, %68
  %70 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 1
  store i32 %69, ptr %70, align 4, !tbaa !11
  %71 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 2
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = load i32, ptr %15, align 4, !tbaa !11
  %74 = xor i32 %72, %73
  %75 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 2
  store i32 %74, ptr %75, align 4, !tbaa !11
  %76 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 0
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = trunc i32 %77 to i16
  %79 = call i16 @llvm.bswap.i16(i16 %78)
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 0
  store i16 %79, ptr %81, align 2, !tbaa !9
  %82 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 1
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = call i32 @llvm.bswap.i32(i32 %83)
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i64 2
  store i32 %84, ptr %86, align 4, !tbaa !11
  %87 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 2
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = call i32 @llvm.bswap.i32(i32 %88)
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %90, i64 6
  store i32 %89, ptr %91, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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"

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

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @tb6(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %5 = load i16, ptr %0, align 2, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %0, i64 6
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = load i16, ptr %1, align 2, !tbaa !5
  %11 = tail call i16 @llvm.bswap.i16(i16 %10)
  %12 = load i16, ptr %2, align 2, !tbaa !5
  %13 = tail call i16 @llvm.bswap.i16(i16 %12)
  %14 = zext i16 %13 to i32
  %15 = shl nuw nsw i32 %14, 8
  %16 = getelementptr inbounds i8, ptr %2, i64 2
  %17 = load i8, ptr %16, align 1, !tbaa !11
  %18 = zext i8 %17 to i32
  %19 = or disjoint i32 %15, %18
  %20 = zext i16 %11 to i32
  %21 = tail call i16 @llvm.fshl.i16(i16 %11, i16 %13, i16 4)
  %22 = shl i32 %19, 12
  %23 = or i32 %22, %20
  %24 = shl nuw i32 %19, 8
  %25 = or disjoint i32 %24, %18
  %26 = tail call i16 @llvm.bswap.i16(i16 %21)
  %27 = xor i16 %26, %5
  store i16 %27, ptr %3, align 2, !tbaa !5
  %28 = tail call i32 @llvm.bswap.i32(i32 %23)
  %29 = xor i32 %28, %7
  %30 = getelementptr inbounds i8, ptr %3, i64 2
  store i32 %29, ptr %30, align 4, !tbaa !9
  %31 = tail call i32 @llvm.bswap.i32(i32 %25)
  %32 = xor i32 %31, %9
  %33 = getelementptr inbounds i8, ptr %3, i64 6
  store i32 %32, ptr %33, align 4, !tbaa !9
  ret void
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass