; LLVM IR from golems/ach :: src (event)

; 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.epoll_event = type <{ i32, %union.epoll_data }>
%union.epoll_data = type { ptr }
%struct.timespec = type { i64, i64 }
%struct.ach_evhandler = type { ptr, ptr, ptr }

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nounwind
declare i32 @clock_gettime(i32 noundef, ptr noundef) #5

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

declare i32 @close(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ach_evhandle_epoll(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #6 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca i8, align 1
  %21 = alloca i8, align 1
  %22 = alloca i32, align 4
  %23 = alloca %struct.epoll_event, align 1
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca %struct.timespec, align 8
  %28 = alloca %struct.timespec, align 8
  %29 = alloca %struct.epoll_event, align 1
  %30 = alloca i32, align 4
  %31 = alloca ptr, align 8
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  store i64 0, ptr %15, align 8, !tbaa !9
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = call ptr @llvm.stacksave.p0()
  store ptr %35, ptr %16, align 8
  %36 = alloca i32, i64 %34, align 16
  store i64 %34, ptr %17, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  store i32 -1, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #8
  %37 = load i32, ptr %13, align 4, !tbaa !11
  %38 = and i32 %37, 2
  %39 = icmp ne i32 %38, 0
  %40 = zext i1 %39 to i8
  store i8 %40, ptr %20, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #8
  %41 = load i32, ptr %13, align 4, !tbaa !11
  %42 = and i32 %41, 1
  %43 = icmp ne i32 %42, 0
  %44 = zext i1 %43 to i8
  store i8 %44, ptr %21, align 1, !tbaa !13
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %70, %6
  %46 = load i64, ptr %19, align 8, !tbaa !9
  %47 = load i64, ptr %9, align 8, !tbaa !9
  %48 = icmp ult i64 %46, %47
  br i1 %48, label %49, label %73

49:                                               ; preds = %45
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %19, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.ach_evhandler, ptr %50, i64 %51
  %53 = getelementptr inbounds %struct.ach_evhandler, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load i64, ptr %19, align 8, !tbaa !9
  %56 = getelementptr inbounds i32, ptr %36, i64 %55
  %57 = call i32 @ach_channel_map(ptr noundef %54, ptr noundef %56)
  store i32 %57, ptr %14, align 4, !tbaa !11
  %58 = icmp ne i32 0, %57
  br i1 %58, label %59, label %61

59:                                               ; preds = %49
  %60 = load i32, ptr %14, align 4, !tbaa !11
  store i32 %60, ptr %7, align 4
  store i32 1, ptr %22, align 4
  br label %266

61:                                               ; preds = %49
  %62 = load i64, ptr %19, align 8, !tbaa !9
  %63 = getelementptr inbounds i32, ptr %36, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !11
  %65 = icmp eq i32 3, %64
  br i1 %65, label %66, label %69

66:                                               ; preds = %61
  %67 = load i64, ptr %15, align 8, !tbaa !9
  %68 = add i64 %67, 1
  store i64 %68, ptr %15, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %66, %61
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %19, align 8, !tbaa !9
  %72 = add i64 %71, 1
  store i64 %72, ptr %19, align 8, !tbaa !9
  br label %45, !llvm.loop !17

73:                                               ; preds = %45
  %74 = load i64, ptr %15, align 8, !tbaa !9
  %75 = load i64, ptr %9, align 8, !tbaa !9
  %76 = icmp ne i64 %74, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %73
  store i32 12, ptr %7, align 4
  store i32 1, ptr %22, align 4
  br label %266

78:                                               ; preds = %73
  %79 = load i64, ptr %15, align 8, !tbaa !9
  %80 = icmp ne i64 %79, 0
  br i1 %80, label %81, label %125

81:                                               ; preds = %78
  %82 = call ptr @__errno_location() #9
  store i32 0, ptr %82, align 4, !tbaa !11
  %83 = call i32 @epoll_create1(i32 noundef 524288) #8
  store i32 %83, ptr %18, align 4, !tbaa !11
  %84 = icmp sgt i32 0, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %81
  br label %246

86:                                               ; preds = %81
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %87

87:                                               ; preds = %121, %86
  %88 = load i64, ptr %19, align 8, !tbaa !9
  %89 = load i64, ptr %9, align 8, !tbaa !9
  %90 = icmp ult i64 %88, %89
  br i1 %90, label %91, label %124

91:                                               ; preds = %87
  %92 = load i64, ptr %19, align 8, !tbaa !9
  %93 = getelementptr inbounds i32, ptr %36, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !11
  %95 = icmp eq i32 3, %94
  br i1 %95, label %96, label %120

96:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 12, ptr %23) #8
  call void @llvm.memset.p0.i64(ptr align 1 %23, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = load i64, ptr %19, align 8, !tbaa !9
  %99 = getelementptr inbounds %struct.ach_evhandler, ptr %97, i64 %98
  %100 = getelementptr inbounds %struct.ach_evhandler, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !15
  %102 = call i32 @ach_channel_fd(ptr noundef %101, ptr noundef %24)
  store i32 %102, ptr %14, align 4, !tbaa !11
  %103 = icmp ne i32 0, %102
  br i1 %103, label %104, label %105

104:                                              ; preds = %96
  store i32 5, ptr %22, align 4
  br label %117

105:                                              ; preds = %96
  %106 = getelementptr inbounds %struct.epoll_event, ptr %23, i32 0, i32 0
  store i32 1, ptr %106, align 1, !tbaa !19
  %107 = load ptr, ptr %8, align 8, !tbaa !5
  %108 = load i64, ptr %19, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.ach_evhandler, ptr %107, i64 %108
  %110 = getelementptr inbounds %struct.epoll_event, ptr %23, i32 0, i32 1
  store ptr %109, ptr %110, align 1, !tbaa !21
  %111 = load i32, ptr %18, align 4, !tbaa !11
  %112 = load i32, ptr %24, align 4, !tbaa !11
  %113 = call i32 @epoll_ctl(i32 noundef %111, i32 noundef 1, i32 noundef %112, ptr noundef %23) #8
  %114 = icmp ne i32 %113, 0
  br i1 %114, label %115, label %116

115:                                              ; preds = %105
  store i32 4, ptr %14, align 4, !tbaa !11
  store i32 5, ptr %22, align 4
  br label %117

116:                                              ; preds = %105
  store i32 0, ptr %22, align 4
  br label %117

117:                                              ; preds = %116, %115, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %23) #8
  %118 = load i32, ptr %22, align 4
  switch i32 %118, label %266 [
    i32 0, label %119
    i32 5, label %246
  ]

119:                                              ; preds = %117
  br label %120

120:                                              ; preds = %119, %91
  br label %121

121:                                              ; preds = %120
  %122 = load i64, ptr %19, align 8, !tbaa !9
  %123 = add i64 %122, 1
  store i64 %123, ptr %19, align 8, !tbaa !9
  br label %87, !llvm.loop !22

124:                                              ; preds = %87
  br label %125

125:                                              ; preds = %124, %78
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  %127 = icmp ne ptr %126, null
  br i1 %127, label %128, label %148

128:                                              ; preds = %125
  %129 = load ptr, ptr %10, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.timespec, ptr %129, i32 0, i32 0
  %131 = load i64, ptr %130, align 8, !tbaa !23
  %132 = mul nsw i64 %131, 1000
  %133 = load ptr, ptr %10, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.timespec, ptr %133, i32 0, i32 1
  %135 = load i64, ptr %134, align 8, !tbaa !25
  %136 = sdiv i64 %135, 1000000
  %137 = add nsw i64 %132, %136
  %138 = trunc i64 %137 to i32
  store i32 %138, ptr %25, align 4, !tbaa !11
  %139 = load i32, ptr %25, align 4, !tbaa !11
  %140 = icmp eq i32 0, %139
  br i1 %140, label %141, label %147

141:                                              ; preds = %128
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.timespec, ptr %142, i32 0, i32 1
  %144 = load i64, ptr %143, align 8, !tbaa !25
  %145 = icmp ne i64 0, %144
  br i1 %145, label %146, label %147

146:                                              ; preds = %141
  store i32 1, ptr %25, align 4, !tbaa !11
  br label %147

147:                                              ; preds = %146, %141, %128
  br label %149

148:                                              ; preds = %125
  store i32 -1, ptr %25, align 4, !tbaa !11
  br label %149

149:                                              ; preds = %148, %147
  %150 = load i32, ptr %25, align 4, !tbaa !11
  store i32 %150, ptr %26, align 4, !tbaa !11
  %151 = load ptr, ptr %10, align 8, !tbaa !5
  %152 = icmp ne ptr %151, null
  br i1 %152, label %153, label %155

153:                                              ; preds = %149
  %154 = call i32 @clock_gettime(i32 noundef 1, ptr noundef %28) #8
  br label %155

155:                                              ; preds = %153, %149
  br label %156

156:                                              ; preds = %242, %155
  call void @llvm.lifetime.start.p0(i64 12, ptr %29) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #8
  %157 = load i32, ptr %18, align 4, !tbaa !11
  %158 = load i32, ptr %26, align 4, !tbaa !11
  %159 = call i32 @epoll_wait(i32 noundef %157, ptr noundef %29, i32 noundef 1, i32 noundef %158)
  store i32 %159, ptr %30, align 4, !tbaa !11
  %160 = load i32, ptr %30, align 4, !tbaa !11
  %161 = icmp slt i32 %160, 0
  br i1 %161, label %162, label %163

162:                                              ; preds = %156
  store i32 4, ptr %14, align 4, !tbaa !11
  br label %199

163:                                              ; preds = %156
  %164 = load i32, ptr %30, align 4, !tbaa !11
  %165 = icmp sgt i32 %164, 0
  br i1 %165, label %166, label %198

166:                                              ; preds = %163
  %167 = getelementptr inbounds %struct.epoll_event, ptr %29, i32 0, i32 0
  %168 = load i32, ptr %167, align 1, !tbaa !19
  %169 = and i32 %168, 1
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %171, label %184

171:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #8
  %172 = getelementptr inbounds %struct.epoll_event, ptr %29, i32 0, i32 1
  %173 = load ptr, ptr %172, align 1, !tbaa !21
  store ptr %173, ptr %31, align 8, !tbaa !5
  %174 = load ptr, ptr %31, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.ach_evhandler, ptr %174, i32 0, i32 2
  %176 = load ptr, ptr %175, align 8, !tbaa !26
  %177 = load ptr, ptr %31, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.ach_evhandler, ptr %177, i32 0, i32 1
  %179 = load ptr, ptr %178, align 8, !tbaa !27
  %180 = load ptr, ptr %31, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.ach_evhandler, ptr %180, i32 0, i32 0
  %182 = load ptr, ptr %181, align 8, !tbaa !15
  %183 = call i32 %176(ptr noundef %179, ptr noundef %182)
  store i32 %183, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #8
  br label %184

184:                                              ; preds = %171, %166
  %185 = load i32, ptr %14, align 4, !tbaa !11
  %186 = icmp eq i32 0, %185
  br i1 %186, label %187, label %197

187:                                              ; preds = %184
  %188 = load ptr, ptr %11, align 8, !tbaa !5
  %189 = icmp ne ptr %188, null
  br i1 %189, label %190, label %197

190:                                              ; preds = %187
  %191 = load i8, ptr %20, align 1, !tbaa !13, !range !28, !noundef !29
  %192 = trunc i8 %191 to i1
  br i1 %192, label %193, label %197

193:                                              ; preds = %190
  %194 = load ptr, ptr %11, align 8, !tbaa !5
  %195 = load ptr, ptr %12, align 8, !tbaa !5
  %196 = call i32 %194(ptr noundef %195)
  store i32 %196, ptr %14, align 4, !tbaa !11
  br label %197

197:                                              ; preds = %193, %190, %187, %184
  br label %198

198:                                              ; preds = %197, %163
  br label %199

199:                                              ; preds = %198, %162
  %200 = load i32, ptr %14, align 4, !tbaa !11
  %201 = icmp eq i32 0, %200
  br i1 %201, label %202, label %241

202:                                              ; preds = %199
  %203 = load ptr, ptr %10, align 8, !tbaa !5
  %204 = icmp ne ptr %203, null
  br i1 %204, label %205, label %241

205:                                              ; preds = %202
  %206 = call i32 @clock_gettime(i32 noundef 1, ptr noundef %27) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #8
  %207 = getelementptr inbounds %struct.timespec, ptr %27, i32 0, i32 0
  %208 = load i64, ptr %207, align 8, !tbaa !23
  %209 = getelementptr inbounds %struct.timespec, ptr %28, i32 0, i32 0
  %210 = load i64, ptr %209, align 8, !tbaa !23
  %211 = sub nsw i64 %208, %210
  %212 = mul nsw i64 %211, 1000
  %213 = getelementptr inbounds %struct.timespec, ptr %27, i32 0, i32 1
  %214 = load i64, ptr %213, align 8, !tbaa !25
  %215 = getelementptr inbounds %struct.timespec, ptr %28, i32 0, i32 1
  %216 = load i64, ptr %215, align 8, !tbaa !25
  %217 = sub nsw i64 %214, %216
  %218 = sdiv i64 %217, 1000000
  %219 = sub nsw i64 %212, %218
  %220 = trunc i64 %219 to i32
  store i32 %220, ptr %32, align 4, !tbaa !11
  %221 = load i32, ptr %32, align 4, !tbaa !11
  %222 = load i32, ptr %25, align 4, !tbaa !11
  %223 = icmp sge i32 %221, %222
  br i1 %223, label %224, label %236

224:                                              ; preds = %205
  %225 = load ptr, ptr %11, align 8, !tbaa !5
  %226 = icmp ne ptr %225, null
  br i1 %226, label %227, label %234

227:                                              ; preds = %224
  %228 = load i8, ptr %21, align 1, !tbaa !13, !range !28, !noundef !29
  %229 = trunc i8 %228 to i1
  br i1 %229, label %230, label %234

230:                                              ; preds = %227
  %231 = load ptr, ptr %11, align 8, !tbaa !5
  %232 = load ptr, ptr %12, align 8, !tbaa !5
  %233 = call i32 %231(ptr noundef %232)
  store i32 %233, ptr %14, align 4, !tbaa !11
  br label %234

234:                                              ; preds = %230, %227, %224
  %235 = load i32, ptr %25, align 4, !tbaa !11
  store i32 %235, ptr %26, align 4, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %27, i64 16, i1 false), !tbaa.struct !30
  br label %240

