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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_gcm_update(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_gcm_finish(ptr noundef, ptr noundef, i64 noundef) #1

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

26:                                               ; preds = %11
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = load i32, ptr %14, align 4, !tbaa !9
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  %47 = load i64, ptr %17, align 8, !tbaa !11
  %48 = load ptr, ptr %18, align 8, !tbaa !5
  %49 = load i64, ptr %19, align 8, !tbaa !11
  %50 = call i32 @mbedtls_gcm_starts(ptr noundef %44, i32 noundef %45, ptr noundef %46, i64 noundef %47, ptr noundef %48, i64 noundef %49)
  store i32 %50, ptr %24, align 4, !tbaa !9
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %54

52:                                               ; preds = %43
  %53 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %53, ptr %12, align 4
  store i32 1, ptr %25, align 4
  br label %72

54:                                               ; preds = %43
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load i64, ptr %15, align 8, !tbaa !11
  %57 = load ptr, ptr %20, align 8, !tbaa !5
  %58 = load ptr, ptr %21, align 8, !tbaa !5
  %59 = call i32 @mbedtls_gcm_update(ptr noundef %55, i64 noundef %56, ptr noundef %57, ptr noundef %58)
  store i32 %59, ptr %24, align 4, !tbaa !9
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %63

61:                                               ; preds = %54
  %62 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %62, ptr %12, align 4
  store i32 1, ptr %25, align 4
  br label %72

63:                                               ; preds = %54
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load ptr, ptr %23, align 8, !tbaa !5
  %66 = load i64, ptr %22, align 8, !tbaa !11
  %67 = call i32 @mbedtls_gcm_finish(ptr noundef %64, ptr noundef %65, i64 noundef %66)
  store i32 %67, ptr %24, align 4, !tbaa !9
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %63
  %70 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %70, ptr %12, align 4
  store i32 1, ptr %25, align 4
  br label %72

71:                                               ; preds = %63
  store i32 0, ptr %12, align 4
  store i32 1, ptr %25, align 4
  br label %72

72:                                               ; preds = %71, %69, %61, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #2
  %73 = load i32, ptr %12, align 4
  ret i32 %73
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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 dso_local i32 @mbedtls_gcm_starts(ptr noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_gcm_update(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_gcm_finish(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_gcm_crypt_and_tag(ptr noundef %0, i32 noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10) local_unnamed_addr #0 {
  %12 = tail call i32 @mbedtls_gcm_starts(ptr noundef %0, i32 noundef %1, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %17

13:                                               ; preds = %11
  %14 = tail call i32 @mbedtls_gcm_update(ptr noundef %0, i64 noundef %2, ptr noundef %7, ptr noundef %8)
  %.not19 = icmp eq i32 %14, 0
  br i1 %.not19, label %15, label %17

15:                                               ; preds = %13
  %16 = tail call i32 @mbedtls_gcm_finish(ptr noundef %0, ptr noundef %10, i64 noundef %9)
  br label %17

17:                                               ; preds = %15, %13, %11
  %.0 = phi i32 [ %12, %11 ], [ %14, %13 ], [ %16, %15 ]
  ret i32 %.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" }

!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)"}


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