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

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

%struct.HURDLE_CTX = type { [256 x i8] }

; Function Attrs: nounwind uwtable
declare dso_local void @transform_80_to_128(ptr noundef, ptr noundef) #0

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

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

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

declare void @HURDLE_set_key(ptr noundef, ptr noundef) #2

declare void @HURDLE_encrypt(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #2

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

%struct.HURDLE_CTX = type { [256 x i8] }

; Function Attrs: nounwind uwtable
declare dso_local void @transform_80_to_128(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @ta61_compute_c(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.HURDLE_CTX, align 1
  %4 = alloca [16 x i8], align 16
  %5 = alloca [8 x i8], align 8
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @transform_80_to_128(ptr noundef %0, ptr noundef nonnull %4)
  call void @HURDLE_set_key(ptr noundef nonnull %4, ptr noundef nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load <2 x i8>, ptr %0, align 1, !tbaa !5
  %8 = load <8 x i8>, ptr %6, align 1, !tbaa !5
  %9 = shufflevector <2 x i8> %7, <2 x i8> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %10 = shufflevector <8 x i8> %9, <8 x i8> %8, <8 x i32> <i32 0, i32 1, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13>
  %11 = xor <8 x i8> %8, %10
  store <8 x i8> %11, ptr %5, align 8, !tbaa !5
  call void @HURDLE_encrypt(ptr noundef %1, ptr noundef nonnull %5, ptr noundef nonnull %3, i8 noundef zeroext 0) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #3
  ret void
}

declare void @HURDLE_set_key(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @HURDLE_encrypt(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass