; LLVM IR from openssl/openssl :: crypto/sha (keccak1600)

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

@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__PRETTY_FUNCTION__.SHA3_absorb = external hidden unnamed_addr constant [75 x i8], align 1

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

18:                                               ; preds = %4
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = urem i64 %19, 8
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  br label %24

23:                                               ; preds = %18, %4
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1075, ptr noundef @__PRETTY_FUNCTION__.SHA3_absorb) #4
  unreachable

24:                                               ; preds = %22
  br label %25

25:                                               ; preds = %93, %24
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = icmp uge i64 %26, %27
  br i1 %28, label %29, label %98

29:                                               ; preds = %25
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %90, %29
  %31 = load i64, ptr %10, align 8, !tbaa !9
  %32 = load i64, ptr %11, align 8, !tbaa !9
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %34, label %93

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 0
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = zext i8 %37 to i64
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = zext i8 %41 to i64
  %43 = shl i64 %42, 8
  %44 = or i64 %38, %43
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 2
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = zext i8 %47 to i64
  %49 = shl i64 %48, 16
  %50 = or i64 %44, %49
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 3
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = zext i8 %53 to i64
  %55 = shl i64 %54, 24
  %56 = or i64 %50, %55
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 4
  %59 = load i8, ptr %58, align 1, !tbaa !11
  %60 = zext i8 %59 to i64
  %61 = shl i64 %60, 32
  %62 = or i64 %56, %61
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 5
  %65 = load i8, ptr %64, align 1, !tbaa !11
  %66 = zext i8 %65 to i64
  %67 = shl i64 %66, 40
  %68 = or i64 %62, %67
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 6
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = zext i8 %71 to i64
  %73 = shl i64 %72, 48
  %74 = or i64 %68, %73
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 7
  %77 = load i8, ptr %76, align 1, !tbaa !11
  %78 = zext i8 %77 to i64
  %79 = shl i64 %78, 56
  %80 = or i64 %74, %79
  store i64 %80, ptr %12, align 8, !tbaa !9
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %81, i64 8
  store ptr %82, ptr %6, align 8, !tbaa !5
  %83 = load i64, ptr %12, align 8, !tbaa !9
  %84 = call i64 @BitInterleave(i64 noundef %83)
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = load i64, ptr %10, align 8, !tbaa !9
  %87 = getelementptr inbounds i64, ptr %85, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !9
  %89 = xor i64 %88, %84
  store i64 %89, ptr %87, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %90

90:                                               ; preds = %34
  %91 = load i64, ptr %10, align 8, !tbaa !9
  %92 = add i64 %91, 1
  store i64 %92, ptr %10, align 8, !tbaa !9
  br label %30, !llvm.loop !12

93:                                               ; preds = %30
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  call void @KeccakF1600(ptr noundef %94)
  %95 = load i64, ptr %8, align 8, !tbaa !9
  %96 = load i64, ptr %7, align 8, !tbaa !9
  %97 = sub i64 %96, %95
  store i64 %97, ptr %7, align 8, !tbaa !9
  br label %25, !llvm.loop !14

98:                                               ; preds = %25
  %99 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret i64 %99
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @BitInterleave(i64 noundef) #0

; 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
declare hidden void @KeccakF1600(ptr noundef) #0

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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@__PRETTY_FUNCTION__.SHA3_absorb = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 199) i64 @SHA3_absorb(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = lshr i64 %3, 3
  %6 = icmp ult i64 %3, 200
  %7 = and i64 %3, 7
  %8 = icmp eq i64 %7, 0
  %or.cond = and i1 %6, %8
  br i1 %or.cond, label %.preheader28, label %18

.preheader28:                                     ; preds = %4
  %.not31 = icmp ult i64 %2, %3
  br i1 %.not31, label %._crit_edge34, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader28
  %.not36 = icmp ult i64 %3, 8
  br i1 %.not36, label %.preheader, label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.lr.ph, %._crit_edge.us
  %.033.us = phi ptr [ %11, %._crit_edge.us ], [ %1, %.preheader.lr.ph ]
  %.02432.us = phi i64 [ %17, %._crit_edge.us ], [ %2, %.preheader.lr.ph ]
  br label %9

9:                                                ; preds = %.preheader.us, %9
  %.130.us = phi ptr [ %.033.us, %.preheader.us ], [ %11, %9 ]
  %.02529.us = phi i64 [ 0, %.preheader.us ], [ %16, %9 ]
  %10 = load i64, ptr %.130.us, align 1
  %11 = getelementptr inbounds i8, ptr %.130.us, i64 8
  %12 = tail call i64 @BitInterleave(i64 noundef %10)
  %13 = getelementptr inbounds i64, ptr %0, i64 %.02529.us
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = xor i64 %14, %12
  store i64 %15, ptr %13, align 8, !tbaa !5
  %16 = add nuw nsw i64 %.02529.us, 1
  %exitcond.not = icmp eq i64 %16, %5
  br i1 %exitcond.not, label %._crit_edge.us, label %9, !llvm.loop !9

._crit_edge.us:                                   ; preds = %9
  tail call void @KeccakF1600(ptr noundef nonnull %0)
  %17 = sub i64 %.02432.us, %3
  %.not.us = icmp ult i64 %17, %3
  br i1 %.not.us, label %._crit_edge34, label %.preheader.us, !llvm.loop !11

18:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1075, ptr noundef nonnull @__PRETTY_FUNCTION__.SHA3_absorb) #2
  unreachable

.preheader:                                       ; preds = %.preheader.lr.ph, %.preheader
  %.02432 = phi i64 [ %19, %.preheader ], [ %2, %.preheader.lr.ph ]
  tail call void @KeccakF1600(ptr noundef %0)
  %19 = sub nuw nsw i64 %.02432, %3
  %.not = icmp ult i64 %19, %3
  br i1 %.not, label %._crit_edge34, label %.preheader, !llvm.loop !11

._crit_edge34:                                    ; preds = %._crit_edge.us, %.preheader, %.preheader28
  %.024.lcssa = phi i64 [ %2, %.preheader28 ], [ %19, %.preheader ], [ %17, %._crit_edge.us ]
  ret i64 %.024.lcssa
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @BitInterleave(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @KeccakF1600(ptr noundef) local_unnamed_addr #0

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 = { noreturn nounwind "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 = { noreturn 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass