; LLVM IR from tezc/sc :: buffer (buf_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.sc_buf = type { ptr, i64, i64, i64, i64, i32, i8 }

@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.test2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.77 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [43 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

declare zeroext i1 @sc_buf_init(ptr noundef, i64 noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare void @sc_buf_term(ptr noundef) #1

declare void @sc_buf_put_64(ptr noundef, i64 noundef) #1

declare i64 @sc_buf_get_64(ptr noundef) #1

declare i64 @sc_buf_size(ptr noundef) #1

declare zeroext i1 @sc_buf_valid(ptr noundef) #1

declare void @sc_buf_clear(ptr noundef) #1

declare void @sc_buf_set_wpos(ptr noundef, i64 noundef) #1

declare void @sc_buf_put_32(ptr noundef, i32 noundef) #1

declare ptr @sc_buf_get_str(ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

declare void @sc_buf_mark_read(ptr noundef, i64 noundef) #1

declare void @sc_buf_mark_write(ptr noundef, i64 noundef) #1

declare ptr @sc_buf_rbuf(ptr noundef) #1

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

declare void @sc_buf_put_text(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @test2() #4 {
  %1 = alloca [32 x i8], align 16
  %2 = alloca %struct.sc_buf, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 48, ptr %2) #5
  %6 = call zeroext i1 @sc_buf_init(ptr noundef %2, i64 noundef 100)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 100)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 200)
  call void @sc_buf_set_64_at(ptr noundef %2, i64 noundef 8, i64 noundef 300)
  %7 = call i64 @sc_buf_peek_64_at(ptr noundef %2, i64 noundef 8)
  %8 = icmp eq i64 %7, 300
  br i1 %8, label %9, label %10

9:                                                ; preds = %0
  br label %11

10:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str.71, ptr noundef @.str.1, i32 noundef 269, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

11:                                               ; preds = %9
  call void @sc_buf_set_32_at(ptr noundef %2, i64 noundef 8, i32 noundef 111)
  %12 = call i32 @sc_buf_peek_32_at(ptr noundef %2, i64 noundef 8)
  %13 = icmp eq i32 %12, 111
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %16

15:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.72, ptr noundef @.str.1, i32 noundef 271, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

16:                                               ; preds = %14
  call void @sc_buf_set_8_at(ptr noundef %2, i64 noundef 0, i8 noundef zeroext 0)
  call void @sc_buf_set_8_at(ptr noundef %2, i64 noundef 1, i8 noundef zeroext 0)
  call void @sc_buf_set_8_at(ptr noundef %2, i64 noundef 2, i8 noundef zeroext 0)
  call void @sc_buf_set_8_at(ptr noundef %2, i64 noundef 3, i8 noundef zeroext 0)
  %17 = call i32 @sc_buf_peek_32_at(ptr noundef %2, i64 noundef 0)
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  br label %21

20:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.73, ptr noundef @.str.1, i32 noundef 276, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

21:                                               ; preds = %19
  call void @sc_buf_clear(ptr noundef %2)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 1000)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 3000)
  call void @sc_buf_set_wpos(ptr noundef %2, i64 noundef 0)
  call void @sc_buf_set_64(ptr noundef %2, i64 noundef 2000)
  call void @sc_buf_set_wpos(ptr noundef %2, i64 noundef 16)
  %22 = call i64 @sc_buf_peek_64(ptr noundef %2)
  %23 = icmp eq i64 %22, 2000
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %26

25:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.74, ptr noundef @.str.1, i32 noundef 284, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

26:                                               ; preds = %24
  %27 = call i64 @sc_buf_peek_64_at(ptr noundef %2, i64 noundef 8)
  %28 = icmp eq i64 %27, 3000
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %31

30:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.75, ptr noundef @.str.1, i32 noundef 285, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

31:                                               ; preds = %29
  call void @sc_buf_clear(ptr noundef %2)
  call void @sc_buf_put_32(ptr noundef %2, i32 noundef 10)
  %32 = call i32 @sc_buf_peek_32(ptr noundef %2)
  %33 = icmp eq i32 %32, 10
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %36

35:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.76, ptr noundef @.str.1, i32 noundef 289, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

36:                                               ; preds = %34
  call void @sc_buf_set_wpos(ptr noundef %2, i64 noundef 0)
  call void @sc_buf_set_32(ptr noundef %2, i32 noundef 1000)
  call void @sc_buf_set_wpos(ptr noundef %2, i64 noundef 4)
  %37 = call i32 @sc_buf_peek_32(ptr noundef %2)
  %38 = icmp eq i32 %37, 1000
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  br label %41

40:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.77, ptr noundef @.str.1, i32 noundef 293, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

41:                                               ; preds = %39
  call void @sc_buf_clear(ptr noundef %2)
  call void (ptr, ptr, ...) @sc_buf_put_text(ptr noundef %2, ptr noundef @.str.22)
  call void (ptr, ptr, ...) @sc_buf_put_text(ptr noundef %2, ptr noundef @.str.22)
  %42 = call ptr @sc_buf_rbuf(ptr noundef %2)
  %43 = call i32 @strcmp(ptr noundef %42, ptr noundef @.str.78) #7
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  br label %47

46:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.79, ptr noundef @.str.1, i32 noundef 298, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

47:                                               ; preds = %45
  call void @sc_buf_clear(ptr noundef %2)
  call void @sc_buf_put_32(ptr noundef %2, i32 noundef 100)
  call void @sc_buf_put_32(ptr noundef %2, i32 noundef 100)
  call void @sc_buf_put_32(ptr noundef %2, i32 noundef 100)
  call void @sc_buf_put_32(ptr noundef %2, i32 noundef 100)
  %48 = call i32 @sc_buf_peek_32_at(ptr noundef %2, i64 noundef 100)
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  br label %52

51:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str.80, ptr noundef @.str.1, i32 noundef 305, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

52:                                               ; preds = %50
  %53 = call zeroext i1 @sc_buf_valid(ptr noundef %2)
  %54 = zext i1 %53 to i32
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  br label %58

57:                                               ; preds = %52
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 306, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

58:                                               ; preds = %56
  call void @sc_buf_term(ptr noundef %2)
  %59 = call zeroext i1 @sc_buf_init(ptr noundef %2, i64 noundef 1000)
  call void @sc_buf_mark_write(ptr noundef %2, i64 noundef 1000)
  call void @sc_buf_mark_read(ptr noundef %2, i64 noundef 800)
  %60 = call zeroext i1 @sc_buf_reserve(ptr noundef %2, i64 noundef 400)
  call void @sc_buf_term(ptr noundef %2)
  %61 = call zeroext i1 @sc_buf_init(ptr noundef %2, i64 noundef 100)
  %62 = call ptr @sc_buf_get_str(ptr noundef %2)
  call void @sc_buf_set_8(ptr noundef %2, i8 noundef zeroext 100)
  call void @sc_buf_set_16(ptr noundef %2, i16 noundef zeroext 100)
  call void @sc_buf_set_32(ptr noundef %2, i32 noundef 100)
  call void @sc_buf_set_64(ptr noundef %2, i64 noundef 100)
  %63 = call i64 @sc_buf_set_data(ptr noundef %2, i64 noundef 19, ptr noundef @.str.81, i64 noundef 1)
  %64 = getelementptr inbounds [32 x i8], ptr %1, i64 0, i64 0
  %65 = call i64 @sc_buf_peek_data(ptr noundef %2, i64 noundef 10, ptr noundef %64, i64 noundef 0)
  %66 = call zeroext i1 @sc_buf_valid(ptr noundef %2)
  br i1 %66, label %68, label %67

67:                                               ; preds = %58
  br label %69

68:                                               ; preds = %58
  call void @__assert_fail(ptr noundef @.str.82, ptr noundef @.str.1, i32 noundef 324, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

69:                                               ; preds = %67
  call void @sc_buf_term(ptr noundef %2)
  %70 = call zeroext i1 @sc_buf_init(ptr noundef %2, i64 noundef 32)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 100)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 200)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 300)
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef 400)
  %71 = call i64 @sc_buf_get_64(ptr noundef %2)
  %72 = call i64 @sc_buf_get_64(ptr noundef %2)
  %73 = call zeroext i1 @sc_buf_shrink(ptr noundef %2, i64 noundef 24)
  %74 = call i64 @sc_buf_get_64(ptr noundef %2)
  %75 = icmp eq i64 %74, 300
  br i1 %75, label %76, label %77

76:                                               ; preds = %69
  br label %78

