; LLVM IR from golems/ach :: src (achpipe-bin)

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

@opt_last = external dso_local global i32, align 4
@opt_sync = external dso_local global i32, align 4
@opt_freq = external dso_local global double, align 8
@sig_received = external dso_local global i32, align 4
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [62 x i8], align 1
@__PRETTY_FUNCTION__.subscribe = external hidden unnamed_addr constant [39 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @verbprintf(i32 noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @hard_assert(i32 noundef, ptr noundef, ...) #0

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

declare ptr @ach_result_to_string(i32 noundef) #2

declare ptr @ach_pipe_alloc(i64 noundef) #2

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

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

declare i64 @ach_pipe_get_size(ptr noundef) #2

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

declare i32 @ach_close(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @subscribe(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.ach_channel, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.timespec, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca [4 x i8], align 1
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void (i32, ptr, ...) @verbprintf(i32 noundef 1, ptr noundef @.str.7)
  %23 = load i32, ptr @opt_sync, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, ptr @.str.9, ptr @.str.10
  call void (i32, ptr, ...) @verbprintf(i32 noundef 1, ptr noundef @.str.8, ptr noundef %26)
  call void @llvm.lifetime.start.p0(i64 128, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call i32 @ach_open(ptr noundef %7, ptr noundef %27, ptr noundef null)
  store i32 %28, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = icmp eq i32 0, %29
  %31 = zext i1 %30 to i32
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = call ptr @ach_result_to_string(i32 noundef %33)
  call void (i32, ptr, ...) @hard_assert(i32 noundef %31, ptr noundef @.str.11, ptr noundef %32, ptr noundef %34)
  %35 = call i32 @ach_flush(ptr noundef %7)
  store i32 %35, ptr %8, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = icmp eq i32 0, %36
  %38 = zext i1 %37 to i32
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = call ptr @ach_result_to_string(i32 noundef %40)
  call void (i32, ptr, ...) @hard_assert(i32 noundef %38, ptr noundef @.str.12, ptr noundef %39, ptr noundef %41)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 512, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %42 = load i64, ptr %9, align 8, !tbaa !11
  %43 = call ptr @ach_pipe_alloc(i64 noundef %42)
  store ptr %43, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #7
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  %44 = load double, ptr @opt_freq, align 8, !tbaa !13
  %45 = fcmp ogt double %44, 0.000000e+00
  br i1 %45, label %46, label %60

46:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %47 = load double, ptr @opt_freq, align 8, !tbaa !13
  %48 = fdiv double 1.000000e+00, %47
  store double %48, ptr %14, align 8, !tbaa !13
  %49 = load double, ptr %14, align 8, !tbaa !13
  %50 = fptosi double %49 to i64
  %51 = getelementptr inbounds %struct.timespec, ptr %12, i32 0, i32 0
  store i64 %50, ptr %51, align 8, !tbaa !15
  %52 = load double, ptr %14, align 8, !tbaa !13
  %53 = getelementptr inbounds %struct.timespec, ptr %12, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !15
  %55 = sitofp i64 %54 to double
  %56 = fsub double %52, %55
  %57 = fmul double %56, 1.000000e+09
  %58 = fptosi double %57 to i64
  %59 = getelementptr inbounds %struct.timespec, ptr %12, i32 0, i32 1
  store i64 %58, ptr %59, align 8, !tbaa !17
  store i32 1, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %60

60:                                               ; preds = %46, %3
  br label %61

61:                                               ; preds = %216, %60
  %62 = load i32, ptr @sig_received, align 4, !tbaa !9
  %63 = icmp ne i32 %62, 0
  %64 = xor i1 %63, true
  br i1 %64, label %65, label %217

65:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  call void @llvm.memset.p0.i64(ptr align 1 %15, i8 0, i64 4, i1 false)
  %66 = load i32, ptr @opt_sync, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %77

68:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %69 = getelementptr inbounds [4 x i8], ptr %15, i64 0, i64 0
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call i64 @fread(ptr noundef %69, i64 noundef 1, i64 noundef 4, ptr noundef %70)
  store i64 %71, ptr %16, align 8, !tbaa !11
  %72 = load i64, ptr %16, align 8, !tbaa !11
  %73 = icmp eq i64 4, %72
  %74 = zext i1 %73 to i32
  %75 = load i64, ptr %16, align 8, !tbaa !11
  call void (i32, ptr, ...) @hard_assert(i32 noundef %74, ptr noundef @.str.13, i64 noundef %75)
  %76 = getelementptr inbounds [4 x i8], ptr %15, i64 0, i64 0
  call void (i32, ptr, ...) @verbprintf(i32 noundef 2, ptr noundef @.str.14, ptr noundef %76)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %77

77:                                               ; preds = %68, %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %168, %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  store i64 0, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 11, ptr %19, align 4, !tbaa !9
  %79 = load i32, ptr @opt_sync, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %116

81:                                               ; preds = %78
  %82 = getelementptr inbounds [4 x i8], ptr %15, i64 0, i64 0
  %83 = call i32 @memcmp(ptr noundef @.str.15, ptr noundef %82, i64 noundef 4) #8
  %84 = icmp eq i32 0, %83
  br i1 %84, label %85, label %91

85:                                               ; preds = %81
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %86, i32 0, i32 2
  %88 = getelementptr inbounds [1 x i8], ptr %87, i64 0, i64 0
  %89 = load i64, ptr %9, align 8, !tbaa !11
  %90 = call i32 @ach_get(ptr noundef %7, ptr noundef %88, i64 noundef %89, ptr noundef %18, ptr noundef null, i32 noundef 1)
  store i32 %90, ptr %19, align 4, !tbaa !9
  br label %115

91:                                               ; preds = %81
  %92 = getelementptr inbounds [4 x i8], ptr %15, i64 0, i64 0
  %93 = call i32 @memcmp(ptr noundef @.str.16, ptr noundef %92, i64 noundef 4) #8
  %94 = icmp eq i32 0, %93
  br i1 %94, label %95, label %101

95:                                               ; preds = %91
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds [1 x i8], ptr %97, i64 0, i64 0
  %99 = load i64, ptr %9, align 8, !tbaa !11
  %100 = call i32 @ach_get(ptr noundef %7, ptr noundef %98, i64 noundef %99, ptr noundef %18, ptr noundef null, i32 noundef 3)
  store i32 %100, ptr %19, align 4, !tbaa !9
  br label %114

101:                                              ; preds = %91
  %102 = getelementptr inbounds [4 x i8], ptr %15, i64 0, i64 0
  %103 = call i32 @memcmp(ptr noundef @.str.17, ptr noundef %102, i64 noundef 4) #8
  %104 = icmp eq i32 0, %103
  br i1 %104, label %105, label %111

105:                                              ; preds = %101
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %106, i32 0, i32 2
  %108 = getelementptr inbounds [1 x i8], ptr %107, i64 0, i64 0
  %109 = load i64, ptr %9, align 8, !tbaa !11
  %110 = call i32 @ach_get(ptr noundef %7, ptr noundef %108, i64 noundef %109, ptr noundef %18, ptr noundef null, i32 noundef 6)
  store i32 %110, ptr %19, align 4, !tbaa !9
  br label %113

111:                                              ; preds = %101
  %112 = getelementptr inbounds [4 x i8], ptr %15, i64 0, i64 0
  call void (i32, ptr, ...) @hard_assert(i32 noundef 0, ptr noundef @.str.18, ptr noundef %112)
  br label %113

113:                                              ; preds = %111, %105
  br label %114

114:                                              ; preds = %113, %95
  br label %115

115:                                              ; preds = %114, %85
  br label %136

116:                                              ; preds = %78
  %117 = load i32, ptr @opt_last, align 4, !tbaa !9
  %118 = icmp ne i32 %117, 0
  br i1 %118, label %122, label %119

119:                                              ; preds = %116
  %120 = load i32, ptr %13, align 4, !tbaa !9
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %128

122:                                              ; preds = %119, %116
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %123, i32 0, i32 2
  %125 = getelementptr inbounds [1 x i8], ptr %124, i64 0, i64 0
  %126 = load i64, ptr %9, align 8, !tbaa !11
  %127 = call i32 @ach_get(ptr noundef %7, ptr noundef %125, i64 noundef %126, ptr noundef %18, ptr noundef null, i32 noundef 3)
  br label %134

128:                                              ; preds = %119
  %129 = load ptr, ptr %10, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %129, i32 0, i32 2
  %131 = getelementptr inbounds [1 x i8], ptr %130, i64 0, i64 0
  %132 = load i64, ptr %9, align 8, !tbaa !11
  %133 = call i32 @ach_get(ptr noundef %7, ptr noundef %131, i64 noundef %132, ptr noundef %18, ptr noundef null, i32 noundef 1)
  br label %134

134:                                              ; preds = %128, %122
  %135 = phi i32 [ %127, %122 ], [ %133, %128 ]
  store i32 %135, ptr %19, align 4, !tbaa !9
  br label %136

136:                                              ; preds = %134, %115
  %137 = load i32, ptr %19, align 4, !tbaa !9
  %138 = icmp eq i32 1, %137
  br i1 %138, label %139, label %150

139:                                              ; preds = %136
  %140 = load i64, ptr %18, align 8, !tbaa !11
  %141 = load i64, ptr %9, align 8, !tbaa !11
  %142 = icmp ugt i64 %140, %141
  br i1 %142, label %143, label %144

143:                                              ; preds = %139
  br label %145

144:                                              ; preds = %139
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.20, i32 noundef 444, ptr noundef @__PRETTY_FUNCTION__.subscribe) #9
  unreachable

145:                                              ; preds = %143
  %146 = load i64, ptr %18, align 8, !tbaa !11
  store i64 %146, ptr %9, align 8, !tbaa !11
  %147 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %147) #7
  %148 = load i64, ptr %9, align 8, !tbaa !11
  %149 = call ptr @ach_pipe_alloc(i64 noundef %148)
  store ptr %149, ptr %10, align 8, !tbaa !5
  br label %167

150:                                              ; preds = %136
  %151 = load i32, ptr %19, align 4, !tbaa !9
  %152 = icmp eq i32 0, %151
  br i1 %152, label %159, label %153

153:                                              ; preds = %150
  %154 = load i32, ptr %19, align 4, !tbaa !9
  %155 = icmp eq i32 6, %154
  br i1 %155, label %159, label %156

156:                                              ; preds = %153
  %157 = load i32, ptr %11, align 4, !tbaa !9
  %158 = icmp ne i32 %157, 0
  br i1 %158, label %159, label %163

159:                                              ; preds = %156, %153, %150
  store i32 1, ptr %17, align 4, !tbaa !9
  %160 = load ptr, ptr %10, align 8, !tbaa !5
  %161 = load i64, ptr %18, align 8, !tbaa !11
  call void @ach_pipe_set_size(ptr noundef %160, i64 noundef %161)
  %162 = load i64, ptr %18, align 8, !tbaa !11
  call void (i32, ptr, ...) @verbprintf(i32 noundef 2, ptr noundef @.str.21, i64 noundef %162)
  br label %166

163:                                              ; preds = %156
  %164 = load i32, ptr %19, align 4, !tbaa !9
  %165 = call ptr @ach_result_to_string(i32 noundef %164)
  call void (i32, ptr, ...) @hard_assert(i32 noundef 0, ptr noundef @.str.22, ptr noundef %165)
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.20, i32 noundef 456, ptr noundef @__PRETTY_FUNCTION__.subscribe) #9
  unreachable

166:                                              ; preds = %159
  br label %167

167:                                              ; preds = %166, %145
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %168

168:                                              ; preds = %167
  %169 = load i32, ptr %17, align 4, !tbaa !9
  %170 = icmp ne i32 %169, 0
  %171 = xor i1 %170, true
  br i1 %171, label %78, label %172, !llvm.loop !18

172:                                              ; preds = %168
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  %174 = call i64 @ach_pipe_get_size(ptr noundef %173)
  %175 = add i64 16, %174
  store i64 %175, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %176 = load ptr, ptr %10, align 8, !tbaa !5
  %177 = load i64, ptr %20, align 8, !tbaa !11
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = call i64 @fwrite(ptr noundef %176, i64 noundef 1, i64 noundef %177, ptr noundef %178)
  store i64 %179, ptr %21, align 8, !tbaa !11
  %180 = load i64, ptr %21, align 8, !tbaa !11
  %181 = load i64, ptr %20, align 8, !tbaa !11
  %182 = icmp ne i64 %180, %181
  br i1 %182, label %183, label %184

183:                                              ; preds = %172
  store i32 3, ptr %22, align 4
  br label %197

184:                                              ; preds = %172
  %185 = load ptr, ptr %5, align 8, !tbaa !5
  %186 = call i32 @fflush(ptr noundef %185)
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %189

188:                                              ; preds = %184
  store i32 3, ptr %22, align 4
  br label %197

189:                                              ; preds = %184
  %190 = load i32, ptr @opt_sync, align 4, !tbaa !9
  %191 = icmp ne i32 %190, 0
  br i1 %191, label %192, label %196

192:                                              ; preds = %189
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  %194 = call i32 @fileno(ptr noundef %193) #7
  %195 = call i32 @fsync(i32 noundef %194)
  br label %196

196:                                              ; preds = %192, %189
  call void (i32, ptr, ...) @verbprintf(i32 noundef 2, ptr noundef @.str.24)
  store i32 0, ptr %22, align 4
  br label %197

197:                                              ; preds = %196, %188, %183
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  %198 = load i32, ptr %22, align 4
  switch i32 %198, label %214 [
    i32 0, label %199
  ]

199:                                              ; preds = %197
  store i32 0, ptr %11, align 4, !tbaa !9
  %200 = load i32, ptr %13, align 4, !tbaa !9
  %201 = icmp ne i32 %200, 0
  br i1 %201, label %202, label %213

202:                                              ; preds = %199
  %203 = load i32, ptr @opt_sync, align 4, !tbaa !9
  %204 = icmp ne i32 %203, 0
  br i1 %204, label %206, label %205

205:                                              ; preds = %202
  br label %207

206:                                              ; preds = %202
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.20, i32 noundef 477, ptr noundef @__PRETTY_FUNCTION__.subscribe) #9
  unreachable

207:                                              ; preds = %205
  %208 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 0
  %209 = load i64, ptr %208, align 8
  %210 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 1
  %211 = load i64, ptr %210, align 8
  %212 = call i32 @_relsleep(i64 %209, i64 %211)
  br label %213

213:                                              ; preds = %207, %199
  store i32 0, ptr %22, align 4
  br label %214

214:                                              ; preds = %213, %197
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  %215 = load i32, ptr %22, align 4
  switch i32 %215, label %220 [
    i32 0, label %216
    i32 3, label %217
  ]

216:                                              ; preds = %214
  br label %61, !llvm.loop !20

217:                                              ; preds = %214, %61
  %218 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %218) #7
  %219 = call i32 @ach_close(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr %7) #7
  ret void

