; LLVM IR from imkcat/CatCrypto :: Sources/ModuleMaps/MD6 (md6_mode)

; 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.md6_state = type { i32, i32, [128 x i8], [129 x i8], i32, i64, i64, i32, [8 x i64], i32, i32, i32, i32, [29 x [64 x i64]], [29 x i32], [29 x i64] }

@Q = external hidden constant [15 x i64], align 16

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

; 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 i32 @md6_compress_block(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %4
  store i32 3, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %123

16:                                               ; preds = %4
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.md6_state, ptr %17, i32 0, i32 4
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i32 5, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %123

22:                                               ; preds = %16
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i32 6, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %123

26:                                               ; preds = %22
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = icmp sge i32 %27, 28
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 7, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %123

30:                                               ; preds = %26
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.md6_state, ptr %31, i32 0, i32 6
  %33 = load i64, ptr %32, align 8, !tbaa !14
  %34 = add i64 %33, 1
  store i64 %34, ptr %32, align 8, !tbaa !14
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %59

37:                                               ; preds = %30
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.md6_state, ptr %39, i32 0, i32 10
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = add nsw i32 %41, 1
  %43 = icmp slt i32 %38, %42
  br i1 %43, label %44, label %51

44:                                               ; preds = %37
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.md6_state, ptr %45, i32 0, i32 13
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [29 x [64 x i64]], ptr %46, i64 0, i64 %48
  %50 = getelementptr inbounds [64 x i64], ptr %49, i64 0, i64 0
  call void @md6_reverse_little_endian(ptr noundef %50, i32 noundef 64)
  br label %58

51:                                               ; preds = %37
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.md6_state, ptr %52, i32 0, i32 13
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [29 x [64 x i64]], ptr %53, i64 0, i64 %55
  %57 = getelementptr inbounds [64 x i64], ptr %56, i64 0, i64 16
  call void @md6_reverse_little_endian(ptr noundef %57, i32 noundef 48)
  br label %58

58:                                               ; preds = %51, %44
  br label %59

59:                                               ; preds = %58, %30
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.md6_state, ptr %60, i32 0, i32 14
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [29 x i32], ptr %61, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = sub i32 4096, %65
  store i32 %66, ptr %10, align 4, !tbaa !9
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.md6_state, ptr %68, i32 0, i32 8
  %70 = getelementptr inbounds [8 x i64], ptr %69, i64 0, i64 0
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.md6_state, ptr %72, i32 0, i32 15
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [29 x i64], ptr %73, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !16
  %78 = trunc i64 %77 to i32
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.md6_state, ptr %79, i32 0, i32 11
  %81 = load i32, ptr %80, align 8, !tbaa !17
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.md6_state, ptr %82, i32 0, i32 10
  %84 = load i32, ptr %83, align 4, !tbaa !15
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.md6_state, ptr %87, i32 0, i32 9
  %89 = load i32, ptr %88, align 8, !tbaa !18
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.md6_state, ptr %90, i32 0, i32 0
  %92 = load i32, ptr %91, align 8, !tbaa !19
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.md6_state, ptr %93, i32 0, i32 13
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [29 x [64 x i64]], ptr %94, i64 0, i64 %96
  %98 = getelementptr inbounds [64 x i64], ptr %97, i64 0, i64 0
  %99 = call i32 @md6_standard_compress(ptr noundef %67, ptr noundef @Q, ptr noundef %70, i32 noundef %71, i32 noundef %78, i32 noundef %81, i32 noundef %84, i32 noundef %85, i32 noundef %86, i32 noundef %89, i32 noundef %92, ptr noundef %98)
  store i32 %99, ptr %11, align 4, !tbaa !9
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %104

102:                                              ; preds = %59
  %103 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %103, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %123

104:                                              ; preds = %59
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.md6_state, ptr %105, i32 0, i32 14
  %107 = load i32, ptr %8, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [29 x i32], ptr %106, i64 0, i64 %108
  store i32 0, ptr %109, align 4, !tbaa !9
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.md6_state, ptr %110, i32 0, i32 15
  %112 = load i32, ptr %8, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [29 x i64], ptr %111, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !16
  %116 = add i64 %115, 1
  store i64 %116, ptr %114, align 8, !tbaa !16
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.md6_state, ptr %117, i32 0, i32 13
  %119 = load i32, ptr %8, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [29 x [64 x i64]], ptr %118, i64 0, i64 %120
  %122 = getelementptr inbounds [64 x i64], ptr %121, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %122, i8 0, i64 512, i1 false)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %123

123:                                              ; preds = %104, %102, %29, %25, %21, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %124 = load i32, ptr %5, align 4
  ret i32 %124
}

declare i32 @md6_standard_compress(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 268}
!12 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 136, !10, i64 268, !13, i64 272, !13, i64 280, !10, i64 288, !7, i64 296, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !7, i64 376, !7, i64 15224, !7, i64 15344}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 280}
!15 = !{!12, !10, i64 364}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !10, i64 368}
!18 = !{!12, !10, i64 360}
!19 = !{!12, !10, 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"

@Q = external hidden constant [15 x i64], align 16

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @md6_compress_block(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %1, null
  br i1 %5, label %47, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %1, i64 268
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %47, label %10

10:                                               ; preds = %6
  %11 = icmp slt i32 %2, 0
  br i1 %11, label %47, label %12

12:                                               ; preds = %10
  %13 = icmp ugt i32 %2, 27
  br i1 %13, label %47, label %14

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %1, i64 280
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = add i64 %16, 1
  store i64 %17, ptr %15, align 8, !tbaa !11
  %18 = icmp eq i32 %2, 1
  br i1 %18, label %.sink.split, label %23

.sink.split:                                      ; preds = %14
  %19 = getelementptr inbounds i8, ptr %1, i64 364
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = icmp sgt i32 %20, 0
  %. = select i1 %21, i64 888, i64 1016
  %.40 = select i1 %21, i32 64, i32 48
  %22 = getelementptr inbounds i8, ptr %1, i64 %.
  tail call void @md6_reverse_little_endian(ptr noundef nonnull %22, i32 noundef %.40)
  br label %23

23:                                               ; preds = %.sink.split, %14
  %24 = getelementptr inbounds i8, ptr %1, i64 15224
  %25 = zext nneg i32 %2 to i64
  %26 = getelementptr inbounds [29 x i32], ptr %24, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = sub i32 4096, %27
  %29 = getelementptr inbounds i8, ptr %1, i64 296
  %30 = getelementptr inbounds i8, ptr %1, i64 15344
  %31 = getelementptr inbounds [29 x i64], ptr %30, i64 0, i64 %25
  %32 = load i64, ptr %31, align 8, !tbaa !14
  %33 = trunc i64 %32 to i32
  %34 = getelementptr inbounds i8, ptr %1, i64 368
  %35 = load i32, ptr %34, align 8, !tbaa !15
  %36 = getelementptr inbounds i8, ptr %1, i64 364
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = getelementptr inbounds i8, ptr %1, i64 360
  %39 = load i32, ptr %38, align 8, !tbaa !16
  %40 = load i32, ptr %1, align 8, !tbaa !17
  %41 = getelementptr inbounds i8, ptr %1, i64 376
  %42 = getelementptr inbounds [29 x [64 x i64]], ptr %41, i64 0, i64 %25
  %43 = tail call i32 @md6_standard_compress(ptr noundef %0, ptr noundef nonnull @Q, ptr noundef nonnull %29, i32 noundef %2, i32 noundef %33, i32 noundef %35, i32 noundef %37, i32 noundef %3, i32 noundef %28, i32 noundef %39, i32 noundef %40, ptr noundef nonnull %42) #3
  %.not = icmp eq i32 %43, 0
  br i1 %.not, label %44, label %47

44:                                               ; preds = %23
  store i32 0, ptr %26, align 4, !tbaa !13
  %45 = load i64, ptr %31, align 8, !tbaa !14
  %46 = add i64 %45, 1
  store i64 %46, ptr %31, align 8, !tbaa !14
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(512) %42, i8 0, i64 512, i1 false)
  br label %47

47:                                               ; preds = %23, %12, %10, %6, %4, %44
  %.0 = phi i32 [ 0, %44 ], [ 3, %4 ], [ 5, %6 ], [ 6, %10 ], [ 7, %12 ], [ %43, %23 ]
  ret i32 %.0
}

declare i32 @md6_standard_compress(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) 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 nounwind willreturn memory(argmem: write) }
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, !7, i64 268}
!6 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 136, !7, i64 268, !10, i64 272, !10, i64 280, !7, i64 288, !8, i64 296, !7, i64 360, !7, i64 364, !7, i64 368, !7, i64 372, !8, i64 376, !8, i64 15224, !8, i64 15344}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 280}
!12 = !{!6, !7, i64 364}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !7, i64 368}
!16 = !{!6, !7, i64 360}
!17 = !{!6, !7, i64 0}


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