; LLVM IR from aws/s2n-tls :: tests/unit (s2n_server_renegotiation_info_test)

; 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.s2n_result = type { i32 }
%struct.s2n_stuffer_reservation = type { ptr, i32, i8 }

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_server_renegotiation_info_extension_write(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) #0 {
  %5 = alloca %struct.s2n_result, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca %struct.s2n_stuffer_reservation, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i8 %3, ptr %9, align 1, !tbaa !9
  br label %12

12:                                               ; preds = %4
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i8, ptr %9, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = mul nsw i32 %15, 3
  %17 = call i32 @s2n_stuffer_growable_alloc(ptr noundef %13, i32 noundef %16)
  %18 = icmp sgt i32 %17, -1
  br i1 %18, label %21, label %19

19:                                               ; preds = %12
  %20 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %20, align 4, !tbaa !10
  br label %66

21:                                               ; preds = %12
  br label %22

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 16, i1 false)
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call i32 @s2n_stuffer_reserve_uint8(ptr noundef %24, ptr noundef %10)
  %26 = icmp sgt i32 %25, -1
  br i1 %26, label %29, label %27

27:                                               ; preds = %23
  %28 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %28, align 4, !tbaa !10
  store i32 1, ptr %11, align 4
  br label %65

29:                                               ; preds = %23
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i8, ptr %9, align 1, !tbaa !9
  %36 = zext i8 %35 to i32
  %37 = call i32 @s2n_stuffer_write_bytes(ptr noundef %33, ptr noundef %34, i32 noundef %36)
  %38 = icmp sgt i32 %37, -1
  br i1 %38, label %41, label %39

39:                                               ; preds = %32
  %40 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %40, align 4, !tbaa !10
  store i32 1, ptr %11, align 4
  br label %65

41:                                               ; preds = %32
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i8, ptr %9, align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = call i32 @s2n_stuffer_write_bytes(ptr noundef %45, ptr noundef %46, i32 noundef %48)
  %50 = icmp sgt i32 %49, -1
  br i1 %50, label %53, label %51

51:                                               ; preds = %44
  %52 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %52, align 4, !tbaa !10
  store i32 1, ptr %11, align 4
  br label %65

53:                                               ; preds = %44
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  %57 = call i32 @s2n_stuffer_write_vector_size(ptr noundef %10)
  %58 = icmp sgt i32 %57, -1
  br i1 %58, label %61, label %59

59:                                               ; preds = %56
  %60 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 -1, ptr %60, align 4, !tbaa !10
  store i32 1, ptr %11, align 4
  br label %65

61:                                               ; preds = %56
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  %64 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  store i32 0, ptr %64, align 4, !tbaa !10
  store i32 1, ptr %11, align 4
  br label %65

65:                                               ; preds = %63, %59, %51, %39, %27
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  br label %66

66:                                               ; preds = %65, %19
  %67 = getelementptr inbounds %struct.s2n_result, ptr %5, i32 0, i32 0
  %68 = load i32, ptr %67, align 4
  ret i32 %68
}

declare i32 @s2n_stuffer_growable_alloc(ptr noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

declare i32 @s2n_stuffer_reserve_uint8(ptr noundef, ptr noundef) #1

declare i32 @s2n_stuffer_write_bytes(ptr noundef, ptr noundef, i32 noundef) #1

declare i32 @s2n_stuffer_write_vector_size(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"", !12, i64 0}
!12 = !{!"int", !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"

%struct.s2n_stuffer_reservation = type { ptr, i32, i8 }

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_server_renegotiation_info_extension_write(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = alloca %struct.s2n_stuffer_reservation, align 8
  %6 = zext i8 %3 to i32
  %7 = mul nuw nsw i32 %6, 3
  %8 = tail call i32 @s2n_stuffer_growable_alloc(ptr noundef %0, i32 noundef %7) #4
  %9 = icmp sgt i32 %8, -1
  br i1 %9, label %10, label %22

10:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  %11 = call i32 @s2n_stuffer_reserve_uint8(ptr noundef %0, ptr noundef nonnull %5) #4
  %12 = icmp sgt i32 %11, -1
  br i1 %12, label %13, label %21

13:                                               ; preds = %10
  %14 = call i32 @s2n_stuffer_write_bytes(ptr noundef %0, ptr noundef %1, i32 noundef %6) #4
  %15 = icmp sgt i32 %14, -1
  br i1 %15, label %16, label %21

16:                                               ; preds = %13
  %17 = call i32 @s2n_stuffer_write_bytes(ptr noundef %0, ptr noundef %2, i32 noundef %6) #4
  %18 = icmp sgt i32 %17, -1
  br i1 %18, label %19, label %21

19:                                               ; preds = %16
  %20 = call i32 @s2n_stuffer_write_vector_size(ptr noundef nonnull %5) #4
  %.lobit = ashr i32 %20, 31
  br label %21

21:                                               ; preds = %19, %16, %13, %10
  %.sroa.0.0 = phi i32 [ -1, %10 ], [ -1, %13 ], [ -1, %16 ], [ %.lobit, %19 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  br label %22

22:                                               ; preds = %4, %21
  %.sroa.0.1 = phi i32 [ %.sroa.0.0, %21 ], [ -1, %4 ]
  ret i32 %.sroa.0.1
}

declare i32 @s2n_stuffer_growable_alloc(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

declare i32 @s2n_stuffer_reserve_uint8(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @s2n_stuffer_write_bytes(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @s2n_stuffer_write_vector_size(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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)"}


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