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

; 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

declare void @HURDLE_enc_cbc(ptr noundef, ptr noundef, ptr noundef) #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @ta81(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #3 {
  %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 [16 x i8], align 16
  %12 = alloca [16 x i8], align 16
  %13 = alloca [16 x i8], align 16
  %14 = 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 16, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 0
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %18 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  store i8 %17, ptr %18, align 16, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 1
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 1
  store i8 %21, ptr %22, align 1, !tbaa !9
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 2
  %25 = load i8, ptr %24, align 1, !tbaa !9
  %26 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 2
  store i8 %25, ptr %26, align 2, !tbaa !9
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 3
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 3
  store i8 %29, ptr %30, align 1, !tbaa !9
  %31 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %32 = load i8, ptr %31, align 16, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 1
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = zext i8 %35 to i32
  %37 = xor i32 %33, %36
  %38 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 2
  %39 = load i8, ptr %38, align 2, !tbaa !9
  %40 = zext i8 %39 to i32
  %41 = xor i32 %37, %40
  %42 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 3
  %43 = load i8, ptr %42, align 1, !tbaa !9
  %44 = zext i8 %43 to i32
  %45 = xor i32 %41, %44
  %46 = trunc i32 %45 to i8
  %47 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 4
  store i8 %46, ptr %47, align 4, !tbaa !9
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 4
  %50 = load i8, ptr %49, align 1, !tbaa !9
  %51 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 5
  store i8 %50, ptr %51, align 1, !tbaa !9
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i64 5
  %54 = load i8, ptr %53, align 1, !tbaa !9
  %55 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 6
  store i8 %54, ptr %55, align 2, !tbaa !9
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 6
  %58 = load i8, ptr %57, align 1, !tbaa !9
  %59 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 7
  store i8 %58, ptr %59, align 1, !tbaa !9
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 7
  %62 = load i8, ptr %61, align 1, !tbaa !9
  %63 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 8
  store i8 %62, ptr %63, align 8, !tbaa !9
  %64 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 5
  %65 = load i8, ptr %64, align 1, !tbaa !9
  %66 = zext i8 %65 to i32
  %67 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 6
  %68 = load i8, ptr %67, align 2, !tbaa !9
  %69 = zext i8 %68 to i32
  %70 = xor i32 %66, %69
  %71 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 7
  %72 = load i8, ptr %71, align 1, !tbaa !9
  %73 = zext i8 %72 to i32
  %74 = xor i32 %70, %73
  %75 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 8
  %76 = load i8, ptr %75, align 8, !tbaa !9
  %77 = zext i8 %76 to i32
  %78 = xor i32 %74, %77
  %79 = trunc i32 %78 to i8
  %80 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 9
  store i8 %79, ptr %80, align 1, !tbaa !9
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %81, i64 8
  %83 = load i8, ptr %82, align 1, !tbaa !9
  %84 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 10
  store i8 %83, ptr %84, align 2, !tbaa !9
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i64 9
  %87 = load i8, ptr %86, align 1, !tbaa !9
  %88 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 11
  store i8 %87, ptr %88, align 1, !tbaa !9
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i64 0
  %91 = load i8, ptr %90, align 1, !tbaa !9
  %92 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 12
  store i8 %91, ptr %92, align 4, !tbaa !9
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i64 1
  %95 = load i8, ptr %94, align 1, !tbaa !9
  %96 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 13
  store i8 %95, ptr %96, align 1, !tbaa !9
  %97 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 10
  %98 = load i8, ptr %97, align 2, !tbaa !9
  %99 = zext i8 %98 to i32
  %100 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 11
  %101 = load i8, ptr %100, align 1, !tbaa !9
  %102 = zext i8 %101 to i32
  %103 = xor i32 %99, %102
  %104 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 12
  %105 = load i8, ptr %104, align 4, !tbaa !9
  %106 = zext i8 %105 to i32
  %107 = xor i32 %103, %106
  %108 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 13
  %109 = load i8, ptr %108, align 1, !tbaa !9
  %110 = zext i8 %109 to i32
  %111 = xor i32 %107, %110
  %112 = trunc i32 %111 to i8
  %113 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 14
  store i8 %112, ptr %113, align 2, !tbaa !9
  %114 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 15
  store i8 0, ptr %114, align 1, !tbaa !9
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %115

115:                                              ; preds = %137, %5
  %116 = load i32, ptr %14, align 4, !tbaa !10
  %117 = icmp slt i32 %116, 16
  br i1 %117, label %118, label %140

118:                                              ; preds = %115
  %119 = load ptr, ptr %9, align 8, !tbaa !5
  %120 = load i32, ptr %14, align 4, !tbaa !10
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i8, ptr %119, i64 %121
  %123 = load i8, ptr %122, align 1, !tbaa !9
  %124 = zext i8 %123 to i32
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = load i32, ptr %14, align 4, !tbaa !10
  %127 = and i32 %126, 1
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds i8, ptr %125, i64 %128
  %130 = load i8, ptr %129, align 1, !tbaa !9
  %131 = zext i8 %130 to i32
  %132 = xor i32 %124, %131
  %133 = trunc i32 %132 to i8
  %134 = load i32, ptr %14, align 4, !tbaa !10
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 %135
  store i8 %133, ptr %136, align 1, !tbaa !9
  br label %137

137:                                              ; preds = %118
  %138 = load i32, ptr %14, align 4, !tbaa !10
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %14, align 4, !tbaa !10
  br label %115, !llvm.loop !12

140:                                              ; preds = %115
  %141 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %142 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %143 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  call void @HURDLE_enc_cbc(ptr noundef %141, ptr noundef %142, ptr noundef %143)
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  %145 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %144, ptr align 16 %145, i64 7, i1 false)
  %146 = load ptr, ptr %10, align 8, !tbaa !5
  %147 = getelementptr inbounds i8, ptr %146, i64 7
  %148 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %149 = getelementptr inbounds i8, ptr %148, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %147, ptr align 1 %149, i64 8, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @HURDLE_enc_cbc(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @ta81(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 #3 {
  %6 = alloca [16 x i8], align 16
  %7 = alloca [16 x i8], align 16
  %8 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #4
  %9 = load i8, ptr %0, align 1, !tbaa !5
  store i8 %9, ptr %6, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 1
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %6, i64 1
  store i8 %11, ptr %12, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 2
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %6, i64 2
  store i8 %14, ptr %15, align 2, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 3
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %6, i64 3
  store i8 %17, ptr %18, align 1, !tbaa !5
  %19 = xor i8 %11, %9
  %20 = xor i8 %19, %14
  %21 = xor i8 %20, %17
  %22 = getelementptr inbounds i8, ptr %6, i64 4
  store i8 %21, ptr %22, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %6, i64 5
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 5
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %6, i64 6
  store i8 %27, ptr %28, align 2, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 6
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %6, i64 7
  store i8 %30, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 7
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %6, i64 8
  store i8 %33, ptr %34, align 8, !tbaa !5
  %35 = xor i8 %27, %24
  %36 = xor i8 %35, %30
  %37 = xor i8 %36, %33
  %38 = getelementptr inbounds i8, ptr %6, i64 9
  store i8 %37, ptr %38, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %6, i64 10
  store i8 %40, ptr %41, align 2, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %0, i64 9
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %6, i64 11
  store i8 %43, ptr %44, align 1, !tbaa !5
  %45 = load i8, ptr %2, align 1, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %6, i64 12
  store i8 %45, ptr %46, align 4, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %2, i64 1
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %6, i64 13
  store i8 %48, ptr %49, align 1, !tbaa !5
  %50 = xor i8 %43, %40
  %51 = xor i8 %50, %45
  %52 = xor i8 %51, %48
  %53 = getelementptr inbounds i8, ptr %6, i64 14
  store i8 %52, ptr %53, align 2, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %6, i64 15
  store i8 0, ptr %54, align 1, !tbaa !5
  %55 = load <2 x i8>, ptr %1, align 1, !tbaa !5
  %56 = shufflevector <2 x i8> %55, <2 x i8> poison, <16 x i32> <i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1>
  %57 = load <16 x i8>, ptr %3, align 1, !tbaa !5
  %58 = xor <16 x i8> %56, %57
  store <16 x i8> %58, ptr %8, align 16, !tbaa !5
  call void @HURDLE_enc_cbc(ptr noundef nonnull %7, ptr noundef nonnull %6, ptr noundef nonnull %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(7) %4, ptr noundef nonnull align 16 dereferenceable(7) %7, i64 7, i1 false)
  %59 = getelementptr inbounds i8, ptr %4, i64 7
  %60 = getelementptr inbounds i8, ptr %7, i64 8
  %61 = load i64, ptr %60, align 8
  store i64 %61, ptr %59, align 1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  ret void
}

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


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