; LLVM IR from aws/s2n-tls :: bin (echo)

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

@stderr = external global ptr, align 8
@s2n_errno = external thread_local global i32, align 4
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @wait_for_event(i32 noundef, i32 noundef) #3

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @print_connection_info(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #1

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

8:                                                ; preds = %48, %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call i32 @s2n_negotiate(ptr noundef %9, ptr noundef %6)
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %49

12:                                               ; preds = %8
  %13 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = call i32 @s2n_error_get_type(i32 noundef %14)
  %16 = icmp ne i32 %15, 3
  br i1 %16, label %17, label %39

17:                                               ; preds = %12
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = call ptr @s2n_strerror(i32 noundef %20, ptr noundef @.str.14)
  %22 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = call ptr @s2n_strerror_debug(i32 noundef %23, ptr noundef @.str.14)
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.64, ptr noundef %21, ptr noundef %24) #5
  %26 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = call i32 @s2n_error_get_type(i32 noundef %27)
  %29 = icmp eq i32 %28, 4
  br i1 %29, label %30, label %35

30:                                               ; preds = %17
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call i32 @s2n_connection_get_alert(ptr noundef %32)
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.65, i32 noundef %33) #5
  br label %35

35:                                               ; preds = %30, %17
  br label %36

36:                                               ; preds = %35
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %53

37:                                               ; No predecessors!
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38, %12
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = call i32 @wait_for_event(i32 noundef %40, i32 noundef %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %48

44:                                               ; preds = %39
  br label %45

45:                                               ; preds = %44
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %53

46:                                               ; No predecessors!
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47, %39
  br label %8, !llvm.loop !11

49:                                               ; preds = %8
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call i32 @print_connection_info(ptr noundef %50)
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.66)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %53

53:                                               ; preds = %49, %45, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %54 = load i32, ptr %3, align 4
  ret i32 %54
}

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

declare i32 @s2n_error_get_type(i32 noundef) #1

declare i32 @s2n_connection_get_alert(ptr noundef) #1

attributes #0 = { 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 #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 speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

@stderr = external local_unnamed_addr global ptr, align 8
@s2n_errno = external thread_local local_unnamed_addr global i32, align 4
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.66 = external hidden unnamed_addr constant [14 x i8], align 1

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

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) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @wait_for_event(i32 noundef, i32 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @print_connection_info(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @negotiate(ptr noundef %0, i32 noundef %1) local_unnamed_addr #3 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %4 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @s2n_errno)
  br label %5

5:                                                ; preds = %24, %2
  %6 = call i32 @s2n_negotiate(ptr noundef %0, ptr noundef nonnull %3) #5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %27, label %7

7:                                                ; preds = %5
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = call i32 @s2n_error_get_type(i32 noundef %8) #5
  %.not4 = icmp eq i32 %9, 3
  br i1 %.not4, label %24, label %10

10:                                               ; preds = %7
  %11 = load ptr, ptr @stderr, align 8, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = call ptr @s2n_strerror(i32 noundef %12, ptr noundef nonnull @.str.14) #5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = call ptr @s2n_strerror_debug(i32 noundef %14, ptr noundef nonnull @.str.14) #5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.64, ptr noundef %13, ptr noundef %15) #6
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = call i32 @s2n_error_get_type(i32 noundef %17) #5
  %19 = icmp eq i32 %18, 4
  br i1 %19, label %20, label %.loopexit

20:                                               ; preds = %10
  %21 = load ptr, ptr @stderr, align 8, !tbaa !9
  %22 = call i32 @s2n_connection_get_alert(ptr noundef %0) #5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.65, i32 noundef %22) #6
  br label %.loopexit

24:                                               ; preds = %7
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = call i32 @wait_for_event(i32 noundef %1, i32 noundef %25)
  %.not5 = icmp eq i32 %26, 0
  br i1 %.not5, label %5, label %.loopexit, !llvm.loop !11

27:                                               ; preds = %5
  %28 = call i32 @print_connection_info(ptr noundef %0)
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.66)
  br label %.loopexit

.loopexit:                                        ; preds = %24, %20, %10, %27
  %.0 = phi i32 [ 0, %27 ], [ -1, %10 ], [ -1, %20 ], [ -1, %24 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret i32 %.0
}

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

declare i32 @s2n_error_get_type(i32 noundef) local_unnamed_addr #1

declare i32 @s2n_connection_get_alert(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { cold 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass