; 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_squeeze = external hidden unnamed_addr constant [73 x i8], align 1

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

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

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

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

21:                                               ; preds = %5
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = urem i64 %22, 8
  %24 = icmp eq i64 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  br label %27

26:                                               ; preds = %21, %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1109, ptr noundef @__PRETTY_FUNCTION__.SHA3_squeeze) #4
  unreachable

27:                                               ; preds = %25
  br label %28

28:                                               ; preds = %120, %27
  %29 = load i64, ptr %8, align 8, !tbaa !9
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %121

31:                                               ; preds = %28
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  call void @KeccakF1600(ptr noundef %35)
  br label %36

36:                                               ; preds = %34, %31
  store i32 1, ptr %10, align 4, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %117, %36
  %38 = load i64, ptr %12, align 8, !tbaa !9
  %39 = load i64, ptr %13, align 8, !tbaa !9
  %40 = icmp ult i64 %38, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %37
  %42 = load i64, ptr %8, align 8, !tbaa !9
  %43 = icmp ne i64 %42, 0
  br label %44

44:                                               ; preds = %41, %37
  %45 = phi i1 [ false, %37 ], [ %43, %41 ]
  br i1 %45, label %46, label %120

46:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load i64, ptr %12, align 8, !tbaa !9
  %49 = getelementptr inbounds i64, ptr %47, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = call i64 @BitDeinterleave(i64 noundef %50)
  store i64 %51, ptr %14, align 8, !tbaa !9
  %52 = load i64, ptr %8, align 8, !tbaa !9
  %53 = icmp ult i64 %52, 8
  br i1 %53, label %54, label %70

54:                                               ; preds = %46
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %66, %54
  %56 = load i64, ptr %12, align 8, !tbaa !9
  %57 = load i64, ptr %8, align 8, !tbaa !9
  %58 = icmp ult i64 %56, %57
  br i1 %58, label %59, label %69

59:                                               ; preds = %55
  %60 = load i64, ptr %14, align 8, !tbaa !9
  %61 = trunc i64 %60 to i8
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i32 1
  store ptr %63, ptr %7, align 8, !tbaa !5
  store i8 %61, ptr %62, align 1, !tbaa !13
  %64 = load i64, ptr %14, align 8, !tbaa !9
  %65 = lshr i64 %64, 8
  store i64 %65, ptr %14, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %59
  %67 = load i64, ptr %12, align 8, !tbaa !9
  %68 = add i64 %67, 1
  store i64 %68, ptr %12, align 8, !tbaa !9
  br label %55, !llvm.loop !14

69:                                               ; preds = %55
  store i32 1, ptr %15, align 4
  br label %114

70:                                               ; preds = %46
  %71 = load i64, ptr %14, align 8, !tbaa !9
  %72 = trunc i64 %71 to i8
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i64 0
  store i8 %72, ptr %74, align 1, !tbaa !13
  %75 = load i64, ptr %14, align 8, !tbaa !9
  %76 = lshr i64 %75, 8
  %77 = trunc i64 %76 to i8
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %78, i64 1
  store i8 %77, ptr %79, align 1, !tbaa !13
  %80 = load i64, ptr %14, align 8, !tbaa !9
  %81 = lshr i64 %80, 16
  %82 = trunc i64 %81 to i8
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 2
  store i8 %82, ptr %84, align 1, !tbaa !13
  %85 = load i64, ptr %14, align 8, !tbaa !9
  %86 = lshr i64 %85, 24
  %87 = trunc i64 %86 to i8
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %88, i64 3
  store i8 %87, ptr %89, align 1, !tbaa !13
  %90 = load i64, ptr %14, align 8, !tbaa !9
  %91 = lshr i64 %90, 32
  %92 = trunc i64 %91 to i8
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i64 4
  store i8 %92, ptr %94, align 1, !tbaa !13
  %95 = load i64, ptr %14, align 8, !tbaa !9
  %96 = lshr i64 %95, 40
  %97 = trunc i64 %96 to i8
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %98, i64 5
  store i8 %97, ptr %99, align 1, !tbaa !13
  %100 = load i64, ptr %14, align 8, !tbaa !9
  %101 = lshr i64 %100, 48
  %102 = trunc i64 %101 to i8
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = getelementptr inbounds i8, ptr %103, i64 6
  store i8 %102, ptr %104, align 1, !tbaa !13
  %105 = load i64, ptr %14, align 8, !tbaa !9
  %106 = lshr i64 %105, 56
  %107 = trunc i64 %106 to i8
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = getelementptr inbounds i8, ptr %108, i64 7
  store i8 %107, ptr %109, align 1, !tbaa !13
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds i8, ptr %110, i64 8
  store ptr %111, ptr %7, align 8, !tbaa !5
  %112 = load i64, ptr %8, align 8, !tbaa !9
  %113 = sub i64 %112, 8
  store i64 %113, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %15, align 4
  br label %114

