; LLVM IR from openanolis/openssl :: fuzz (pem)

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

@.str = external hidden unnamed_addr constant [69 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1

declare void @ERR_clear_error() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @FuzzerTestOneInput(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  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 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = icmp ule i64 %12, 1
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %77

15:                                               ; preds = %2
  %16 = call ptr @BIO_s_mem()
  %17 = call ptr @BIO_new(ptr noundef %16)
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 1
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = sub i64 %21, 1
  %23 = trunc i64 %22 to i32
  %24 = call i32 @BIO_write(ptr noundef %18, ptr noundef %20, i32 noundef %23)
  %25 = sext i32 %24 to i64
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = sub i64 %26, 1
  %28 = icmp eq i64 %25, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %15
  br label %32

30:                                               ; preds = %15
  call void @OPENSSL_die(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 34) #6
  unreachable

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31, %29
  %33 = phi i32 [ 0, %29 ], [ 1, %31 ]
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 0
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = zext i8 %37 to i32
  %39 = call i32 @PEM_read_bio_ex(ptr noundef %34, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, i32 noundef %38)
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %59

41:                                               ; preds = %32
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call i64 @strlen(ptr noundef %44) #7
  %46 = trunc i64 %45 to i32
  %47 = call i32 @BIO_write(ptr noundef %42, ptr noundef %43, i32 noundef %46)
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call i64 @strlen(ptr noundef %50) #7
  %52 = trunc i64 %51 to i32
  %53 = call i32 @BIO_write(ptr noundef %48, ptr noundef %49, i32 noundef %52)
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = trunc i64 %56 to i32
  %58 = call i32 @BIO_write(ptr noundef %54, ptr noundef %55, i32 noundef %57)
  br label %59

59:                                               ; preds = %41, %32
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 0
  %62 = load i8, ptr %61, align 1, !tbaa !11
  %63 = zext i8 %62 to i32
  %64 = and i32 %63, 1
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %59
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  call void @CRYPTO_secure_free(ptr noundef %67, ptr noundef @.str.1, i32 noundef 42)
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  call void @CRYPTO_secure_free(ptr noundef %68, ptr noundef @.str.1, i32 noundef 43)
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  call void @CRYPTO_secure_free(ptr noundef %69, ptr noundef @.str.1, i32 noundef 44)
  br label %74

70:                                               ; preds = %59
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %71, ptr noundef @.str.1, i32 noundef 46)
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %72, ptr noundef @.str.1, i32 noundef 47)
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %73, ptr noundef @.str.1, i32 noundef 48)
  br label %74

74:                                               ; preds = %70, %66
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = call i32 @BIO_free(ptr noundef %75)
  call void @ERR_clear_error()
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %77

77:                                               ; preds = %74, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %78 = load i32, ptr %3, align 4
  ret i32 %78
}

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

declare ptr @BIO_new(ptr noundef) #0

declare ptr @BIO_s_mem() #0

declare i32 @BIO_write(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: noreturn
declare void @OPENSSL_die(ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @PEM_read_bio_ex(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

declare void @CRYPTO_secure_free(ptr noundef, ptr noundef, i32 noundef) #0

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #0

declare i32 @BIO_free(ptr noundef) #0

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

attributes #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { noreturn "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 willreturn memory(read) "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 #5 = { nounwind }
attributes #6 = { noreturn }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!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"

@.str = external hidden unnamed_addr constant [69 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1

declare void @ERR_clear_error() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @FuzzerTestOneInput(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %7 = icmp ult i64 %1, 2
  br i1 %7, label %48, label %8

8:                                                ; preds = %2
  %9 = tail call ptr @BIO_s_mem() #5
  %10 = tail call ptr @BIO_new(ptr noundef %9) #5
  %11 = getelementptr inbounds i8, ptr %0, i64 1
  %12 = add i64 %1, -1
  %13 = trunc i64 %12 to i32
  %14 = tail call i32 @BIO_write(ptr noundef %10, ptr noundef nonnull %11, i32 noundef %13) #5
  %15 = sext i32 %14 to i64
  %16 = icmp eq i64 %12, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %8
  tail call void @OPENSSL_die(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 34) #6
  unreachable

18:                                               ; preds = %8
  %19 = load i8, ptr %0, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = call i32 @PEM_read_bio_ex(ptr noundef %10, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, i32 noundef %20) #5
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %36

23:                                               ; preds = %18
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %24) #7
  %26 = trunc i64 %25 to i32
  %27 = call i32 @BIO_write(ptr noundef %10, ptr noundef %24, i32 noundef %26) #5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %28) #7
  %30 = trunc i64 %29 to i32
  %31 = call i32 @BIO_write(ptr noundef %10, ptr noundef %28, i32 noundef %30) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i64, ptr %6, align 8, !tbaa !10
  %34 = trunc i64 %33 to i32
  %35 = call i32 @BIO_write(ptr noundef %10, ptr noundef %32, i32 noundef %34) #5
  br label %36

36:                                               ; preds = %23, %18
  %37 = load i8, ptr %0, align 1, !tbaa !9
  %38 = and i8 %37, 1
  %.not = icmp eq i8 %38, 0
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  br i1 %.not, label %43, label %40

40:                                               ; preds = %36
  call void @CRYPTO_secure_free(ptr noundef %39, ptr noundef nonnull @.str.1, i32 noundef 42) #5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  call void @CRYPTO_secure_free(ptr noundef %41, ptr noundef nonnull @.str.1, i32 noundef 43) #5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  call void @CRYPTO_secure_free(ptr noundef %42, ptr noundef nonnull @.str.1, i32 noundef 44) #5
  br label %46

43:                                               ; preds = %36
  call void @CRYPTO_free(ptr noundef %39, ptr noundef nonnull @.str.1, i32 noundef 46) #5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %44, ptr noundef nonnull @.str.1, i32 noundef 47) #5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %45, ptr noundef nonnull @.str.1, i32 noundef 48) #5
  br label %46

46:                                               ; preds = %43, %40
  %47 = call i32 @BIO_free(ptr noundef %10) #5
  call void @ERR_clear_error() #5
  br label %48

48:                                               ; preds = %2, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i32 0
}

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

declare ptr @BIO_new(ptr noundef) local_unnamed_addr #0

declare ptr @BIO_s_mem() local_unnamed_addr #0

declare i32 @BIO_write(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: noreturn
declare void @OPENSSL_die(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @PEM_read_bio_ex(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

declare void @CRYPTO_secure_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #0

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

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

!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, !11, i64 0}
!11 = !{!"long", !7, i64 0}


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