77:                                               ; preds = %69
  call void @__assert_fail(ptr noundef @.str.83, ptr noundef @.str.1, i32 noundef 335, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

78:                                               ; preds = %76
  %79 = call i64 @sc_buf_get_64(ptr noundef %2)
  %80 = icmp eq i64 %79, 400
  br i1 %80, label %81, label %82

81:                                               ; preds = %78
  br label %83

82:                                               ; preds = %78
  call void @__assert_fail(ptr noundef @.str.84, ptr noundef @.str.1, i32 noundef 336, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

83:                                               ; preds = %81
  %84 = call i64 @sc_buf_size(ptr noundef %2)
  %85 = icmp eq i64 %84, 0
  br i1 %85, label %86, label %87

86:                                               ; preds = %83
  br label %88

87:                                               ; preds = %83
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 337, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

88:                                               ; preds = %86
  call void @sc_buf_term(ptr noundef %2)
  %89 = call zeroext i1 @sc_buf_init(ptr noundef %2, i64 noundef 4096)
  %90 = call zeroext i1 @sc_buf_shrink(ptr noundef %2, i64 noundef 8192)
  %91 = call zeroext i1 @sc_buf_shrink(ptr noundef %2, i64 noundef 128)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %99, %88
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = icmp slt i32 %93, 4000
  br i1 %94, label %96, label %95

95:                                               ; preds = %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %102

96:                                               ; preds = %92
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  call void @sc_buf_put_64(ptr noundef %2, i64 noundef %98)
  br label %99

99:                                               ; preds = %96
  %100 = load i32, ptr %3, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %3, align 4, !tbaa !5
  br label %92, !llvm.loop !9

102:                                              ; preds = %95
  %103 = call zeroext i1 @sc_buf_shrink(ptr noundef %2, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %110, %102
  %105 = load i32, ptr %4, align 4, !tbaa !5
  %106 = icmp slt i32 %105, 3700
  br i1 %106, label %108, label %107

107:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %113

108:                                              ; preds = %104
  %109 = call i64 @sc_buf_get_64(ptr noundef %2)
  br label %110

110:                                              ; preds = %108
  %111 = load i32, ptr %4, align 4, !tbaa !5
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %4, align 4, !tbaa !5
  br label %104, !llvm.loop !11

113:                                              ; preds = %107
  %114 = call zeroext i1 @sc_buf_shrink(ptr noundef %2, i64 noundef 4096)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %128, %113
  %116 = load i32, ptr %5, align 4, !tbaa !5
  %117 = icmp slt i32 %116, 300
  br i1 %117, label %119, label %118

118:                                              ; preds = %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %131

119:                                              ; preds = %115
  %120 = call i64 @sc_buf_get_64(ptr noundef %2)
  %121 = load i32, ptr %5, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = add i64 3700, %122
  %124 = icmp eq i64 %120, %123
  br i1 %124, label %125, label %126

125:                                              ; preds = %119
  br label %127

126:                                              ; preds = %119
  call void @__assert_fail(ptr noundef @.str.85, ptr noundef @.str.1, i32 noundef 357, ptr noundef @__PRETTY_FUNCTION__.test2) #6
  unreachable

127:                                              ; preds = %125
  br label %128

128:                                              ; preds = %127
  %129 = load i32, ptr %5, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %5, align 4, !tbaa !5
  br label %115, !llvm.loop !12

131:                                              ; preds = %118
  call void @sc_buf_term(ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 48, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #5
  ret void
}

declare void @sc_buf_set_64_at(ptr noundef, i64 noundef, i64 noundef) #1

declare i64 @sc_buf_peek_64_at(ptr noundef, i64 noundef) #1

declare void @sc_buf_set_32_at(ptr noundef, i64 noundef, i32 noundef) #1

declare i32 @sc_buf_peek_32_at(ptr noundef, i64 noundef) #1

declare void @sc_buf_set_8_at(ptr noundef, i64 noundef, i8 noundef zeroext) #1

declare void @sc_buf_set_64(ptr noundef, i64 noundef) #1

declare i64 @sc_buf_peek_64(ptr noundef) #1

declare i32 @sc_buf_peek_32(ptr noundef) #1

declare void @sc_buf_set_32(ptr noundef, i32 noundef) #1

declare zeroext i1 @sc_buf_reserve(ptr noundef, i64 noundef) #1

declare void @sc_buf_set_8(ptr noundef, i8 noundef zeroext) #1

declare void @sc_buf_set_16(ptr noundef, i16 noundef zeroext) #1

declare i64 @sc_buf_set_data(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

declare i64 @sc_buf_peek_data(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

declare zeroext i1 @sc_buf_shrink(ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #4 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; 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.sc_buf = type { ptr, i64, i64, i64, i64, i32, i8 }

@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.test2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.77 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare zeroext i1 @sc_buf_init(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @sc_buf_term(ptr noundef) local_unnamed_addr #1

declare void @sc_buf_put_64(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i64 @sc_buf_get_64(ptr noundef) local_unnamed_addr #1

declare i64 @sc_buf_size(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @sc_buf_valid(ptr noundef) local_unnamed_addr #1

declare void @sc_buf_clear(ptr noundef) local_unnamed_addr #1

declare void @sc_buf_set_wpos(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @sc_buf_put_32(ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @sc_buf_get_str(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

declare void @sc_buf_mark_read(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @sc_buf_mark_write(ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @sc_buf_rbuf(ptr noundef) local_unnamed_addr #1

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

declare void @sc_buf_put_text(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test2() local_unnamed_addr #4 {
  %1 = alloca [32 x i8], align 16
  %2 = alloca %struct.sc_buf, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #5
  %3 = call zeroext i1 @sc_buf_init(ptr noundef nonnull %2, i64 noundef 100) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 100) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 200) #5
  call void @sc_buf_set_64_at(ptr noundef nonnull %2, i64 noundef 8, i64 noundef 300) #5
  %4 = call i64 @sc_buf_peek_64_at(ptr noundef nonnull %2, i64 noundef 8) #5
  %5 = icmp eq i64 %4, 300
  br i1 %5, label %7, label %6

6:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.71, ptr noundef nonnull @.str.1, i32 noundef 269, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

7:                                                ; preds = %0
  call void @sc_buf_set_32_at(ptr noundef nonnull %2, i64 noundef 8, i32 noundef 111) #5
  %8 = call i32 @sc_buf_peek_32_at(ptr noundef nonnull %2, i64 noundef 8) #5
  %9 = icmp eq i32 %8, 111
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @__assert_fail(ptr noundef nonnull @.str.72, ptr noundef nonnull @.str.1, i32 noundef 271, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

11:                                               ; preds = %7
  call void @sc_buf_set_8_at(ptr noundef nonnull %2, i64 noundef 0, i8 noundef zeroext 0) #5
  call void @sc_buf_set_8_at(ptr noundef nonnull %2, i64 noundef 1, i8 noundef zeroext 0) #5
  call void @sc_buf_set_8_at(ptr noundef nonnull %2, i64 noundef 2, i8 noundef zeroext 0) #5
  call void @sc_buf_set_8_at(ptr noundef nonnull %2, i64 noundef 3, i8 noundef zeroext 0) #5
  %12 = call i32 @sc_buf_peek_32_at(ptr noundef nonnull %2, i64 noundef 0) #5
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @__assert_fail(ptr noundef nonnull @.str.73, ptr noundef nonnull @.str.1, i32 noundef 276, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

15:                                               ; preds = %11
  call void @sc_buf_clear(ptr noundef nonnull %2) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 1000) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 3000) #5
  call void @sc_buf_set_wpos(ptr noundef nonnull %2, i64 noundef 0) #5
  call void @sc_buf_set_64(ptr noundef nonnull %2, i64 noundef 2000) #5
  call void @sc_buf_set_wpos(ptr noundef nonnull %2, i64 noundef 16) #5
  %16 = call i64 @sc_buf_peek_64(ptr noundef nonnull %2) #5
  %17 = icmp eq i64 %16, 2000
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @__assert_fail(ptr noundef nonnull @.str.74, ptr noundef nonnull @.str.1, i32 noundef 284, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

19:                                               ; preds = %15
  %20 = call i64 @sc_buf_peek_64_at(ptr noundef nonnull %2, i64 noundef 8) #5
  %21 = icmp eq i64 %20, 3000
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @__assert_fail(ptr noundef nonnull @.str.75, ptr noundef nonnull @.str.1, i32 noundef 285, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

23:                                               ; preds = %19
  call void @sc_buf_clear(ptr noundef nonnull %2) #5
  call void @sc_buf_put_32(ptr noundef nonnull %2, i32 noundef 10) #5
  %24 = call i32 @sc_buf_peek_32(ptr noundef nonnull %2) #5
  %25 = icmp eq i32 %24, 10
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  call void @__assert_fail(ptr noundef nonnull @.str.76, ptr noundef nonnull @.str.1, i32 noundef 289, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

27:                                               ; preds = %23
  call void @sc_buf_set_wpos(ptr noundef nonnull %2, i64 noundef 0) #5
  call void @sc_buf_set_32(ptr noundef nonnull %2, i32 noundef 1000) #5
  call void @sc_buf_set_wpos(ptr noundef nonnull %2, i64 noundef 4) #5
  %28 = call i32 @sc_buf_peek_32(ptr noundef nonnull %2) #5
  %29 = icmp eq i32 %28, 1000
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  call void @__assert_fail(ptr noundef nonnull @.str.77, ptr noundef nonnull @.str.1, i32 noundef 293, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

31:                                               ; preds = %27
  call void @sc_buf_clear(ptr noundef nonnull %2) #5
  call void (ptr, ptr, ...) @sc_buf_put_text(ptr noundef nonnull %2, ptr noundef nonnull @.str.22) #5
  call void (ptr, ptr, ...) @sc_buf_put_text(ptr noundef nonnull %2, ptr noundef nonnull @.str.22) #5
  %32 = call ptr @sc_buf_rbuf(ptr noundef nonnull %2) #5
  %33 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %32, ptr noundef nonnull dereferenceable(1) @.str.78) #7
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @__assert_fail(ptr noundef nonnull @.str.79, ptr noundef nonnull @.str.1, i32 noundef 298, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

36:                                               ; preds = %31
  call void @sc_buf_clear(ptr noundef nonnull %2) #5
  call void @sc_buf_put_32(ptr noundef nonnull %2, i32 noundef 100) #5
  call void @sc_buf_put_32(ptr noundef nonnull %2, i32 noundef 100) #5
  call void @sc_buf_put_32(ptr noundef nonnull %2, i32 noundef 100) #5
  call void @sc_buf_put_32(ptr noundef nonnull %2, i32 noundef 100) #5
  %37 = call i32 @sc_buf_peek_32_at(ptr noundef nonnull %2, i64 noundef 100) #5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  call void @__assert_fail(ptr noundef nonnull @.str.80, ptr noundef nonnull @.str.1, i32 noundef 305, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

40:                                               ; preds = %36
  %41 = call zeroext i1 @sc_buf_valid(ptr noundef nonnull %2) #5
  br i1 %41, label %42, label %43

42:                                               ; preds = %40
  call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 306, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

43:                                               ; preds = %40
  call void @sc_buf_term(ptr noundef nonnull %2) #5
  %44 = call zeroext i1 @sc_buf_init(ptr noundef nonnull %2, i64 noundef 1000) #5
  call void @sc_buf_mark_write(ptr noundef nonnull %2, i64 noundef 1000) #5
  call void @sc_buf_mark_read(ptr noundef nonnull %2, i64 noundef 800) #5
  %45 = call zeroext i1 @sc_buf_reserve(ptr noundef nonnull %2, i64 noundef 400) #5
  call void @sc_buf_term(ptr noundef nonnull %2) #5
  %46 = call zeroext i1 @sc_buf_init(ptr noundef nonnull %2, i64 noundef 100) #5
  %47 = call ptr @sc_buf_get_str(ptr noundef nonnull %2) #5
  call void @sc_buf_set_8(ptr noundef nonnull %2, i8 noundef zeroext 100) #5
  call void @sc_buf_set_16(ptr noundef nonnull %2, i16 noundef zeroext 100) #5
  call void @sc_buf_set_32(ptr noundef nonnull %2, i32 noundef 100) #5
  call void @sc_buf_set_64(ptr noundef nonnull %2, i64 noundef 100) #5
  %48 = call i64 @sc_buf_set_data(ptr noundef nonnull %2, i64 noundef 19, ptr noundef nonnull @.str.81, i64 noundef 1) #5
  %49 = call i64 @sc_buf_peek_data(ptr noundef nonnull %2, i64 noundef 10, ptr noundef nonnull %1, i64 noundef 0) #5
  %50 = call zeroext i1 @sc_buf_valid(ptr noundef nonnull %2) #5
  br i1 %50, label %51, label %52

51:                                               ; preds = %43
  call void @__assert_fail(ptr noundef nonnull @.str.82, ptr noundef nonnull @.str.1, i32 noundef 324, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

52:                                               ; preds = %43
  call void @sc_buf_term(ptr noundef nonnull %2) #5
  %53 = call zeroext i1 @sc_buf_init(ptr noundef nonnull %2, i64 noundef 32) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 100) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 200) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 300) #5
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef 400) #5
  %54 = call i64 @sc_buf_get_64(ptr noundef nonnull %2) #5
  %55 = call i64 @sc_buf_get_64(ptr noundef nonnull %2) #5
  %56 = call zeroext i1 @sc_buf_shrink(ptr noundef nonnull %2, i64 noundef 24) #5
  %57 = call i64 @sc_buf_get_64(ptr noundef nonnull %2) #5
  %58 = icmp eq i64 %57, 300
  br i1 %58, label %60, label %59

59:                                               ; preds = %52
  call void @__assert_fail(ptr noundef nonnull @.str.83, ptr noundef nonnull @.str.1, i32 noundef 335, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

60:                                               ; preds = %52
  %61 = call i64 @sc_buf_get_64(ptr noundef nonnull %2) #5
  %62 = icmp eq i64 %61, 400
  br i1 %62, label %64, label %63

63:                                               ; preds = %60
  call void @__assert_fail(ptr noundef nonnull @.str.84, ptr noundef nonnull @.str.1, i32 noundef 336, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

64:                                               ; preds = %60
  %65 = call i64 @sc_buf_size(ptr noundef nonnull %2) #5
  %66 = icmp eq i64 %65, 0
  br i1 %66, label %68, label %67

67:                                               ; preds = %64
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 337, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable

68:                                               ; preds = %64
  call void @sc_buf_term(ptr noundef nonnull %2) #5
  %69 = call zeroext i1 @sc_buf_init(ptr noundef nonnull %2, i64 noundef 4096) #5
  %70 = call zeroext i1 @sc_buf_shrink(ptr noundef nonnull %2, i64 noundef 8192) #5
  %71 = call zeroext i1 @sc_buf_shrink(ptr noundef nonnull %2, i64 noundef 128) #5
  br label %74

72:                                               ; preds = %74
  %73 = call zeroext i1 @sc_buf_shrink(ptr noundef nonnull %2, i64 noundef 0) #5
  br label %77

74:                                               ; preds = %68, %74
  %indvars.iv = phi i64 [ 0, %68 ], [ %indvars.iv.next, %74 ]
  call void @sc_buf_put_64(ptr noundef nonnull %2, i64 noundef %indvars.iv) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 4000
  br i1 %exitcond.not, label %72, label %74, !llvm.loop !5

75:                                               ; preds = %77
  %76 = call zeroext i1 @sc_buf_shrink(ptr noundef nonnull %2, i64 noundef 4096) #5
  br label %82

77:                                               ; preds = %72, %77
  %.0811 = phi i32 [ 0, %72 ], [ %79, %77 ]
  %78 = call i64 @sc_buf_get_64(ptr noundef nonnull %2) #5
  %79 = add nuw nsw i32 %.0811, 1
  %exitcond14.not = icmp eq i32 %79, 3700
  br i1 %exitcond14.not, label %75, label %77, !llvm.loop !7

80:                                               ; preds = %82
  %indvars.iv.next16 = add nuw nsw i64 %indvars.iv15, 1
  %exitcond19.not = icmp eq i64 %indvars.iv.next16, 300
  br i1 %exitcond19.not, label %81, label %82, !llvm.loop !8

81:                                               ; preds = %80
  call void @sc_buf_term(ptr noundef nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #5
  ret void

82:                                               ; preds = %75, %80
  %indvars.iv15 = phi i64 [ 0, %75 ], [ %indvars.iv.next16, %80 ]
  %83 = call i64 @sc_buf_get_64(ptr noundef nonnull %2) #5
  %84 = add nuw nsw i64 %indvars.iv15, 3700
  %85 = icmp eq i64 %83, %84
  br i1 %85, label %80, label %86

86:                                               ; preds = %82
  call void @__assert_fail(ptr noundef nonnull @.str.85, ptr noundef nonnull @.str.1, i32 noundef 357, ptr noundef nonnull @__PRETTY_FUNCTION__.test2) #6
  unreachable
}

declare void @sc_buf_set_64_at(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare i64 @sc_buf_peek_64_at(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @sc_buf_set_32_at(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @sc_buf_peek_32_at(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @sc_buf_set_8_at(ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @sc_buf_set_64(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i64 @sc_buf_peek_64(ptr noundef) local_unnamed_addr #1

declare i32 @sc_buf_peek_32(ptr noundef) local_unnamed_addr #1

declare void @sc_buf_set_32(ptr noundef, i32 noundef) local_unnamed_addr #1

declare zeroext i1 @sc_buf_reserve(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @sc_buf_set_8(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @sc_buf_set_16(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

declare i64 @sc_buf_set_data(ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare i64 @sc_buf_peek_data(ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare zeroext i1 @sc_buf_shrink(ptr noundef, i64 noundef) local_unnamed_addr #1

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


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