; LLVM IR from aws/s2n-tls :: stuffer (s2n_stuffer_text)

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) #0

declare i32 @s2n_stuffer_validate(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #2

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

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 @s2n_stuffer_validate(ptr noundef %15)
  %17 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  store i32 %16, ptr %17, align 4
  %18 = getelementptr inbounds %struct.s2n_result, ptr %7, i32 0, i32 0
  %19 = load i32, ptr %18, align 4
  %20 = call zeroext i1 @s2n_result_is_ok(i32 %19)
  %21 = xor i1 %20, true
  %22 = xor i1 %21, true
  %23 = zext i1 %22 to i32
  %24 = sext i32 %23 to i64
  %25 = call i64 @llvm.expect.i64(i64 %24, i64 1)
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %14
  %28 = getelementptr inbounds %struct.s2n_result, ptr %6, i32 0, i32 0
  store i32 0, ptr %28, align 4, !tbaa !9
  br label %31

29:                                               ; preds = %14
  %30 = getelementptr inbounds %struct.s2n_result, ptr %6, i32 0, i32 0
  store i32 -1, ptr %30, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %29, %27
  %32 = getelementptr inbounds %struct.s2n_result, ptr %6, i32 0, i32 0
  %33 = load i32, ptr %32, align 4
  %34 = call zeroext i1 @s2n_result_is_ok(i32 %33)
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 -1, ptr %3, align 4
  br label %146

36:                                               ; preds = %31
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call i32 @s2n_stuffer_validate(ptr noundef %39)
  %41 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  store i32 %40, ptr %41, align 4
  %42 = getelementptr inbounds %struct.s2n_result, ptr %9, i32 0, i32 0
  %43 = load i32, ptr %42, align 4
  %44 = call zeroext i1 @s2n_result_is_ok(i32 %43)
  %45 = xor i1 %44, true
  %46 = xor i1 %45, true
  %47 = zext i1 %46 to i32
  %48 = sext i32 %47 to i64
  %49 = call i64 @llvm.expect.i64(i64 %48, i64 1)
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %38
  %52 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 0, ptr %52, align 4, !tbaa !9
  br label %55

53:                                               ; preds = %38
  %54 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  store i32 -1, ptr %54, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %53, %51
  %56 = getelementptr inbounds %struct.s2n_result, ptr %8, i32 0, i32 0
  %57 = load i32, ptr %56, align 4
  %58 = call zeroext i1 @s2n_result_is_ok(i32 %57)
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 -1, ptr %3, align 4
  br label %146

60:                                               ; preds = %55
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = call i32 @s2n_stuffer_read_token(ptr noundef %63, ptr noundef %64, i8 noundef signext 10)
  %66 = icmp sgt i32 %65, -1
  br i1 %66, label %68, label %67

67:                                               ; preds = %62
  store i32 -1, ptr %3, align 4
  br label %146

68:                                               ; preds = %62
  br label %69

69:                                               ; preds = %68
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.s2n_stuffer, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !12
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.s2n_stuffer, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 8, !tbaa !15
  %76 = sub i32 %72, %75
  %77 = icmp ugt i32 %76, 0
  br i1 %77, label %78, label %97

78:                                               ; preds = %69
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.s2n_stuffer, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.s2n_blob, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !16
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.s2n_stuffer, ptr %83, i32 0, i32 2
  %85 = load i32, ptr %84, align 4, !tbaa !12
  %86 = sub i32 %85, 1
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %82, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !17
  %90 = zext i8 %89 to i32
  %91 = icmp eq i32 %90, 13
  br i1 %91, label %92, label %97

92:                                               ; preds = %78
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.s2n_stuffer, ptr %93, i32 0, i32 2
  %95 = load i32, ptr %94, align 4, !tbaa !12
  %96 = add i32 %95, -1
  store i32 %96, ptr %94, align 4, !tbaa !12
  br label %97

97:                                               ; preds = %92, %78, %69
  br label %98

98:                                               ; preds = %97
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = call i32 @s2n_stuffer_validate(ptr noundef %99)
  %101 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  store i32 %100, ptr %101, align 4
  %102 = getelementptr inbounds %struct.s2n_result, ptr %11, i32 0, i32 0
  %103 = load i32, ptr %102, align 4
  %104 = call zeroext i1 @s2n_result_is_ok(i32 %103)
  %105 = xor i1 %104, true
  %106 = xor i1 %105, true
  %107 = zext i1 %106 to i32
  %108 = sext i32 %107 to i64
  %109 = call i64 @llvm.expect.i64(i64 %108, i64 1)
  %110 = icmp ne i64 %109, 0
  br i1 %110, label %111, label %113

111:                                              ; preds = %98
  %112 = getelementptr inbounds %struct.s2n_result, ptr %10, i32 0, i32 0
  store i32 0, ptr %112, align 4, !tbaa !9
  br label %115

113:                                              ; preds = %98
  %114 = getelementptr inbounds %struct.s2n_result, ptr %10, i32 0, i32 0
  store i32 -1, ptr %114, align 4, !tbaa !9
  br label %115

115:                                              ; preds = %113, %111
  %116 = getelementptr inbounds %struct.s2n_result, ptr %10, i32 0, i32 0
  %117 = load i32, ptr %116, align 4
  %118 = call zeroext i1 @s2n_result_is_ok(i32 %117)
  br i1 %118, label %120, label %119

119:                                              ; preds = %115
  store i32 -1, ptr %3, align 4
  br label %146

120:                                              ; preds = %115
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = call i32 @s2n_stuffer_validate(ptr noundef %123)
  %125 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  store i32 %124, ptr %125, align 4
  %126 = getelementptr inbounds %struct.s2n_result, ptr %13, i32 0, i32 0
  %127 = load i32, ptr %126, align 4
  %128 = call zeroext i1 @s2n_result_is_ok(i32 %127)
  %129 = xor i1 %128, true
  %130 = xor i1 %129, true
  %131 = zext i1 %130 to i32
  %132 = sext i32 %131 to i64
  %133 = call i64 @llvm.expect.i64(i64 %132, i64 1)
  %134 = icmp ne i64 %133, 0
  br i1 %134, label %135, label %137

135:                                              ; preds = %122
  %136 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 0, ptr %136, align 4, !tbaa !9
  br label %139

137:                                              ; preds = %122
  %138 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  store i32 -1, ptr %138, align 4, !tbaa !9
  br label %139

139:                                              ; preds = %137, %135
  %140 = getelementptr inbounds %struct.s2n_result, ptr %12, i32 0, i32 0
  %141 = load i32, ptr %140, align 4
  %142 = call zeroext i1 @s2n_result_is_ok(i32 %141)
  br i1 %142, label %144, label %143

143:                                              ; preds = %139
  store i32 -1, ptr %3, align 4
  br label %146

144:                                              ; preds = %139
  br label %145

145:                                              ; preds = %144
  store i32 0, ptr %3, align 4
  br label %146

146:                                              ; preds = %145, %143, %119, %67, %59, %35
  %147 = load i32, ptr %3, align 4
  ret i32 %147
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_stuffer_read_token(ptr noundef, ptr noundef, i8 noundef signext) #3

attributes #0 = { inlinehint 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(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" }

!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, !11, i64 0}
!10 = !{!"", !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 28}
!13 = !{!"s2n_stuffer", !14, i64 0, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 36, !11, i64 36}
!14 = !{!"s2n_blob", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!15 = !{!13, !11, i64 24}
!16 = !{!13, !6, i64 0}
!17 = !{!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"

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @s2n_result_is_ok(i32) local_unnamed_addr #0

declare i32 @s2n_stuffer_validate(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @s2n_stuffer_read_line(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = tail call i32 @s2n_stuffer_validate(ptr noundef %0) #3
  %4 = tail call zeroext i1 @s2n_result_is_ok(i32 %3)
  %not. = xor i1 %4, true
  %. = sext i1 %not. to i32
  %5 = tail call zeroext i1 @s2n_result_is_ok(i32 %.)
  br i1 %5, label %6, label %34

6:                                                ; preds = %2
  %7 = tail call i32 @s2n_stuffer_validate(ptr noundef %1) #3
  %8 = tail call zeroext i1 @s2n_result_is_ok(i32 %7)
  %not.21 = xor i1 %8, true
  %.18 = sext i1 %not.21 to i32
  %9 = tail call zeroext i1 @s2n_result_is_ok(i32 %.18)
  br i1 %9, label %10, label %34

10:                                               ; preds = %6
  %11 = tail call i32 @s2n_stuffer_read_token(ptr noundef %0, ptr noundef %1, i8 noundef signext 10)
  %12 = icmp sgt i32 %11, -1
  br i1 %12, label %13, label %34

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %1, i64 28
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 24
  %17 = load i32, ptr %16, align 8, !tbaa !12
  %.not = icmp eq i32 %15, %17
  br i1 %.not, label %26, label %18

18:                                               ; preds = %13
  %19 = load ptr, ptr %1, align 8, !tbaa !13
  %20 = add i32 %15, -1
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !14
  %24 = icmp eq i8 %23, 13
  br i1 %24, label %25, label %26

25:                                               ; preds = %18
  store i32 %20, ptr %14, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %13, %18, %25
  %27 = tail call i32 @s2n_stuffer_validate(ptr noundef %0) #3
  %28 = tail call zeroext i1 @s2n_result_is_ok(i32 %27)
  %not.22 = xor i1 %28, true
  %.19 = sext i1 %not.22 to i32
  %29 = tail call zeroext i1 @s2n_result_is_ok(i32 %.19)
  br i1 %29, label %30, label %34

30:                                               ; preds = %26
  %31 = tail call i32 @s2n_stuffer_validate(ptr noundef nonnull %1) #3
  %32 = tail call zeroext i1 @s2n_result_is_ok(i32 %31)
  %not.23 = xor i1 %32, true
  %.20 = sext i1 %not.23 to i32
  %33 = tail call zeroext i1 @s2n_result_is_ok(i32 %.20)
  %not.24 = xor i1 %33, true
  %spec.select = sext i1 %not.24 to i32
  br label %34

34:                                               ; preds = %30, %26, %10, %6, %2
  %.0 = phi i32 [ -1, %2 ], [ -1, %6 ], [ -1, %10 ], [ -1, %26 ], [ %spec.select, %30 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @s2n_stuffer_read_token(ptr noundef, ptr noundef, i8 noundef signext) local_unnamed_addr #2

attributes #0 = { inlinehint 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 = { 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 #3 = { 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, !11, i64 28}
!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 = !{!6, !11, i64 24}
!13 = !{!6, !8, i64 0}
!14 = !{!9, !9, i64 0}


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