220:                                              ; preds = %214
  unreachable
}

declare i32 @ach_flush(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i32 @ach_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef) #2

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

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare i32 @fflush(ptr noundef) #2

declare i32 @fsync(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @_relsleep(i64, i64) #0

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !12, i64 0}
!16 = !{!"timespec", !12, i64 0, !12, i64 8}
!17 = !{!16, !12, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }

@opt_last = external dso_local local_unnamed_addr global i32, align 4
@opt_sync = external dso_local local_unnamed_addr global i32, align 4
@opt_freq = external dso_local local_unnamed_addr global double, align 8
@sig_received = external dso_local local_unnamed_addr global i32, align 4
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [62 x i8], align 1
@__PRETTY_FUNCTION__.subscribe = external hidden unnamed_addr constant [39 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @verbprintf(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @hard_assert(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

declare i32 @ach_open(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @ach_result_to_string(i32 noundef) local_unnamed_addr #2

declare ptr @ach_pipe_alloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

declare i64 @ach_pipe_get_size(ptr 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 i32 @ach_close(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @subscribe(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.ach_channel, align 8
  %5 = alloca [4 x i8], align 4
  %6 = alloca i64, align 8
  tail call void (i32, ptr, ...) @verbprintf(i32 noundef 1, ptr noundef nonnull @.str.7)
  %7 = load i32, ptr @opt_sync, align 4, !tbaa !5
  %.not = icmp eq i32 %7, 0
  %8 = select i1 %.not, ptr @.str.10, ptr @.str.9
  tail call void (i32, ptr, ...) @verbprintf(i32 noundef 1, ptr noundef nonnull @.str.8, ptr noundef nonnull %8)
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %4) #7
  %9 = call i32 @ach_open(ptr noundef nonnull %4, ptr noundef %2, ptr noundef null) #7
  %10 = icmp eq i32 %9, 0
  %11 = zext i1 %10 to i32
  %12 = call ptr @ach_result_to_string(i32 noundef %9) #7
  call void (i32, ptr, ...) @hard_assert(i32 noundef %11, ptr noundef nonnull @.str.11, ptr noundef %2, ptr noundef %12)
  %13 = call i32 @ach_flush(ptr noundef nonnull %4) #7
  %14 = icmp eq i32 %13, 0
  %15 = zext i1 %14 to i32
  %16 = call ptr @ach_result_to_string(i32 noundef %13) #7
  call void (i32, ptr, ...) @hard_assert(i32 noundef %15, ptr noundef nonnull @.str.12, ptr noundef %2, ptr noundef %16)
  %17 = call ptr @ach_pipe_alloc(i64 noundef 512) #7
  %18 = load double, ptr @opt_freq, align 8, !tbaa !9
  %19 = fcmp ogt double %18, 0.000000e+00
  br i1 %19, label %20, label %27

20:                                               ; preds = %3
  %21 = fdiv double 1.000000e+00, %18
  %22 = fptosi double %21 to i64
  %23 = sitofp i64 %22 to double
  %24 = fsub double %21, %23
  %25 = fmul double %24, 1.000000e+09
  %26 = fptosi double %25 to i64
  br label %27

27:                                               ; preds = %20, %3
  %.sroa.6.0 = phi i64 [ %26, %20 ], [ 0, %3 ]
  %.sroa.0.0 = phi i64 [ %22, %20 ], [ 0, %3 ]
  %28 = load i32, ptr @sig_received, align 4, !tbaa !5
  %.not65114 = icmp eq i32 %28, 0
  br i1 %.not65114, label %.lr.ph, label %.loopexit98

.lr.ph:                                           ; preds = %27, %89
  %.052116 = phi i64 [ %.153, %89 ], [ 512, %27 ]
  %.054115 = phi ptr [ %.155, %89 ], [ %17, %27 ]
  %29 = phi i1 [ false, %89 ], [ true, %27 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  store i32 0, ptr %5, align 4
  %30 = load i32, ptr @opt_sync, align 4, !tbaa !5
  %.not66 = icmp eq i32 %30, 0
  br i1 %.not66, label %.preheader, label %31

31:                                               ; preds = %.lr.ph
  %32 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 1, i64 noundef 4, ptr noundef %0)
  %33 = icmp eq i64 %32, 4
  %34 = zext i1 %33 to i32
  call void (i32, ptr, ...) @hard_assert(i32 noundef %34, ptr noundef nonnull @.str.13, i64 noundef %32)
  call void (i32, ptr, ...) @verbprintf(i32 noundef 2, ptr noundef nonnull @.str.14, ptr noundef nonnull %5)
  br label %.preheader

.preheader:                                       ; preds = %31, %.lr.ph
  br label %35

35:                                               ; preds = %.preheader, %68
  %.155 = phi ptr [ %69, %68 ], [ %.054115, %.preheader ]
  %.153 = phi i64 [ %63, %68 ], [ %.052116, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i64 0, ptr %6, align 8, !tbaa !11
  %36 = load i32, ptr @opt_sync, align 4, !tbaa !5
  %.not67 = icmp eq i32 %36, 0
  br i1 %.not67, label %52, label %37

37:                                               ; preds = %35
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(4) @.str.15, ptr noundef nonnull dereferenceable(4) %5, i64 4)
  %38 = icmp eq i32 %bcmp, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %37
  %40 = getelementptr inbounds i8, ptr %.155, i64 16
  %41 = call i32 @ach_get(ptr noundef nonnull %4, ptr noundef nonnull %40, i64 noundef %.153, ptr noundef nonnull %6, ptr noundef null, i32 noundef 1) #7
  br label %60

42:                                               ; preds = %37
  %bcmp96 = call i32 @bcmp(ptr noundef nonnull dereferenceable(4) @.str.16, ptr noundef nonnull dereferenceable(4) %5, i64 4)
  %43 = icmp eq i32 %bcmp96, 0
  br i1 %43, label %44, label %47

44:                                               ; preds = %42
  %45 = getelementptr inbounds i8, ptr %.155, i64 16
  %46 = call i32 @ach_get(ptr noundef nonnull %4, ptr noundef nonnull %45, i64 noundef %.153, ptr noundef nonnull %6, ptr noundef null, i32 noundef 3) #7
  br label %60

47:                                               ; preds = %42
  %bcmp97 = call i32 @bcmp(ptr noundef nonnull dereferenceable(4) @.str.17, ptr noundef nonnull dereferenceable(4) %5, i64 4)
  %48 = icmp eq i32 %bcmp97, 0
  br i1 %48, label %49, label %.thread

49:                                               ; preds = %47
  %50 = getelementptr inbounds i8, ptr %.155, i64 16
  %51 = call i32 @ach_get(ptr noundef nonnull %4, ptr noundef nonnull %50, i64 noundef %.153, ptr noundef nonnull %6, ptr noundef null, i32 noundef 6) #7
  br label %60

.thread:                                          ; preds = %47
  call void (i32, ptr, ...) @hard_assert(i32 noundef 0, ptr noundef nonnull @.str.18, ptr noundef nonnull %5)
  br label %.loopexit

52:                                               ; preds = %35
  %53 = load i32, ptr @opt_last, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 0
  %or.cond = or i1 %19, %54
  %55 = getelementptr inbounds i8, ptr %.155, i64 16
  br i1 %or.cond, label %56, label %58

56:                                               ; preds = %52
  %57 = call i32 @ach_get(ptr noundef nonnull %4, ptr noundef nonnull %55, i64 noundef %.153, ptr noundef nonnull %6, ptr noundef null, i32 noundef 3) #7
  br label %60

58:                                               ; preds = %52
  %59 = call i32 @ach_get(ptr noundef nonnull %4, ptr noundef nonnull %55, i64 noundef %.153, ptr noundef nonnull %6, ptr noundef null, i32 noundef 1) #7
  br label %60

60:                                               ; preds = %56, %58, %39, %49, %44
  %.057 = phi i32 [ %41, %39 ], [ %46, %44 ], [ %51, %49 ], [ %57, %56 ], [ %59, %58 ]
  %61 = icmp eq i32 %.057, 1
  br i1 %61, label %62, label %.loopexit

62:                                               ; preds = %60
  %63 = load i64, ptr %6, align 8, !tbaa !11
  %64 = icmp ugt i64 %63, %.153
  br i1 %64, label %68, label %65

65:                                               ; preds = %62
  call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.20, i32 noundef 444, ptr noundef nonnull @__PRETTY_FUNCTION__.subscribe) #8
  unreachable

.loopexit:                                        ; preds = %60, %.thread
  %.05776 = phi i32 [ 11, %.thread ], [ %.057, %60 ]
  br i1 %29, label %70, label %switch.early.test

switch.early.test:                                ; preds = %.loopexit
  switch i32 %.05776, label %66 [
    i32 6, label %70
    i32 0, label %70
  ]

66:                                               ; preds = %switch.early.test
  %67 = call ptr @ach_result_to_string(i32 noundef %.05776) #7
  call void (i32, ptr, ...) @hard_assert(i32 noundef 0, ptr noundef nonnull @.str.22, ptr noundef %67)
  call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.20, i32 noundef 456, ptr noundef nonnull @__PRETTY_FUNCTION__.subscribe) #8
  unreachable

68:                                               ; preds = %62
  call void @free(ptr noundef %.155) #7
  %69 = call ptr @ach_pipe_alloc(i64 noundef %63) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %35, !llvm.loop !13

70:                                               ; preds = %.loopexit, %switch.early.test, %switch.early.test
  %71 = load i64, ptr %6, align 8, !tbaa !11
  call void @ach_pipe_set_size(ptr noundef %.155, i64 noundef %71) #7
  %72 = load i64, ptr %6, align 8, !tbaa !11
  call void (i32, ptr, ...) @verbprintf(i32 noundef 2, ptr noundef nonnull @.str.21, i64 noundef %72)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  %73 = call i64 @ach_pipe_get_size(ptr noundef %.155) #7
  %74 = add i64 %73, 16
  %75 = call i64 @fwrite(ptr noundef %.155, i64 noundef 1, i64 noundef %74, ptr noundef %1)
  %.not69 = icmp eq i64 %75, %74
  br i1 %.not69, label %76, label %.thread92

76:                                               ; preds = %70
  %77 = call i32 @fflush(ptr noundef %1)
  %.not70 = icmp eq i32 %77, 0
  br i1 %.not70, label %78, label %.thread92

78:                                               ; preds = %76
  %79 = load i32, ptr @opt_sync, align 4, !tbaa !5
  %.not71 = icmp eq i32 %79, 0
  br i1 %.not71, label %83, label %80

80:                                               ; preds = %78
  %81 = call i32 @fileno(ptr noundef %1) #7
  %82 = call i32 @fsync(i32 noundef %81) #7
  br label %83

.thread92:                                        ; preds = %76, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  br label %.loopexit98

83:                                               ; preds = %78, %80
  call void (i32, ptr, ...) @verbprintf(i32 noundef 2, ptr noundef nonnull @.str.24)
  br i1 %19, label %84, label %89

84:                                               ; preds = %83
  %85 = load i32, ptr @opt_sync, align 4, !tbaa !5
  %.not73 = icmp eq i32 %85, 0
  br i1 %.not73, label %87, label %86

86:                                               ; preds = %84
  call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.20, i32 noundef 477, ptr noundef nonnull @__PRETTY_FUNCTION__.subscribe) #8
  unreachable

87:                                               ; preds = %84
  %88 = call i32 @_relsleep(i64 %.sroa.0.0, i64 %.sroa.6.0)
  br label %89

89:                                               ; preds = %83, %87
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  %90 = load i32, ptr @sig_received, align 4, !tbaa !5
  %.not65 = icmp eq i32 %90, 0
  br i1 %.not65, label %.lr.ph, label %.loopexit98

.loopexit98:                                      ; preds = %89, %27, %.thread92
  %.3 = phi ptr [ %.155, %.thread92 ], [ %17, %27 ], [ %.155, %89 ]
  call void @free(ptr noundef %.3) #7
  %91 = call i32 @ach_close(ptr noundef nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %4) #7
  ret void
}

declare i32 @ach_flush(ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

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

declare i32 @fsync(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @_relsleep(i64, i64) local_unnamed_addr #0

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

attributes #0 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress 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 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind willreturn memory(argmem: read) }
attributes #7 = { nounwind }
attributes #8 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass