; LLVM IR from philanc/luazen :: src/mono (monocypher)

; 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.crypto_poly1305_ctx = type { [4 x i32], [5 x i32], [16 x i8], [4 x i32], i64 }

; 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 @load32_le_buf(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @crypto_poly1305_init(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %17, %2
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = icmp ult i64 %9, 5
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %20

12:                                               ; preds = %8
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.crypto_poly1305_ctx, ptr %13, i32 0, i32 1
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds [5 x i32], ptr %14, i64 0, i64 %15
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %12
  %18 = load i64, ptr %5, align 8, !tbaa !9
  %19 = add i64 %18, 1
  store i64 %19, ptr %5, align 8, !tbaa !9
  br label %8, !llvm.loop !13

20:                                               ; preds = %11
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.crypto_poly1305_ctx, ptr %21, i32 0, i32 4
  store i64 0, ptr %22, align 8, !tbaa !15
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.crypto_poly1305_ctx, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds [4 x i32], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  call void @load32_le_buf(ptr noundef %25, ptr noundef %26, i64 noundef 4)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.crypto_poly1305_ctx, ptr %27, i32 0, i32 3
  %29 = getelementptr inbounds [4 x i32], ptr %28, i64 0, i64 0
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  call void @load32_le_buf(ptr noundef %29, ptr noundef %31, i64 noundef 4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %43, %20
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = icmp ult i64 %33, 1
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %46

36:                                               ; preds = %32
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.crypto_poly1305_ctx, ptr %37, i32 0, i32 0
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = getelementptr inbounds [4 x i32], ptr %38, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = and i32 %41, 268435455
  store i32 %42, ptr %40, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %36
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !9
  br label %32, !llvm.loop !17

46:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 1, ptr %7, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %58, %46
  %48 = load i64, ptr %7, align 8, !tbaa !9
  %49 = icmp ult i64 %48, 4
  br i1 %49, label %51, label %50

50:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %61

51:                                               ; preds = %47
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.crypto_poly1305_ctx, ptr %52, i32 0, i32 0
  %54 = load i64, ptr %7, align 8, !tbaa !9
  %55 = getelementptr inbounds [4 x i32], ptr %53, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = and i32 %56, 268435452
  store i32 %57, ptr %55, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %51
  %59 = load i64, ptr %7, align 8, !tbaa !9
  %60 = add i64 %59, 1
  store i64 %60, ptr %7, align 8, !tbaa !9
  br label %47, !llvm.loop !18

61:                                               ; preds = %50
  ret void
}

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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 72}
!16 = !{!"", !7, i64 0, !7, i64 16, !7, i64 36, !7, i64 52, !10, i64 72}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; 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 @load32_le_buf(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @crypto_poly1305_init(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
.critedge:
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %2, i8 0, i64 20, i1 false), !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 72
  store i64 0, ptr %3, align 8, !tbaa !9
  tail call void @load32_le_buf(ptr noundef %0, ptr noundef %1, i64 noundef 4)
  %4 = getelementptr inbounds i8, ptr %0, i64 52
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  tail call void @load32_le_buf(ptr noundef nonnull %4, ptr noundef nonnull %5, i64 noundef 4)
  %6 = load <4 x i32>, ptr %0, align 4, !tbaa !5
  %7 = and <4 x i32> %6, <i32 268435455, i32 268435452, i32 268435452, i32 268435452>
  store <4 x i32> %7, ptr %0, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 72}
!10 = !{!"", !7, i64 0, !7, i64 16, !7, i64 36, !7, i64 52, !11, i64 72}
!11 = !{!"long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass