; LLVM IR from golems/ach :: src/achd (transport)

; 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.achd_cx = type { %struct.achd_headers, i32, i32, i32, i32, ptr, i32, %struct.ach_channel, ptr }
%struct.achd_headers = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr, ptr, i32, i32, ptr }
%struct.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }
%struct.achd_conn = type { i32, %struct.timespec, %struct.timespec, %struct.achd_headers, %struct.achd_headers, i32, i32, i32, i64, ptr, ptr, ptr }
%struct.timespec = type { i64, i64 }
%struct.ach_pipe_frame_t = type { [8 x i8], [8 x i8], [1 x i8] }

@cx = external global %struct.achd_cx, align 8
@ach_verbosity = external global i32, align 4
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 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
declare ptr @strerror(i32 noundef) #1

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

declare void @ach_log(i32 noundef, ptr noundef, ...) #3

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

declare i64 @ach_pipe_get_size(ptr noundef) #3

declare i32 @achd_reconnect(ptr noundef) #3

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

7:                                                ; preds = %151, %1
  %8 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !9
  %9 = icmp ne i32 %8, 0
  %10 = xor i1 %9, true
  br i1 %10, label %11, label %152

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !16
  br label %12

12:                                               ; preds = %141, %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.achd_conn, ptr %13, i32 0, i32 5
  %15 = load i32, ptr %14, align 8, !tbaa !17
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.achd_conn, ptr %16, i32 0, i32 9
  %18 = load ptr, ptr %17, align 8, !tbaa !20
  %19 = call i64 @achd_read(i32 noundef %15, ptr noundef %18, i64 noundef 16)
  store i64 %19, ptr %5, align 8, !tbaa !16
  %20 = load i64, ptr %5, align 8, !tbaa !16
  %21 = icmp sle i64 %20, 0
  br i1 %21, label %22, label %39

22:                                               ; preds = %12
  %23 = load i32, ptr @ach_verbosity, align 4, !tbaa !15
  %24 = add nsw i32 5, %23
  %25 = icmp sle i32 7, %24
  br i1 %25, label %26, label %32

26:                                               ; preds = %22
  %27 = call ptr @__errno_location() #7
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = call ptr @strerror(i32 noundef %28) #6
  %30 = call ptr @__errno_location() #7
  %31 = load i32, ptr %30, align 4, !tbaa !15
  call void (i32, ptr, ...) @ach_log(i32 noundef 7, ptr noundef @.str.8, ptr noundef %29, i32 noundef %31)
  br label %32

32:                                               ; preds = %26, %22
  %33 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 3), align 8, !tbaa !21
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = call i32 @achd_reconnect(ptr noundef %36)
  br label %38

38:                                               ; preds = %35, %32
  br label %131

39:                                               ; preds = %12
  %40 = load i64, ptr %5, align 8, !tbaa !16
  %41 = icmp ne i64 16, %40
  br i1 %41, label %42, label %54

42:                                               ; preds = %39
  %43 = load i32, ptr @ach_verbosity, align 4, !tbaa !15
  %44 = add nsw i32 5, %43
  %45 = icmp sle i32 3, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.9)
  br label %47

47:                                               ; preds = %46, %42
  %48 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 3), align 8, !tbaa !21
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = call i32 @achd_reconnect(ptr noundef %51)
  br label %53

53:                                               ; preds = %50, %47
  br label %130

54:                                               ; preds = %39
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.achd_conn, ptr %55, i32 0, i32 9
  %57 = load ptr, ptr %56, align 8, !tbaa !20
  %58 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [8 x i8], ptr %58, i64 0, i64 0
  %60 = call i32 @memcmp(ptr noundef @.str.10, ptr noundef %59, i64 noundef 8) #8
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %74

62:                                               ; preds = %54
  %63 = load i32, ptr @ach_verbosity, align 4, !tbaa !15
  %64 = add nsw i32 5, %63
  %65 = icmp sle i32 3, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.11)
  br label %67

67:                                               ; preds = %66, %62
  %68 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 3), align 8, !tbaa !21
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %73

70:                                               ; preds = %67
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = call i32 @achd_reconnect(ptr noundef %71)
  br label %73

73:                                               ; preds = %70, %67
  br label %129

74:                                               ; preds = %54
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.achd_conn, ptr %75, i32 0, i32 9
  %77 = load ptr, ptr %76, align 8, !tbaa !20
  %78 = call i64 @ach_pipe_get_size(ptr noundef %77)
  store i64 %78, ptr %4, align 8, !tbaa !16
  %79 = load i64, ptr %4, align 8, !tbaa !16
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.achd_conn, ptr %80, i32 0, i32 8
  %82 = load i64, ptr %81, align 8, !tbaa !22
  %83 = icmp ugt i64 %79, %82
  br i1 %83, label %84, label %101

84:                                               ; preds = %74
  %85 = load i64, ptr %4, align 8, !tbaa !16
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.achd_conn, ptr %86, i32 0, i32 8
  store i64 %85, ptr %87, align 8, !tbaa !22
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.achd_conn, ptr %88, i32 0, i32 9
  %90 = load ptr, ptr %89, align 8, !tbaa !20
  call void @free(ptr noundef %90) #6
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.achd_conn, ptr %91, i32 0, i32 8
  %93 = load i64, ptr %92, align 8, !tbaa !22
  %94 = call ptr @ach_pipe_alloc(i64 noundef %93)
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.achd_conn, ptr %95, i32 0, i32 9
  store ptr %94, ptr %96, align 8, !tbaa !20
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.achd_conn, ptr %97, i32 0, i32 9
  %99 = load ptr, ptr %98, align 8, !tbaa !20
  %100 = load i64, ptr %4, align 8, !tbaa !16
  call void @ach_pipe_set_size(ptr noundef %99, i64 noundef %100)
  br label %101

101:                                              ; preds = %84, %74
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.achd_conn, ptr %102, i32 0, i32 5
  %104 = load i32, ptr %103, align 8, !tbaa !17
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.achd_conn, ptr %105, i32 0, i32 9
  %107 = load ptr, ptr %106, align 8, !tbaa !20
  %108 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %107, i32 0, i32 2
  %109 = getelementptr inbounds [1 x i8], ptr %108, i64 0, i64 0
  %110 = load i64, ptr %4, align 8, !tbaa !16
  %111 = call i64 @achd_read(i32 noundef %104, ptr noundef %109, i64 noundef %110)
  store i64 %111, ptr %5, align 8, !tbaa !16
  %112 = load i64, ptr %4, align 8, !tbaa !16
  %113 = load i64, ptr %5, align 8, !tbaa !16
  %114 = icmp ne i64 %112, %113
  br i1 %114, label %115, label %127

115:                                              ; preds = %101
  %116 = load i32, ptr @ach_verbosity, align 4, !tbaa !15
  %117 = add nsw i32 5, %116
  %118 = icmp sle i32 3, %117
  br i1 %118, label %119, label %120

119:                                              ; preds = %115
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.12)
  br label %120

120:                                              ; preds = %119, %115
  %121 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 3), align 8, !tbaa !21
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %126

123:                                              ; preds = %120
  %124 = load ptr, ptr %2, align 8, !tbaa !5
  %125 = call i32 @achd_reconnect(ptr noundef %124)
  br label %126

126:                                              ; preds = %123, %120
  br label %128

127:                                              ; preds = %101
  store i32 1, ptr %3, align 4, !tbaa !15
  br label %128

128:                                              ; preds = %127, %126
  br label %129

129:                                              ; preds = %128, %73
  br label %130

130:                                              ; preds = %129, %53
  br label %131

131:                                              ; preds = %130, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %132

132:                                              ; preds = %131
  %133 = load i32, ptr %3, align 4, !tbaa !15
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %141, label %135

135:                                              ; preds = %132
  %136 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !9
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %141, label %138

138:                                              ; preds = %135
  %139 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 3), align 8, !tbaa !21
  %140 = icmp ne i32 %139, 0
  br label %141

141:                                              ; preds = %138, %135, %132
  %142 = phi i1 [ false, %135 ], [ false, %132 ], [ %140, %138 ]
  br i1 %142, label %12, label %143, !llvm.loop !23

143:                                              ; preds = %141
  %144 = load i32, ptr %3, align 4, !tbaa !15
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %147, label %146

146:                                              ; preds = %143
  store i32 1, ptr %6, align 4
  br label %149

147:                                              ; preds = %143
  %148 = load ptr, ptr %2, align 8, !tbaa !5
  call void @put_frame(ptr noundef %148)
  store i32 0, ptr %6, align 4
  br label %149