114:                                              ; preds = %70, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %115 = load i32, ptr %15, align 4
  switch i32 %115, label %122 [
    i32 0, label %116
  ]

116:                                              ; preds = %114
  br label %117

117:                                              ; preds = %116
  %118 = load i64, ptr %12, align 8, !tbaa !9
  %119 = add i64 %118, 1
  store i64 %119, ptr %12, align 8, !tbaa !9
  br label %37, !llvm.loop !16

120:                                              ; preds = %44
  br label %28, !llvm.loop !17

121:                                              ; preds = %28
  store i32 0, ptr %15, align 4
  br label %122

122:                                              ; preds = %121, %114
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %123 = load i32, ptr %15, align 4
  switch i32 %123, label %125 [
    i32 0, label %124
    i32 1, label %124
  ]

124:                                              ; preds = %122, %122
  ret void

125:                                              ; preds = %122
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden i64 @BitDeinterleave(i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


; 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_squeeze = external hidden unnamed_addr constant [73 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @SHA3_squeeze(ptr noundef %0, ptr nocapture noundef writeonly %1, i64 noundef %2, i64 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = lshr i64 %3, 3
  %7 = icmp ult i64 %3, 200
  %8 = and i64 %3, 7
  %9 = icmp eq i64 %8, 0
  %or.cond = and i1 %7, %9
  br i1 %or.cond, label %.preheader57, label %44

.preheader57:                                     ; preds = %5
  %.not68 = icmp eq i64 %2, 0
  br i1 %.not68, label %.loopexit56, label %.lr.ph72

.lr.ph72:                                         ; preds = %.preheader57
  %.not = icmp ult i64 %3, 8
  %.not48.peel = icmp eq i32 %4, 0
  br i1 %.not, label %.lr.ph72.split.split.preheader, label %.lr.ph72.split.us

.lr.ph72.split.split.preheader:                   ; preds = %.lr.ph72
  br i1 %.not48.peel, label %.loopexit.preheader, label %10

.loopexit.preheader:                              ; preds = %10, %.lr.ph72.split.split.preheader
  br label %.loopexit

10:                                               ; preds = %.lr.ph72.split.split.preheader
  tail call void @KeccakF1600(ptr noundef %0)
  br label %.loopexit.preheader

.lr.ph72.split.us:                                ; preds = %.lr.ph72, %..loopexit_crit_edge.us
  %.03971.us = phi ptr [ %38, %..loopexit_crit_edge.us ], [ %1, %.lr.ph72 ]
  %.04370.us = phi i64 [ %39, %..loopexit_crit_edge.us ], [ %2, %.lr.ph72 ]
  %.04669.us = phi i1 [ false, %..loopexit_crit_edge.us ], [ %.not48.peel, %.lr.ph72 ]
  br i1 %.04669.us, label %.lr.ph.us.preheader, label %11

11:                                               ; preds = %.lr.ph72.split.us
  tail call void @KeccakF1600(ptr noundef %0)
  br label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %11, %.lr.ph72.split.us
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.thread.us
  %.166.us = phi ptr [ %38, %.thread.us ], [ %.03971.us, %.lr.ph.us.preheader ]
  %.04065.us = phi i64 [ %40, %.thread.us ], [ 0, %.lr.ph.us.preheader ]
  %.14464.us = phi i64 [ %39, %.thread.us ], [ %.04370.us, %.lr.ph.us.preheader ]
  %12 = getelementptr inbounds i64, ptr %0, i64 %.04065.us
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = tail call i64 @BitDeinterleave(i64 noundef %13)
  %15 = icmp ugt i64 %.14464.us, 7
  br i1 %15, label %.thread.us, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.lr.ph.us
  %umax = tail call i64 @llvm.umax.i64(i64 %.14464.us, i64 1)
  br label %.preheader.us.epil

.thread.us:                                       ; preds = %.lr.ph.us
  %16 = trunc i64 %14 to i8
  store i8 %16, ptr %.166.us, align 1, !tbaa !9
  %17 = lshr i64 %14, 8
  %18 = trunc i64 %17 to i8
  %19 = getelementptr inbounds i8, ptr %.166.us, i64 1
  store i8 %18, ptr %19, align 1, !tbaa !9
  %20 = lshr i64 %14, 16
  %21 = trunc i64 %20 to i8
  %22 = getelementptr inbounds i8, ptr %.166.us, i64 2
  store i8 %21, ptr %22, align 1, !tbaa !9
  %23 = lshr i64 %14, 24
  %24 = trunc i64 %23 to i8
  %25 = getelementptr inbounds i8, ptr %.166.us, i64 3
  store i8 %24, ptr %25, align 1, !tbaa !9
  %26 = lshr i64 %14, 32
  %27 = trunc i64 %26 to i8
  %28 = getelementptr inbounds i8, ptr %.166.us, i64 4
  store i8 %27, ptr %28, align 1, !tbaa !9
  %29 = lshr i64 %14, 40
  %30 = trunc i64 %29 to i8
  %31 = getelementptr inbounds i8, ptr %.166.us, i64 5
  store i8 %30, ptr %31, align 1, !tbaa !9
  %32 = lshr i64 %14, 48
  %33 = trunc i64 %32 to i8
  %34 = getelementptr inbounds i8, ptr %.166.us, i64 6
  store i8 %33, ptr %34, align 1, !tbaa !9
  %35 = lshr i64 %14, 56
  %36 = trunc nuw i64 %35 to i8
  %37 = getelementptr inbounds i8, ptr %.166.us, i64 7
  store i8 %36, ptr %37, align 1, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %.166.us, i64 8
  %39 = add i64 %.14464.us, -8
  %40 = add nuw nsw i64 %.04065.us, 1
  %41 = icmp ult i64 %40, %6
  %42 = icmp ne i64 %39, 0
  %43 = select i1 %41, i1 %42, i1 false
  br i1 %43, label %.lr.ph.us, label %..loopexit_crit_edge.us, !llvm.loop !10

..loopexit_crit_edge.us:                          ; preds = %.thread.us
  %.not.us = icmp eq i64 %39, 0
  br i1 %.not.us, label %.loopexit56, label %.lr.ph72.split.us, !llvm.loop !12

44:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1109, ptr noundef nonnull @__PRETTY_FUNCTION__.SHA3_squeeze) #3
  unreachable

.loopexit:                                        ; preds = %.loopexit.preheader, %.loopexit
  tail call void @KeccakF1600(ptr noundef %0)
  br label %.loopexit, !llvm.loop !13

.preheader.us.epil:                               ; preds = %.preheader.us.epil, %.preheader.us.preheader
  %.03863.us.epil = phi i64 [ %47, %.preheader.us.epil ], [ %14, %.preheader.us.preheader ]
  %.262.us.epil = phi ptr [ %46, %.preheader.us.epil ], [ %.166.us, %.preheader.us.preheader ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.us.epil ], [ 0, %.preheader.us.preheader ]
  %45 = trunc i64 %.03863.us.epil to i8
  %46 = getelementptr inbounds i8, ptr %.262.us.epil, i64 1
  store i8 %45, ptr %.262.us.epil, align 1, !tbaa !9
  %47 = lshr i64 %.03863.us.epil, 8
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %umax
  br i1 %epil.iter.cmp.not, label %.loopexit56, label %.preheader.us.epil, !llvm.loop !15

.loopexit56:                                      ; preds = %..loopexit_crit_edge.us, %.preheader.us.epil, %.preheader57
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @BitDeinterleave(i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #2

attributes #0 = { 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 #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 nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.peeled.count", i32 1}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}


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