; LLVM IR from aws/s2n-tls :: tests/unit (s2n_async_pkey_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"

@s2n_use_color_in_output = external dso_local global i8, align 1
@test_count = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [101 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@s2n_errno = external thread_local global i32, align 4
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [132 x i8], align 1

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #1

declare i32 @s2n_print_stacktrace(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @isatty(i32 noundef) #3

; Function Attrs: nounwind
declare i32 @fileno(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare ptr @s2n_strerror(i32 noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #4

declare ptr @s2n_strerror_debug(i32 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #3

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #5

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

6:                                                ; preds = %2
  br label %7

7:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %8 = call ptr @__errno_location() #8
  %9 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %9, ptr %5, align 4, !tbaa !9
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = call i32 @s2n_print_stacktrace(ptr noundef %10)
  %12 = load i8, ptr @s2n_use_color_in_output, align 1, !tbaa !11, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %36

14:                                               ; preds = %7
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = call i32 @fileno(ptr noundef %15) #7
  %17 = call i32 @isatty(i32 noundef %16) #7
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %36

19:                                               ; preds = %14
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = call ptr @__errno_location() #8
  store i32 %20, ptr %21, align 4, !tbaa !9
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = load i32, ptr @test_count, align 4, !tbaa !9
  %24 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = call ptr @s2n_strerror(i32 noundef %25, ptr noundef @.str.3)
  %27 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = call ptr @s2n_strerror_debug(i32 noundef %28, ptr noundef @.str.3)
  %30 = call ptr @__errno_location() #8
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = call ptr @strerror(i32 noundef %31) #7
  %33 = call ptr @__errno_location() #8
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str, i32 noundef %23, ptr noundef @.str.61, ptr noundef @.str.2, i32 noundef 350, ptr noundef %26, ptr noundef %29, ptr noundef %32, i32 noundef %34) #7
  br label %53

36:                                               ; preds = %14, %7
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = call ptr @__errno_location() #8
  store i32 %37, ptr %38, align 4, !tbaa !9
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = load i32, ptr @test_count, align 4, !tbaa !9
  %41 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = call ptr @s2n_strerror(i32 noundef %42, ptr noundef @.str.3)
  %44 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = call ptr @s2n_strerror_debug(i32 noundef %45, ptr noundef @.str.3)
  %47 = call ptr @__errno_location() #8
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = call ptr @strerror(i32 noundef %48) #7
  %50 = call ptr @__errno_location() #8
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.4, i32 noundef %40, ptr noundef @.str.61, ptr noundef @.str.2, i32 noundef 350, ptr noundef %43, ptr noundef %46, ptr noundef %49, i32 noundef %51) #7
  br label %53

53:                                               ; preds = %36, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %54

54:                                               ; preds = %53
  call void @exit(i32 noundef 1) #9
  unreachable

55:                                               ; No predecessors!
  ret i32 -1
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(none) "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 = { "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 #3 = { nounwind "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind "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 #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { noreturn 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 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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

@s2n_use_color_in_output = external dso_local local_unnamed_addr global i8, align 1
@test_count = external dso_local local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [101 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [132 x i8], align 1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #0

declare i32 @s2n_print_stacktrace(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @isatty(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fileno(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #4

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @async_pkey_invalid_complete(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1) local_unnamed_addr #6 {
  %3 = tail call ptr @__errno_location() #7
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = load ptr, ptr @stderr, align 8, !tbaa !9
  %6 = tail call i32 @s2n_print_stacktrace(ptr noundef %5) #8
  %7 = load i8, ptr @s2n_use_color_in_output, align 1, !tbaa !11, !range !13, !noundef !14
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %13

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !9
  %11 = tail call i32 @fileno(ptr noundef %10) #8
  %12 = tail call i32 @isatty(i32 noundef %11) #8
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %14

13:                                               ; preds = %9, %2
  br label %14

14:                                               ; preds = %9, %13
  %.str.4.sink = phi ptr [ @.str.4, %13 ], [ @.str, %9 ]
  store i32 %4, ptr %3, align 4, !tbaa !5
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = load i32, ptr @test_count, align 4, !tbaa !5
  %17 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = tail call ptr @s2n_strerror(i32 noundef %18, ptr noundef nonnull @.str.3) #8
  %20 = load i32, ptr %17, align 4, !tbaa !5
  %21 = tail call ptr @s2n_strerror_debug(i32 noundef %20, ptr noundef nonnull @.str.3) #8
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = tail call ptr @strerror(i32 noundef %22) #8
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull %.str.4.sink, i32 noundef %16, ptr noundef nonnull @.str.61, ptr noundef nonnull @.str.2, i32 noundef 350, ptr noundef %19, ptr noundef %21, ptr noundef %23, i32 noundef %24) #9
  tail call void @exit(i32 noundef 1) #10
  unreachable
}

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nounwind "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 #3 = { nofree nounwind "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind "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 #6 = { noreturn 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 #7 = { nounwind willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { cold nounwind }
attributes #10 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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