236:                                              ; preds = %205
  %237 = load i32, ptr %25, align 4, !tbaa !11
  %238 = load i32, ptr %32, align 4, !tbaa !11
  %239 = sub nsw i32 %237, %238
  store i32 %239, ptr %26, align 4, !tbaa !11
  br label %240

240:                                              ; preds = %236, %234
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #8
  br label %241

241:                                              ; preds = %240, %202, %199
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %29) #8
  br label %242

242:                                              ; preds = %241
  %243 = load i32, ptr %14, align 4, !tbaa !11
  %244 = icmp eq i32 0, %243
  br i1 %244, label %156, label %245, !llvm.loop !31

245:                                              ; preds = %242
  br label %246

246:                                              ; preds = %245, %117, %85
  %247 = load i32, ptr %18, align 4, !tbaa !11
  %248 = icmp sgt i32 %247, 0
  br i1 %248, label %249, label %264

249:                                              ; preds = %246
  %250 = call ptr @__errno_location() #9
  %251 = load i32, ptr %250, align 4, !tbaa !11
  %252 = icmp ne i32 %251, 0
  br i1 %252, label %253, label %260

253:                                              ; preds = %249
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #8
  %254 = call ptr @__errno_location() #9
  %255 = load i32, ptr %254, align 4, !tbaa !11
  store i32 %255, ptr %33, align 4, !tbaa !11
  %256 = load i32, ptr %18, align 4, !tbaa !11
  %257 = call i32 @close(i32 noundef %256)
  %258 = load i32, ptr %33, align 4, !tbaa !11
  %259 = call ptr @__errno_location() #9
  store i32 %258, ptr %259, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #8
  br label %263