149:                                              ; preds = %147, %146
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  %150 = load i32, ptr %6, align 4
  switch i32 %150, label %153 [
    i32 0, label %151
    i32 1, label %152
  ]

151:                                              ; preds = %149
  br label %7, !llvm.loop !25

152:                                              ; preds = %149, %7
  ret void

153:                                              ; preds = %149
  unreachable
}

declare i64 @achd_read(i32 noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

declare ptr @ach_pipe_alloc(i64 noundef) #3

declare void @ach_pipe_set_size(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @put_frame(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { 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, !12, i64 112}
!10 = !{!"achd_cx", !11, i64 0, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !6, i64 104, !12, i64 112, !14, i64 120, !6, i64 248}
!11 = !{!"achd_headers", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !13, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !6, i64 80}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"ach_channel", !7, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!18, !12, i64 216}
!18 = !{!"achd_conn", !12, i64 0, !19, i64 8, !19, i64 24, !11, i64 40, !11, i64 128, !12, i64 216, !12, i64 220, !12, i64 224, !13, i64 232, !6, i64 240, !6, i64 248, !6, i64 256}
!19 = !{!"timespec", !13, i64 0, !13, i64 8}
!20 = !{!18, !6, i64 240}
!21 = !{!10, !12, i64 96}
!22 = !{!18, !13, i64 232}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


; 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.achd_cx = type { %struct.achd_headers, i32, i32, i32, i32, ptr, i32, %struct.ach_channel, ptr }
%struct.achd_headers = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr, ptr, i32, i32, ptr }
%struct.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }

@cx = external local_unnamed_addr global %struct.achd_cx, align 8
@ach_verbosity = external local_unnamed_addr global i32, align 4
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1

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

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

declare void @ach_log(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

declare i64 @ach_pipe_get_size(ptr noundef) local_unnamed_addr #2

declare i32 @achd_reconnect(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @achd_pull_tcp(ptr noundef %0) local_unnamed_addr #3 {
  %.old = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8, !tbaa !5
  %.not.old = icmp eq i32 %.old, 0
  br i1 %.not.old, label %.preheader, label %.thread

.preheader:                                       ; preds = %1
  %2 = getelementptr inbounds i8, ptr %0, i64 216
  %3 = getelementptr inbounds i8, ptr %0, i64 240
  %4 = getelementptr inbounds i8, ptr %0, i64 232
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %.preheader
  %5 = load i32, ptr %2, align 8, !tbaa !14
  %6 = load ptr, ptr %3, align 8, !tbaa !17
  %7 = tail call i64 @achd_read(i32 noundef %5, ptr noundef %6, i64 noundef 16) #6
  %8 = icmp slt i64 %7, 1
  br i1 %8, label %9, label %19

9:                                                ; preds = %.backedge
  %10 = load i32, ptr @ach_verbosity, align 4, !tbaa !18
  %11 = icmp sgt i32 %10, 1
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = tail call ptr @__errno_location() #7
  %14 = load i32, ptr %13, align 4, !tbaa !18
  %15 = tail call ptr @strerror(i32 noundef %14) #6
  %16 = load i32, ptr %13, align 4, !tbaa !18
  tail call void (i32, ptr, ...) @ach_log(i32 noundef 7, ptr noundef nonnull @.str.8, ptr noundef %15, i32 noundef %16) #6
  br label %17

17:                                               ; preds = %12, %9
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 96), align 8, !tbaa !19
  %.not39 = icmp eq i32 %18, 0
  br i1 %.not39, label %54, label %.sink.split

19:                                               ; preds = %.backedge
  %.not33 = icmp eq i64 %7, 16
  br i1 %.not33, label %26, label %20

20:                                               ; preds = %19
  %21 = load i32, ptr @ach_verbosity, align 4, !tbaa !18
  %22 = icmp sgt i32 %21, -3
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  tail call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.9) #6
  br label %24

24:                                               ; preds = %23, %20
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 96), align 8, !tbaa !19
  %.not38 = icmp eq i32 %25, 0
  br i1 %.not38, label %54, label %.sink.split

26:                                               ; preds = %19
  %27 = load ptr, ptr %3, align 8, !tbaa !17
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) @.str.10, ptr noundef nonnull dereferenceable(8) %27, i64 8)
  %.not34 = icmp eq i32 %bcmp, 0
  br i1 %.not34, label %34, label %28

