; LLVM IR from ARMmbed/mbed-crypto :: library (poly1305)

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

; Function Attrs: nounwind uwtable
declare hidden void @poly1305_process(ptr noundef, i64 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_poly1305_finish(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %2
  br label %6

6:                                                ; preds = %5
  br label %7

7:                                                ; preds = %6
  br label %8

8:                                                ; preds = %7
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %9, i32 0, i32 4
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = icmp ugt i64 %11, 0
  br i1 %12, label %13, label %38

13:                                               ; preds = %8
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %16, i32 0, i32 4
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds [16 x i8], ptr %15, i64 0, i64 %18
  store i8 1, ptr %19, align 1, !tbaa !12
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %20, i32 0, i32 4
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = add i64 %22, 1
  store i64 %23, ptr %21, align 8, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %26, i32 0, i32 4
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 %28
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %30, i32 0, i32 4
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = sub i64 16, %32
  call void @llvm.memset.p0.i64(ptr align 1 %29, i8 0, i64 %33, i1 false)
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.mbedtls_poly1305_context, ptr %35, i32 0, i32 3
  %37 = getelementptr inbounds [16 x i8], ptr %36, i64 0, i64 0
  call void @poly1305_process(ptr noundef %34, i64 noundef 1, ptr noundef %37, i32 noundef 0)
  br label %38

38:                                               ; preds = %13, %8
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  call void @poly1305_compute_mac(ptr noundef %39, ptr noundef %40)
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare hidden void @poly1305_compute_mac(ptr noundef, 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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 72}
!10 = !{!"mbedtls_poly1305_context", !7, i64 0, !7, i64 16, !7, i64 32, !7, i64 52, !11, i64 72}
!11 = !{!"long", !7, i64 0}
!12 = !{!7, !7, i64 0}


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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @mbedtls_poly1305_finish(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 72
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %12, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 52
  %7 = getelementptr inbounds [16 x i8], ptr %6, i64 0, i64 %4
  store i8 1, ptr %7, align 1, !tbaa !10
  %8 = load i64, ptr %3, align 8, !tbaa !5
  %9 = add i64 %8, 1
  store i64 %9, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds [16 x i8], ptr %6, i64 0, i64 %9
  %11 = sub i64 15, %8
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %10, i8 0, i64 %11, i1 false)
  tail call void @poly1305_process(ptr noundef nonnull %0, i64 noundef 1, ptr noundef nonnull %6, i32 noundef 0)
  br label %12

12:                                               ; preds = %5, %2
  tail call void @poly1305_compute_mac(ptr noundef nonnull %0, ptr noundef %1)
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare hidden void @poly1305_compute_mac(ptr noundef, 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 = { mustprogress 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, !9, i64 72}
!6 = !{!"mbedtls_poly1305_context", !7, i64 0, !7, i64 16, !7, i64 32, !7, i64 52, !9, i64 72}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass