; LLVM IR from thekyria/elabtsaot2 :: auxiliary/sha1/sha1.ll (ZN9elabtsaot4SHA15InputEPKhm)

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

%"class.elabtsaot::SHA1" = type <{ ptr, [5 x i32], i32, i32, [64 x i8], i32, i8, i8, [6 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9elabtsaot4SHA15InputEPKhm(ptr noundef nonnull align 8 dereferenceable(106) %0, ptr noundef %1, i64 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = load i64, ptr %6, align 8, !tbaa !9
  %9 = icmp ne i64 %8, 0
  br i1 %9, label %11, label %10

10:                                               ; preds = %3
  br label %75

11:                                               ; preds = %3
  %12 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 6
  %13 = load i8, ptr %12, align 8, !tbaa !11, !range !15, !noundef !16
  %14 = trunc i8 %13 to i1
  br i1 %14, label %19, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 7
  %17 = load i8, ptr %16, align 1, !tbaa !17, !range !15, !noundef !16
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %21

19:                                               ; preds = %15, %11
  %20 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 7
  store i8 1, ptr %20, align 1, !tbaa !17
  br label %75

21:                                               ; preds = %15
  br label %22

22:                                               ; preds = %72, %21
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = add i64 %23, -1
  store i64 %24, ptr %6, align 8, !tbaa !9
  %25 = icmp ne i64 %23, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 7
  %28 = load i8, ptr %27, align 1, !tbaa !17, !range !15, !noundef !16
  %29 = trunc i8 %28 to i1
  %30 = xor i1 %29, true
  br label %31

31:                                               ; preds = %26, %22
  %32 = phi i1 [ false, %22 ], [ %30, %26 ]
  br i1 %32, label %33, label %75

33:                                               ; preds = %31
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !18
  %36 = zext i8 %35 to i32
  %37 = and i32 %36, 255
  %38 = trunc i32 %37 to i8
  %39 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 4
  %40 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 5
  %41 = load i32, ptr %40, align 4, !tbaa !19
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !19
  %43 = sext i32 %41 to i64
  %44 = getelementptr inbounds [64 x i8], ptr %39, i64 0, i64 %43
  store i8 %38, ptr %44, align 1, !tbaa !18
  %45 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 2
  %46 = load i32, ptr %45, align 4, !tbaa !20
  %47 = add i32 %46, 8
  store i32 %47, ptr %45, align 4, !tbaa !20
  %48 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !20
  %50 = and i32 %49, -1
  store i32 %50, ptr %48, align 4, !tbaa !20
  %51 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !20
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %67

54:                                               ; preds = %33
  %55 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 3
  %56 = load i32, ptr %55, align 8, !tbaa !21
  %57 = add i32 %56, 1
  store i32 %57, ptr %55, align 8, !tbaa !21
  %58 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 3
  %59 = load i32, ptr %58, align 8, !tbaa !21
  %60 = and i32 %59, -1
  store i32 %60, ptr %58, align 8, !tbaa !21
  %61 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 3
  %62 = load i32, ptr %61, align 8, !tbaa !21
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %54
  %65 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 7
  store i8 1, ptr %65, align 1, !tbaa !17
  br label %66

66:                                               ; preds = %64, %54
  br label %67

67:                                               ; preds = %66, %33
  %68 = getelementptr inbounds %"class.elabtsaot::SHA1", ptr %7, i32 0, i32 5
  %69 = load i32, ptr %68, align 4, !tbaa !19
  %70 = icmp eq i32 %69, 64
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  call void @_ZN9elabtsaot4SHA119ProcessMessageBlockEv(ptr noundef nonnull align 8 dereferenceable(106) %7)
  br label %72

72:                                               ; preds = %71, %67
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %73, i32 1
  store ptr %74, ptr %5, align 8, !tbaa !5
  br label %22, !llvm.loop !22

75:                                               ; preds = %31, %19, %10
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9elabtsaot4SHA119ProcessMessageBlockEv(ptr noundef nonnull align 8 dereferenceable(106)) #0 align 2

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 104}
!12 = !{!"_ZTSN9elabtsaot4SHA1E", !7, i64 8, !13, i64 28, !13, i64 32, !7, i64 36, !13, i64 100, !14, i64 104, !14, i64 105}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !14, i64 105}
!18 = !{!7, !7, i64 0}
!19 = !{!12, !13, i64 100}
!20 = !{!12, !13, i64 28}
!21 = !{!12, !13, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9elabtsaot4SHA15InputEPKhm(ptr noundef nonnull align 8 dereferenceable(106) %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 align 2 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %.critedge, label %4

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 104
  %6 = load i8, ptr %5, align 8, !tbaa !5, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %16, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 105
  %10 = load i8, ptr %9, align 1, !tbaa !13, !range !11, !noundef !12
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %16, label %.preheader

.preheader:                                       ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 36
  %13 = getelementptr inbounds i8, ptr %0, i64 100
  %14 = getelementptr inbounds i8, ptr %0, i64 28
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  br label %18

16:                                               ; preds = %8, %4
  %17 = getelementptr inbounds i8, ptr %0, i64 105
  store i8 1, ptr %17, align 1, !tbaa !13
  br label %.critedge

18:                                               ; preds = %.preheader, %40
  %.in = phi i64 [ %2, %.preheader ], [ %19, %40 ]
  %.047 = phi ptr [ %1, %.preheader ], [ %41, %40 ]
  %19 = add i64 %.in, -1
  %20 = load i8, ptr %9, align 1, !tbaa !13, !range !11, !noundef !12
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %.critedge, label %22

22:                                               ; preds = %18
  %23 = load i8, ptr %.047, align 1, !tbaa !14
  %24 = load i32, ptr %13, align 4, !tbaa !15
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %13, align 4, !tbaa !15
  %26 = sext i32 %24 to i64
  %27 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 %26
  store i8 %23, ptr %27, align 1, !tbaa !14
  %28 = load i32, ptr %14, align 4, !tbaa !16
  %29 = add i32 %28, 8
  store i32 %29, ptr %14, align 4, !tbaa !16
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %36

31:                                               ; preds = %22
  %32 = load i32, ptr %15, align 8, !tbaa !17
  %33 = add i32 %32, 1
  store i32 %33, ptr %15, align 8, !tbaa !17
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i8 1, ptr %9, align 1, !tbaa !13
  br label %36

36:                                               ; preds = %31, %35, %22
  %37 = load i32, ptr %13, align 4, !tbaa !15
  %38 = icmp eq i32 %37, 64
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  tail call void @_ZN9elabtsaot4SHA119ProcessMessageBlockEv(ptr noundef nonnull align 8 dereferenceable(106) %0)
  br label %40

40:                                               ; preds = %39, %36
  %41 = getelementptr inbounds i8, ptr %.047, i64 1
  %.not6 = icmp eq i64 %19, 0
  br i1 %.not6, label %.critedge, label %18, !llvm.loop !18

.critedge:                                        ; preds = %40, %18, %3, %16
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9elabtsaot4SHA119ProcessMessageBlockEv(ptr noundef nonnull align 8 dereferenceable(106)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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, !10, i64 104}
!6 = !{!"_ZTSN9elabtsaot4SHA1E", !7, i64 8, !9, i64 28, !9, i64 32, !7, i64 36, !9, i64 100, !10, i64 104, !10, i64 105}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !10, i64 105}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !9, i64 100}
!16 = !{!6, !9, i64 28}
!17 = !{!6, !9, i64 32}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass