; LLVM IR from openssl/openssl :: crypto/modes (cts128)

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

%union.anon.4 = type { i64, [24 x i8] }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @CRYPTO_nistcts128_decrypt(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #3 {
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca %union.anon.4, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #4
  %17 = load i64, ptr %10, align 8, !tbaa !9
  %18 = icmp ult i64 %17, 16
  br i1 %18, label %19, label %20

19:                                               ; preds = %6
  store i64 0, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %79

20:                                               ; preds = %6
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = urem i64 %21, 16
  store i64 %22, ptr %14, align 8, !tbaa !9
  %23 = load i64, ptr %14, align 8, !tbaa !9
  %24 = icmp eq i64 %23, 0
  br i1 %24, label %25, label %33

25:                                               ; preds = %20
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load i64, ptr %10, align 8, !tbaa !9
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  call void %26(ptr noundef %27, ptr noundef %28, i64 noundef %29, ptr noundef %30, ptr noundef %31, i32 noundef 0)
  %32 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %32, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %79

33:                                               ; preds = %20
  %34 = load i64, ptr %14, align 8, !tbaa !9
  %35 = add i64 16, %34
  %36 = load i64, ptr %10, align 8, !tbaa !9
  %37 = sub i64 %36, %35
  store i64 %37, ptr %10, align 8, !tbaa !9
  %38 = load i64, ptr %10, align 8, !tbaa !9
  %39 = icmp ne i64 %38, 0
  br i1 %39, label %40, label %53

40:                                               ; preds = %33
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  call void %41(ptr noundef %42, ptr noundef %43, i64 noundef %44, ptr noundef %45, ptr noundef %46, i32 noundef 0)
  %47 = load i64, ptr %10, align 8, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 %47
  store ptr %49, ptr %8, align 8, !tbaa !5
  %50 = load i64, ptr %10, align 8, !tbaa !9
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 %50
  store ptr %52, ptr %9, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %40, %33
  %54 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %54, i8 0, i64 32, i1 false)
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i64, ptr %14, align 8, !tbaa !9
  %58 = getelementptr inbounds i8, ptr %56, i64 %57
  %59 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %62 = getelementptr inbounds i8, ptr %61, i64 16
  call void %55(ptr noundef %58, ptr noundef %59, i64 noundef 16, ptr noundef %60, ptr noundef %62, i32 noundef 0)
  %63 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load i64, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %63, ptr align 1 %64, i64 %65, i1 false)
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %68 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  call void %66(ptr noundef %67, ptr noundef %68, i64 noundef 32, ptr noundef %69, ptr noundef %70, i32 noundef 0)
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %73 = load i64, ptr %14, align 8, !tbaa !9
  %74 = add i64 16, %73
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %71, ptr align 8 %72, i64 %74, i1 false)
  %75 = load i64, ptr %10, align 8, !tbaa !9
  %76 = add i64 16, %75
  %77 = load i64, ptr %14, align 8, !tbaa !9
  %78 = add i64 %76, %77
  store i64 %78, ptr %7, align 8
  store i32 1, ptr %16, align 4
  br label %79

79:                                               ; preds = %53, %25, %19
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %80 = load i64, ptr %7, align 8
  ret i64 %80
}

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

%union.anon.4 = type { i64, [24 x i8] }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @CRYPTO_nistcts128_decrypt(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef readonly %5) local_unnamed_addr #3 {
  %7 = alloca %union.anon.4, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #4
  %8 = icmp ult i64 %2, 16
  br i1 %8, label %22, label %9

9:                                                ; preds = %6
  %10 = and i64 %2, 15
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  tail call void %5(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef 0) #4
  br label %22

13:                                               ; preds = %9
  %14 = or disjoint i64 %10, 16
  %.not = icmp eq i64 %14, %2
  br i1 %.not, label %19, label %15

15:                                               ; preds = %13
  %16 = sub i64 %2, %14
  tail call void %5(ptr noundef %0, ptr noundef %1, i64 noundef %16, ptr noundef %3, ptr noundef %4, i32 noundef 0) #4
  %17 = getelementptr inbounds i8, ptr %0, i64 %16
  %18 = getelementptr inbounds i8, ptr %1, i64 %16
  br label %19

19:                                               ; preds = %15, %13
  %.037 = phi ptr [ %18, %15 ], [ %1, %13 ]
  %.036 = phi ptr [ %17, %15 ], [ %0, %13 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %7, i8 0, i64 32, i1 false)
  %20 = getelementptr inbounds i8, ptr %.036, i64 %10
  %21 = getelementptr inbounds i8, ptr %7, i64 16
  call void %5(ptr noundef nonnull %20, ptr noundef nonnull %7, i64 noundef 16, ptr noundef %3, ptr noundef nonnull %21, i32 noundef 0) #4
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %7, ptr align 1 %.036, i64 %10, i1 false)
  call void %5(ptr noundef nonnull %7, ptr noundef nonnull %7, i64 noundef 32, ptr noundef %3, ptr noundef %4, i32 noundef 0) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %.037, ptr noundef nonnull align 8 dereferenceable(1) %7, i64 %14, i1 false)
  br label %22

22:                                               ; preds = %6, %19, %12
  %.0 = phi i64 [ %2, %12 ], [ %2, %19 ], [ 0, %6 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #4
  ret i64 %.0
}

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


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