28:                                               ; preds = %26
  %29 = load i32, ptr @ach_verbosity, align 4, !tbaa !18
  %30 = icmp sgt i32 %29, -3
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  tail call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.11) #6
  br label %32

32:                                               ; preds = %31, %28
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 96), align 8, !tbaa !19
  %.not37 = icmp eq i32 %33, 0
  br i1 %.not37, label %54, label %.sink.split

34:                                               ; preds = %26
  %35 = tail call i64 @ach_pipe_get_size(ptr noundef %27) #6
  %36 = load i64, ptr %4, align 8, !tbaa !20
  %37 = icmp ugt i64 %35, %36
  br i1 %37, label %38, label %42

38:                                               ; preds = %34
  store i64 %35, ptr %4, align 8, !tbaa !20
  %39 = load ptr, ptr %3, align 8, !tbaa !17
  tail call void @free(ptr noundef %39) #6
  %40 = load i64, ptr %4, align 8, !tbaa !20
  %41 = tail call ptr @ach_pipe_alloc(i64 noundef %40) #6
  store ptr %41, ptr %3, align 8, !tbaa !17
  tail call void @ach_pipe_set_size(ptr noundef %41, i64 noundef %35) #6
  br label %42

42:                                               ; preds = %38, %34
  %43 = load i32, ptr %2, align 8, !tbaa !14
  %44 = load ptr, ptr %3, align 8, !tbaa !17
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %46 = tail call i64 @achd_read(i32 noundef %43, ptr noundef nonnull %45, i64 noundef %35) #6
  %.not35 = icmp eq i64 %35, %46
  br i1 %.not35, label %.critedge, label %47

47:                                               ; preds = %42
  %48 = load i32, ptr @ach_verbosity, align 4, !tbaa !18
  %49 = icmp sgt i32 %48, -3
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  tail call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.12) #6
  br label %51

51:                                               ; preds = %50, %47
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 96), align 8, !tbaa !19
  %.not36 = icmp eq i32 %52, 0
  br i1 %.not36, label %54, label %.sink.split

.sink.split:                                      ; preds = %51, %32, %24, %17
  %53 = tail call i32 @achd_reconnect(ptr noundef nonnull %0) #6
  br label %54

54:                                               ; preds = %.sink.split, %24, %51, %32, %17
  %55 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8
  %56 = icmp eq i32 %55, 0
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 96), align 8
  %58 = icmp ne i32 %57, 0
  %or.cond3 = select i1 %56, i1 %58, i1 false
  br i1 %or.cond3, label %.backedge.backedge, label %.thread

.backedge.backedge:                               ; preds = %54, %.critedge
  br label %.backedge, !llvm.loop !21

.critedge:                                        ; preds = %42
  tail call void @put_frame(ptr noundef nonnull %0)
  %59 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8
  %.not = icmp eq i32 %59, 0
  br i1 %.not, label %.backedge.backedge, label %.thread

.thread:                                          ; preds = %54, %.critedge, %1
  ret void
}

declare i64 @achd_read(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

declare ptr @ach_pipe_alloc(i64 noundef) local_unnamed_addr #2

declare void @ach_pipe_set_size(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @put_frame(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5

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 = { 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 #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 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 112}
!6 = !{!"achd_cx", !7, i64 0, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !8, i64 104, !11, i64 112, !13, i64 120, !8, i64 248}
!7 = !{!"achd_headers", !8, i64 0, !8, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !12, i64 48, !8, i64 56, !8, i64 64, !11, i64 72, !11, i64 76, !8, i64 80}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!"ach_channel", !9, i64 0}
!14 = !{!15, !11, i64 216}
!15 = !{!"achd_conn", !11, i64 0, !16, i64 8, !16, i64 24, !7, i64 40, !7, i64 128, !11, i64 216, !11, i64 220, !11, i64 224, !12, i64 232, !8, i64 240, !8, i64 248, !8, i64 256}
!16 = !{!"timespec", !12, i64 0, !12, i64 8}
!17 = !{!15, !8, i64 240}
!18 = !{!11, !11, i64 0}
!19 = !{!6, !11, i64 96}
!20 = !{!15, !12, i64 232}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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