; LLVM IR from aws/s2n-tls :: tests/fuzz (s2n_openssl_diff_pem_parsing_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_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

; Function Attrs: nounwind uwtable
define dso_local i32 @s2n_fuzz_test(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca %struct.s2n_stuffer, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 40, ptr %6) #4
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 40, i1 false)
  br label %10

10:                                               ; preds = %2
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = add i64 %11, 1
  %13 = trunc i64 %12 to i32
  %14 = call i32 @s2n_stuffer_alloc(ptr noundef %6, i32 noundef %13)
  %15 = icmp sgt i32 %14, -1
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %62

17:                                               ; preds = %10
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = trunc i64 %22 to i32
  %24 = call i32 @s2n_stuffer_write_bytes(ptr noundef %6, ptr noundef %21, i32 noundef %23)
  %25 = icmp sgt i32 %24, -1
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %62

27:                                               ; preds = %20
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = getelementptr inbounds %struct.s2n_stuffer, ptr %6, i32 0, i32 0
  %31 = getelementptr inbounds %struct.s2n_blob, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  store i8 0, ptr %34, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %35 = call i32 @openssl_parse_cert_chain(ptr noundef %6)
  %36 = trunc i32 %35 to i8
  store i8 %36, ptr %8, align 1, !tbaa !15
  br label %37

37:                                               ; preds = %29
  %38 = call i32 @s2n_stuffer_reread(ptr noundef %6)
  %39 = icmp sgt i32 %38, -1
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %61

41:                                               ; preds = %37
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %44 = call i32 @s2n_parse_cert_chain(ptr noundef %6)
  %45 = trunc i32 %44 to i8
  store i8 %45, ptr %9, align 1, !tbaa !15
  br label %46

46:                                               ; preds = %43
  %47 = call i32 @s2n_stuffer_free(ptr noundef %6)
  %48 = icmp sgt i32 %47, -1
  br i1 %48, label %50, label %49

49:                                               ; preds = %46
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %60

50:                                               ; preds = %46
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  %53 = load i8, ptr %8, align 1, !tbaa !15
  %54 = zext i8 %53 to i32
  %55 = load i8, ptr %9, align 1, !tbaa !15
  %56 = zext i8 %55 to i32
  %57 = icmp sgt i32 %54, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %52
  br label %59

59:                                               ; preds = %58, %52
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %60

60:                                               ; preds = %59, %49
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %61

61:                                               ; preds = %60, %40
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %62

62:                                               ; preds = %61, %26, %16
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #4
  %63 = load i32, ptr %3, align 4
  ret i32 %63
}

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

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

declare i32 @s2n_stuffer_alloc(ptr noundef, i32 noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @openssl_parse_cert_chain(ptr noundef) #0

declare i32 @s2n_stuffer_reread(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_parse_cert_chain(ptr noundef) #0

declare i32 @s2n_stuffer_free(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"s2n_stuffer", !13, i64 0, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 36, !14, i64 36}
!13 = !{!"s2n_blob", !6, i64 0, !14, i64 8, !14, i64 12, !14, i64 16}
!14 = !{!"int", !7, i64 0}
!15 = !{!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"

%struct.s2n_stuffer = type { %struct.s2n_blob, i32, i32, i32, i8 }
%struct.s2n_blob = type { ptr, i32, i32, i8 }

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_fuzz_test(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.s2n_stuffer, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %3, i8 0, i64 40, i1 false)
  %4 = trunc i64 %1 to i32
  %5 = add i32 %4, 1
  %6 = call i32 @s2n_stuffer_alloc(ptr noundef nonnull %3, i32 noundef %5) #4
  %7 = icmp sgt i32 %6, -1
  br i1 %7, label %8, label %20

8:                                                ; preds = %2
  %9 = call i32 @s2n_stuffer_write_bytes(ptr noundef nonnull %3, ptr noundef %0, i32 noundef %4) #4
  %10 = icmp sgt i32 %9, -1
  br i1 %10, label %11, label %20

11:                                               ; preds = %8
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 %1
  store i8 0, ptr %13, align 1, !tbaa !12
  %14 = call i32 @openssl_parse_cert_chain(ptr noundef nonnull %3)
  %15 = call i32 @s2n_stuffer_reread(ptr noundef nonnull %3) #4
  %16 = icmp sgt i32 %15, -1
  br i1 %16, label %17, label %20

17:                                               ; preds = %11
  %18 = call i32 @s2n_parse_cert_chain(ptr noundef nonnull %3)
  %19 = call i32 @s2n_stuffer_free(ptr noundef nonnull %3) #4
  %.lobit = ashr i32 %19, 31
  br label %20

20:                                               ; preds = %17, %11, %8, %2
  %.2 = phi i32 [ -1, %2 ], [ -1, %8 ], [ %.lobit, %17 ], [ -1, %11 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #4
  ret i32 %.2
}

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

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

declare i32 @s2n_stuffer_alloc(ptr noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @openssl_parse_cert_chain(ptr noundef) local_unnamed_addr #0

declare i32 @s2n_stuffer_reread(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @s2n_parse_cert_chain(ptr noundef) local_unnamed_addr #0

declare i32 @s2n_stuffer_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #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, !8, i64 0}
!6 = !{!"s2n_stuffer", !7, i64 0, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 36, !11, i64 36}
!7 = !{!"s2n_blob", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!9, !9, i64 0}


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