260:                                              ; preds = %249
  %261 = load i32, ptr %18, align 4, !tbaa !11
  %262 = call i32 @close(i32 noundef %261)
  br label %263

263:                                              ; preds = %260, %253
  br label %264

264:                                              ; preds = %263, %246
  %265 = load i32, ptr %14, align 4, !tbaa !11
  store i32 %265, ptr %7, align 4
  store i32 1, ptr %22, align 4
  br label %266

266:                                              ; preds = %264, %117, %77, %59
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  %267 = load ptr, ptr %16, align 8
  call void @llvm.stackrestore.p0(ptr %267)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  %268 = load i32, ptr %7, align 4
  ret i32 %268
}

; Function Attrs: nounwind
declare i32 @epoll_create1(i32 noundef) #5

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

; Function Attrs: nounwind
declare i32 @epoll_ctl(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #5

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
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(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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = { 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { 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, !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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"ach_evhandler", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !12, i64 0}
!20 = !{!"epoll_event", !12, i64 0, !7, i64 4}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !18}
!23 = !{!24, !10, i64 0}
!24 = !{!"timespec", !10, i64 0, !10, i64 8}
!25 = !{!24, !10, i64 8}
!26 = !{!16, !6, i64 16}
!27 = !{!16, !6, i64 8}
!28 = !{i8 0, i8 2}
!29 = !{}
!30 = !{i64 0, i64 8, !9, i64 8, i64 8, !9}
!31 = distinct !{!31, !18}


; 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.epoll_event = type <{ i32, %union.epoll_data }>
%union.epoll_data = type { ptr }
%struct.timespec = type { i64, i64 }
%struct.ach_evhandler = type { ptr, ptr, ptr }

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind
declare i32 @clock_gettime(i32 noundef, ptr noundef) local_unnamed_addr #4

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

declare i32 @close(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ach_evhandle_epoll(ptr noundef %0, i64 noundef %1, ptr noundef readonly %2, ptr noundef readonly %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #5 {
  %7 = alloca %struct.epoll_event, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.timespec, align 8
  %10 = alloca %struct.timespec, align 8
  %11 = alloca %struct.epoll_event, align 4
  %12 = alloca i32, i64 %1, align 16
  %13 = and i32 %5, 2
  %.not = icmp eq i32 %13, 0
  %14 = and i32 %5, 1
  %.not92 = icmp eq i32 %14, 0
  %.not132 = icmp eq i64 %1, 0
  br i1 %.not132, label %.loopexit126, label %.lr.ph

.lr.ph:                                           ; preds = %6, %19
  %.066129 = phi i64 [ %spec.select, %19 ], [ 0, %6 ]
  %.075128 = phi i64 [ %23, %19 ], [ 0, %6 ]
  %15 = getelementptr inbounds %struct.ach_evhandler, ptr %0, i64 %.075128
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i32, ptr %12, i64 %.075128
  %18 = call i32 @ach_channel_map(ptr noundef %16, ptr noundef nonnull %17) #7
  %.not103 = icmp eq i32 %18, 0
  br i1 %.not103, label %19, label %.thread120

19:                                               ; preds = %.lr.ph
  %20 = load i32, ptr %17, align 4, !tbaa !10
  %21 = icmp eq i32 %20, 3
  %22 = zext i1 %21 to i64
  %spec.select = add i64 %.066129, %22
  %23 = add nuw i64 %.075128, 1
  %exitcond.not = icmp eq i64 %23, %1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %19
  %.not93 = icmp eq i64 %spec.select, %1
  br i1 %.not93, label %24, label %.thread120

24:                                               ; preds = %._crit_edge
  %25 = tail call ptr @__errno_location() #8
  store i32 0, ptr %25, align 4, !tbaa !10
  %26 = call i32 @epoll_create1(i32 noundef 524288) #7
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %.thread120, label %.lr.ph131

.lr.ph131:                                        ; preds = %24
  %28 = getelementptr inbounds i8, ptr %7, i64 4
  br label %29

29:                                               ; preds = %.lr.ph131, %41
  %.176130 = phi i64 [ 0, %.lr.ph131 ], [ %42, %41 ]
  %30 = getelementptr inbounds i32, ptr %12, i64 %.176130
  %31 = load i32, ptr %30, align 4, !tbaa !10
  %32 = icmp eq i32 %31, 3
  br i1 %32, label %33, label %41

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %7, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #7
  %34 = getelementptr inbounds %struct.ach_evhandler, ptr %0, i64 %.176130
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = call i32 @ach_channel_fd(ptr noundef %35, ptr noundef nonnull %8) #7
  %.not100 = icmp eq i32 %36, 0
  br i1 %.not100, label %37, label %.thread

37:                                               ; preds = %33
  store i32 1, ptr %7, align 4, !tbaa !14
  store ptr %34, ptr %28, align 4, !tbaa !16
  %38 = load i32, ptr %8, align 4, !tbaa !10
  %39 = call i32 @epoll_ctl(i32 noundef %26, i32 noundef 1, i32 noundef %38, ptr noundef nonnull %7) #7
  %.not101 = icmp eq i32 %39, 0
  br i1 %.not101, label %40, label %.thread

.thread:                                          ; preds = %33, %37
  %.2.ph = phi i32 [ 4, %37 ], [ %36, %33 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  br label %.loopexit

40:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  br label %41

41:                                               ; preds = %40, %29
  %42 = add nuw i64 %.176130, 1
  %exitcond138.not = icmp eq i64 %42, %1
  br i1 %exitcond138.not, label %.loopexit126, label %29, !llvm.loop !17

.loopexit126:                                     ; preds = %41, %6
  %.068 = phi i32 [ -1, %6 ], [ %26, %41 ]
  %.not134 = icmp eq ptr %2, null
  br i1 %.not134, label %.split.us.preheader, label %.split.preheader

.split.preheader:                                 ; preds = %.loopexit126
  %43 = load i64, ptr %2, align 8, !tbaa !18
  %44 = mul nsw i64 %43, 1000
  %45 = getelementptr inbounds i8, ptr %2, i64 8
  %46 = load i64, ptr %45, align 8, !tbaa !21
  %47 = sdiv i64 %46, 1000000
  %48 = add nsw i64 %47, %44
  %49 = trunc i64 %48 to i32
  %50 = icmp eq i32 %49, 0
  %.not95 = icmp ne i64 %46, 0
  %spec.select105 = zext i1 %.not95 to i32
  %.073.ph = select i1 %50, i32 %spec.select105, i32 %49
  %51 = call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull %10) #7
  %52 = getelementptr inbounds i8, ptr %11, i64 4
  %53 = icmp eq ptr %3, null
  %54 = getelementptr inbounds i8, ptr %9, i64 8
  %55 = getelementptr inbounds i8, ptr %10, i64 8
  %brmerge106 = or i1 %53, %.not92
  br label %.split

.split.us.preheader:                              ; preds = %.loopexit126
  %56 = getelementptr inbounds i8, ptr %11, i64 4
  %57 = icmp eq ptr %3, null
  br label %.split.us

.split.us:                                        ; preds = %.split.us.preheader, %77
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #7
  %58 = call i32 @epoll_wait(i32 noundef %.068, ptr noundef nonnull %11, i32 noundef 1, i32 noundef -1) #7
  %59 = icmp slt i32 %58, 0
  br i1 %59, label %.thread117, label %60

60:                                               ; preds = %.split.us
  %.not96.us = icmp eq i32 %58, 0
  br i1 %.not96.us, label %77, label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %11, align 4, !tbaa !14
  %63 = and i32 %62, 1
  %.not97.us = icmp eq i32 %63, 0
  br i1 %.not97.us, label %72, label %64

64:                                               ; preds = %61
  %65 = load ptr, ptr %56, align 4, !tbaa !16
  %66 = getelementptr inbounds i8, ptr %65, i64 16
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  %68 = getelementptr inbounds i8, ptr %65, i64 8
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = load ptr, ptr %65, align 8, !tbaa !5
  %71 = call i32 %67(ptr noundef %69, ptr noundef %70) #7
  br label %72

72:                                               ; preds = %64, %61
  %.6.us = phi i32 [ %71, %64 ], [ 0, %61 ]
  %73 = icmp ne i32 %.6.us, 0
  %74 = or i1 %73, %57
  %brmerge.us = or i1 %74, %.not
  br i1 %brmerge.us, label %77, label %75

75:                                               ; preds = %72
  %76 = call i32 %3(ptr noundef %4) #7
  br label %77

77:                                               ; preds = %75, %72, %60
  %.7.us = phi i32 [ %76, %75 ], [ %.6.us, %72 ], [ 0, %60 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #7
  %78 = icmp eq i32 %.7.us, 0
  br i1 %78, label %.split.us, label %.loopexit, !llvm.loop !24

.split:                                           ; preds = %.split.preheader, %116
  %.070 = phi i32 [ %.272, %116 ], [ %.073.ph, %.split.preheader ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #7
  %79 = call i32 @epoll_wait(i32 noundef %.068, ptr noundef nonnull %11, i32 noundef 1, i32 noundef %.070) #7
  %80 = icmp slt i32 %79, 0
  br i1 %80, label %.thread117, label %81

.thread117:                                       ; preds = %.split, %.split.us
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #7
  br label %.loopexit

81:                                               ; preds = %.split
  %.not96 = icmp eq i32 %79, 0
  br i1 %.not96, label %.thread146, label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %11, align 4, !tbaa !14
  %84 = and i32 %83, 1
  %.not97 = icmp eq i32 %84, 0
  br i1 %.not97, label %93, label %85

85:                                               ; preds = %82
  %86 = load ptr, ptr %52, align 4, !tbaa !16
  %87 = getelementptr inbounds i8, ptr %86, i64 16
  %88 = load ptr, ptr %87, align 8, !tbaa !22
  %89 = getelementptr inbounds i8, ptr %86, i64 8
  %90 = load ptr, ptr %89, align 8, !tbaa !23
  %91 = load ptr, ptr %86, align 8, !tbaa !5
  %92 = call i32 %88(ptr noundef %90, ptr noundef %91) #7
  br label %93

93:                                               ; preds = %85, %82
  %.6 = phi i32 [ %92, %85 ], [ 0, %82 ]
  %94 = icmp ne i32 %.6, 0
  %95 = or i1 %.not, %94
  %brmerge = or i1 %53, %95
  br i1 %brmerge, label %98, label %96

96:                                               ; preds = %93
  %97 = call i32 %3(ptr noundef %4) #7
  br label %98

98:                                               ; preds = %93, %96
  %.7 = phi i32 [ %97, %96 ], [ %.6, %93 ]
  %99 = icmp eq i32 %.7, 0
  br i1 %99, label %.thread146, label %.thread148

.thread148:                                       ; preds = %98
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #7
  br label %.loopexit

.thread146:                                       ; preds = %81, %98
  %100 = call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull %9) #7
  %101 = load i64, ptr %9, align 8, !tbaa !18
  %102 = load i64, ptr %10, align 8, !tbaa !18
  %103 = sub nsw i64 %101, %102
  %104 = mul nsw i64 %103, 1000
  %105 = load i64, ptr %54, align 8, !tbaa !21
  %106 = load i64, ptr %55, align 8, !tbaa !21
  %107 = sub nsw i64 %105, %106
  %.neg = sdiv i64 %107, -1000000
  %108 = add i64 %.neg, %104
  %109 = trunc i64 %108 to i32
  %.not98 = icmp sgt i32 %.073.ph, %109
  br i1 %.not98, label %114, label %110

110:                                              ; preds = %.thread146
  br i1 %brmerge106, label %113, label %111

111:                                              ; preds = %110
  %112 = call i32 %3(ptr noundef %4) #7
  br label %113

113:                                              ; preds = %110, %111
  %.8 = phi i32 [ %112, %111 ], [ 0, %110 ]
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %9, i64 16, i1 false), !tbaa.struct !25
  br label %116

114:                                              ; preds = %.thread146
  %115 = sub nsw i32 %.073.ph, %109
  br label %116

116:                                              ; preds = %113, %114
  %.272 = phi i32 [ %.073.ph, %113 ], [ %115, %114 ]
  %.10 = phi i32 [ %.8, %113 ], [ 0, %114 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #7
  %117 = icmp eq i32 %.10, 0
  br i1 %117, label %.split, label %.loopexit, !llvm.loop !24

.loopexit:                                        ; preds = %116, %77, %.thread148, %.thread117, %.thread
  %.169 = phi i32 [ %26, %.thread ], [ %.068, %.thread117 ], [ %.068, %.thread148 ], [ %.068, %77 ], [ %.068, %116 ]
  %.11 = phi i32 [ %.2.ph, %.thread ], [ 4, %.thread117 ], [ %.7, %.thread148 ], [ %.7.us, %77 ], [ %.10, %116 ]
  %118 = icmp sgt i32 %.169, 0
  br i1 %118, label %119, label %.thread120

119:                                              ; preds = %.loopexit
  %120 = tail call ptr @__errno_location() #8
  %121 = load i32, ptr %120, align 4, !tbaa !10
  %.not102 = icmp eq i32 %121, 0
  %122 = call i32 @close(i32 noundef %.169) #7
  br i1 %.not102, label %.thread120, label %123

123:                                              ; preds = %119
  store i32 %121, ptr %120, align 4, !tbaa !10
  br label %.thread120

.thread120:                                       ; preds = %.lr.ph, %119, %24, %.loopexit, %123, %._crit_edge
  %.0 = phi i32 [ 12, %._crit_edge ], [ %.11, %123 ], [ %.11, %.loopexit ], [ 0, %24 ], [ %.11, %119 ], [ %18, %.lr.ph ]
  ret i32 %.0
}

; Function Attrs: nounwind
declare i32 @epoll_create1(i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind
declare i32 @epoll_ctl(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

declare i32 @epoll_wait(i32 noundef, ptr noundef, i32 noundef, i32 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 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { 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, !7, i64 0}
!6 = !{!"ach_evhandler", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !11, i64 0}
!15 = !{!"epoll_event", !11, i64 0, !8, i64 4}
!16 = !{!8, !8, i64 0}
!17 = distinct !{!17, !13}
!18 = !{!19, !20, i64 0}
!19 = !{!"timespec", !20, i64 0, !20, i64 8}
!20 = !{!"long", !8, i64 0}
!21 = !{!19, !20, i64 8}
!22 = !{!6, !7, i64 16}
!23 = !{!6, !7, i64 8}
!24 = distinct !{!24, !13}
!25 = !{i64 0, i64 8, !26, i64 8, i64 8, !26}
!26 = !{!20, !20, i64 0}


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