; LLVM IR from godzilla-foundation/godzilla-community :: core/deps/nanomsg-1.1.5/src/transports/ws (sha1)

; 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.nn_sha1 = type { [16 x i32], [5 x i32], i32, i8, 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden void @nn_sha1_add(ptr noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @nn_sha1_result(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  call void @nn_sha1_add(ptr noundef %4, i8 noundef zeroext -128)
  br label %5

5:                                                ; preds = %11, %1
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.nn_sha1, ptr %6, i32 0, i32 3
  %8 = load i8, ptr %7, align 4, !tbaa !9
  %9 = zext i8 %8 to i32
  %10 = icmp ne i32 %9, 56
  br i1 %10, label %11, label %13

11:                                               ; preds = %5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  call void @nn_sha1_add(ptr noundef %12, i8 noundef zeroext 0)
  br label %5, !llvm.loop !12

13:                                               ; preds = %5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  call void @nn_sha1_add(ptr noundef %14, i8 noundef zeroext 0)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  call void @nn_sha1_add(ptr noundef %15, i8 noundef zeroext 0)
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @nn_sha1_add(ptr noundef %16, i8 noundef zeroext 0)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.nn_sha1, ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = lshr i32 %20, 29
  %22 = trunc i32 %21 to i8
  call void @nn_sha1_add(ptr noundef %17, i8 noundef zeroext %22)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nn_sha1, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = lshr i32 %26, 21
  %28 = trunc i32 %27 to i8
  call void @nn_sha1_add(ptr noundef %23, i8 noundef zeroext %28)
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.nn_sha1, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = lshr i32 %32, 13
  %34 = trunc i32 %33 to i8
  call void @nn_sha1_add(ptr noundef %29, i8 noundef zeroext %34)
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nn_sha1, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !14
  %39 = lshr i32 %38, 5
  %40 = trunc i32 %39 to i8
  call void @nn_sha1_add(ptr noundef %35, i8 noundef zeroext %40)
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.nn_sha1, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 4, !tbaa !14
  %45 = shl i32 %44, 3
  %46 = trunc i32 %45 to i8
  call void @nn_sha1_add(ptr noundef %41, i8 noundef zeroext %46)
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nn_sha1, ptr %47, i32 0, i32 4
  %49 = load i8, ptr %48, align 1, !tbaa !15
  %50 = icmp ne i8 %49, 0
  br i1 %50, label %51, label %100

51:                                               ; preds = %13
  store i32 0, ptr %3, align 4, !tbaa !16
  br label %52

52:                                               ; preds = %96, %51
  %53 = load i32, ptr %3, align 4, !tbaa !16
  %54 = icmp slt i32 %53, 5
  br i1 %54, label %55, label %99

55:                                               ; preds = %52
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.nn_sha1, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %3, align 4, !tbaa !16
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [5 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !16
  %62 = shl i32 %61, 24
  %63 = and i32 %62, -16777216
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.nn_sha1, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %3, align 4, !tbaa !16
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [5 x i32], ptr %65, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !16
  %70 = shl i32 %69, 8
  %71 = and i32 %70, 16711680
  %72 = or i32 %63, %71
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.nn_sha1, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %3, align 4, !tbaa !16
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [5 x i32], ptr %74, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !16
  %79 = lshr i32 %78, 8
  %80 = and i32 %79, 65280
  %81 = or i32 %72, %80
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.nn_sha1, ptr %82, i32 0, i32 1
  %84 = load i32, ptr %3, align 4, !tbaa !16
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [5 x i32], ptr %83, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !16
  %88 = lshr i32 %87, 24
  %89 = and i32 %88, 255
  %90 = or i32 %81, %89
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.nn_sha1, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %3, align 4, !tbaa !16
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [5 x i32], ptr %92, i64 0, i64 %94
  store i32 %90, ptr %95, align 4, !tbaa !16
  br label %96

96:                                               ; preds = %55
  %97 = load i32, ptr %3, align 4, !tbaa !16
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %3, align 4, !tbaa !16
  br label %52, !llvm.loop !17

99:                                               ; preds = %52
  br label %100

100:                                              ; preds = %99, %13
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.nn_sha1, ptr %101, i32 0, i32 1
  %103 = getelementptr inbounds [5 x i32], ptr %102, i64 0, i64 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret ptr %103
}

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 = { 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, !7, i64 88}
!10 = !{!"nn_sha1", !7, i64 0, !7, i64 64, !11, i64 84, !7, i64 88, !7, i64 89}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !11, i64 84}
!15 = !{!10, !7, i64 89}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !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"

; Function Attrs: nounwind uwtable
declare hidden void @nn_sha1_add(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local nonnull ptr @nn_sha1_result(ptr noundef %0) local_unnamed_addr #0 {
  tail call void @nn_sha1_add(ptr noundef %0, i8 noundef zeroext -128)
  %2 = getelementptr inbounds i8, ptr %0, i64 88
  %3 = load i8, ptr %2, align 4, !tbaa !5
  %.not30 = icmp eq i8 %3, 56
  br i1 %.not30, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext 0)
  %4 = load i8, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i8 %4, 56
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %1
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext 0)
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext 0)
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext 0)
  %5 = getelementptr inbounds i8, ptr %0, i64 84
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = lshr i32 %6, 29
  %8 = trunc nuw nsw i32 %7 to i8
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext %8)
  %9 = load i32, ptr %5, align 4, !tbaa !12
  %10 = lshr i32 %9, 21
  %11 = trunc i32 %10 to i8
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext %11)
  %12 = load i32, ptr %5, align 4, !tbaa !12
  %13 = lshr i32 %12, 13
  %14 = trunc i32 %13 to i8
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext %14)
  %15 = load i32, ptr %5, align 4, !tbaa !12
  %16 = lshr i32 %15, 5
  %17 = trunc i32 %16 to i8
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext %17)
  %18 = load i32, ptr %5, align 4, !tbaa !12
  %.tr = trunc i32 %18 to i8
  %19 = shl i8 %.tr, 3
  tail call void @nn_sha1_add(ptr noundef nonnull %0, i8 noundef zeroext %19)
  %20 = getelementptr inbounds i8, ptr %0, i64 89
  %21 = load i8, ptr %20, align 1, !tbaa !13
  %.not29 = icmp eq i8 %21, 0
  br i1 %.not29, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %22 = getelementptr inbounds i8, ptr %0, i64 64
  %23 = load <4 x i32>, ptr %22, align 4, !tbaa !14
  %24 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %23)
  store <4 x i32> %24, ptr %22, align 4, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %0, i64 80
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = tail call i32 @llvm.bswap.i32(i32 %26)
  store i32 %27, ptr %25, align 4, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %._crit_edge
  %28 = getelementptr inbounds i8, ptr %0, i64 64
  ret ptr %28
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.bswap.i32(i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>) #1

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 speculatable willreturn memory(none) }

!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 88}
!6 = !{!"nn_sha1", !7, i64 0, !7, i64 64, !9, i64 84, !7, i64 88, !7, i64 89}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!6, !9, i64 84}
!13 = !{!6, !7, i64 89}
!14 = !{!9, !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass