; LLVM IR from buzz-lang/Buzz :: src/buzz (buzzoutmsg)

; 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.buzzvm_s = type { ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i16, ptr, ptr, ptr, ptr, i32, i32, ptr, i16, ptr, i32 }
%struct.buzzoutmsg_queue_s = type { [6 x ptr], ptr }
%struct.buzzdarray_s = type { ptr, i64, i32, i32, ptr }
%struct.buzzoutmsg_broadcast_s = type { i32, ptr, ptr }
%struct.buzzoutmsg_swarm_s = type { i32, ptr, i16 }
%struct.buzzoutmsg_vstig_s = type { i32, i16, 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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @buzzdarray_new(i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @buzzoutmsg_queue_first(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.buzzvm_s, ptr %17, i32 0, i32 17
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds [6 x ptr], ptr %20, i64 0, i64 0
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.buzzdarray_s, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %48, label %26

26:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.buzzvm_s, ptr %27, i32 0, i32 17
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds [6 x ptr], ptr %30, i64 0, i64 0
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.buzzdarray_s, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = getelementptr inbounds ptr, ptr %34, i64 0
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  store ptr %36, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %37 = call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null)
  store ptr %37, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @buzzmsg_serialize_u8(ptr noundef %38, i8 noundef zeroext 0)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.buzzoutmsg_broadcast_s, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  call void @buzzobj_serialize(ptr noundef %39, ptr noundef %42)
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.buzzoutmsg_broadcast_s, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  call void @buzzobj_serialize(ptr noundef %43, ptr noundef %46)
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %47, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %233

48:                                               ; preds = %1
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.buzzvm_s, ptr %49, i32 0, i32 17
  %51 = load ptr, ptr %50, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds [6 x ptr], ptr %52, i64 0, i64 1
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.buzzdarray_s, ptr %54, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !13
  %57 = icmp eq i64 %56, 0
  br i1 %57, label %97, label %58

58:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.buzzvm_s, ptr %59, i32 0, i32 17
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds [6 x ptr], ptr %62, i64 0, i64 1
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.buzzdarray_s, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = getelementptr inbounds ptr, ptr %66, i64 0
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  store ptr %68, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %69 = call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null)
  store ptr %69, ptr %8, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  call void @buzzmsg_serialize_u8(ptr noundef %70, i8 noundef zeroext 1)
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.buzzoutmsg_swarm_s, ptr %72, i32 0, i32 2
  %74 = load i16, ptr %73, align 8, !tbaa !17
  call void @buzzmsg_serialize_u16(ptr noundef %71, i16 noundef zeroext %74)
  store i16 0, ptr %6, align 2, !tbaa !18
  br label %75

75:                                               ; preds = %92, %58
  %76 = load i16, ptr %6, align 2, !tbaa !18
  %77 = zext i16 %76 to i32
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.buzzoutmsg_swarm_s, ptr %78, i32 0, i32 2
  %80 = load i16, ptr %79, align 8, !tbaa !17
  %81 = zext i16 %80 to i32
  %82 = icmp slt i32 %77, %81
  br i1 %82, label %83, label %95

83:                                               ; preds = %75
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.buzzoutmsg_swarm_s, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !17
  %88 = load i16, ptr %6, align 2, !tbaa !18
  %89 = zext i16 %88 to i64
  %90 = getelementptr inbounds i16, ptr %87, i64 %89
  %91 = load i16, ptr %90, align 2, !tbaa !18
  call void @buzzmsg_serialize_u16(ptr noundef %84, i16 noundef zeroext %91)
  br label %92

92:                                               ; preds = %83
  %93 = load i16, ptr %6, align 2, !tbaa !18
  %94 = add i16 %93, 1
  store i16 %94, ptr %6, align 2, !tbaa !18
  br label %75, !llvm.loop !19

95:                                               ; preds = %75
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %96, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  br label %233

97:                                               ; preds = %48
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.buzzvm_s, ptr %98, i32 0, i32 17
  %100 = load ptr, ptr %99, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %100, i32 0, i32 0
  %102 = getelementptr inbounds [6 x ptr], ptr %101, i64 0, i64 2
  %103 = load ptr, ptr %102, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.buzzdarray_s, ptr %103, i32 0, i32 1
  %105 = load i64, ptr %104, align 8, !tbaa !13
  %106 = icmp eq i64 %105, 0
  br i1 %106, label %132, label %107

107:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.buzzvm_s, ptr %108, i32 0, i32 17
  %110 = load ptr, ptr %109, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %110, i32 0, i32 0
  %112 = getelementptr inbounds [6 x ptr], ptr %111, i64 0, i64 2
  %113 = load ptr, ptr %112, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.buzzdarray_s, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !16
  %116 = getelementptr inbounds ptr, ptr %115, i64 0
  %117 = load ptr, ptr %116, align 8, !tbaa !5
  store ptr %117, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %118 = call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null)
  store ptr %118, ptr %10, align 8, !tbaa !5
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  call void @buzzmsg_serialize_u8(ptr noundef %119, i8 noundef zeroext 2)
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.buzzoutmsg_vstig_s, ptr %121, i32 0, i32 1
  %123 = load i16, ptr %122, align 4, !tbaa !17
  call void @buzzmsg_serialize_u16(ptr noundef %120, i16 noundef zeroext %123)
  %124 = load ptr, ptr %10, align 8, !tbaa !5
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.buzzoutmsg_vstig_s, ptr %125, i32 0, i32 2
  %127 = load ptr, ptr %126, align 8, !tbaa !17
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.buzzoutmsg_vstig_s, ptr %128, i32 0, i32 3
  %130 = load ptr, ptr %129, align 8, !tbaa !17
  call void @buzzvstig_elem_serialize(ptr noundef %124, ptr noundef %127, ptr noundef %130)
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %131, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %233

132:                                              ; preds = %97
  %133 = load ptr, ptr %3, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.buzzvm_s, ptr %133, i32 0, i32 17
  %135 = load ptr, ptr %134, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %135, i32 0, i32 0
  %137 = getelementptr inbounds [6 x ptr], ptr %136, i64 0, i64 3
  %138 = load ptr, ptr %137, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.buzzdarray_s, ptr %138, i32 0, i32 1
  %140 = load i64, ptr %139, align 8, !tbaa !13
  %141 = icmp eq i64 %140, 0
  br i1 %141, label %167, label %142

142:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.buzzvm_s, ptr %143, i32 0, i32 17
  %145 = load ptr, ptr %144, align 8, !tbaa !9
  %146 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %145, i32 0, i32 0
  %147 = getelementptr inbounds [6 x ptr], ptr %146, i64 0, i64 3
  %148 = load ptr, ptr %147, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.buzzdarray_s, ptr %148, i32 0, i32 0
  %150 = load ptr, ptr %149, align 8, !tbaa !16
  %151 = getelementptr inbounds ptr, ptr %150, i64 0
  %152 = load ptr, ptr %151, align 8, !tbaa !5
  store ptr %152, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %153 = call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null)
  store ptr %153, ptr %12, align 8, !tbaa !5
  %154 = load ptr, ptr %12, align 8, !tbaa !5
  call void @buzzmsg_serialize_u8(ptr noundef %154, i8 noundef zeroext 3)
  %155 = load ptr, ptr %12, align 8, !tbaa !5
  %156 = load ptr, ptr %11, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.buzzoutmsg_vstig_s, ptr %156, i32 0, i32 1
  %158 = load i16, ptr %157, align 4, !tbaa !17
  call void @buzzmsg_serialize_u16(ptr noundef %155, i16 noundef zeroext %158)
  %159 = load ptr, ptr %12, align 8, !tbaa !5
  %160 = load ptr, ptr %11, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.buzzoutmsg_vstig_s, ptr %160, i32 0, i32 2
  %162 = load ptr, ptr %161, align 8, !tbaa !17
  %163 = load ptr, ptr %11, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.buzzoutmsg_vstig_s, ptr %163, i32 0, i32 3
  %165 = load ptr, ptr %164, align 8, !tbaa !17
  call void @buzzvstig_elem_serialize(ptr noundef %159, ptr noundef %162, ptr noundef %165)
  %166 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %166, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %233

167:                                              ; preds = %132
  %168 = load ptr, ptr %3, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.buzzvm_s, ptr %168, i32 0, i32 17
  %170 = load ptr, ptr %169, align 8, !tbaa !9
  %171 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %170, i32 0, i32 0
  %172 = getelementptr inbounds [6 x ptr], ptr %171, i64 0, i64 4
  %173 = load ptr, ptr %172, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.buzzdarray_s, ptr %173, i32 0, i32 1
  %175 = load i64, ptr %174, align 8, !tbaa !13
  %176 = icmp eq i64 %175, 0
  br i1 %176, label %197, label %177

177:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %178 = load ptr, ptr %3, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.buzzvm_s, ptr %178, i32 0, i32 17
  %180 = load ptr, ptr %179, align 8, !tbaa !9
  %181 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %180, i32 0, i32 0
  %182 = getelementptr inbounds [6 x ptr], ptr %181, i64 0, i64 4
  %183 = load ptr, ptr %182, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.buzzdarray_s, ptr %183, i32 0, i32 0
  %185 = load ptr, ptr %184, align 8, !tbaa !16
  %186 = getelementptr inbounds ptr, ptr %185, i64 0
  %187 = load ptr, ptr %186, align 8, !tbaa !5
  store ptr %187, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %188 = call ptr @buzzdarray_new(i32 noundef 5, i32 noundef 1, ptr noundef null)
  store ptr %188, ptr %14, align 8, !tbaa !5
  %189 = load ptr, ptr %14, align 8, !tbaa !5
  call void @buzzmsg_serialize_u8(ptr noundef %189, i8 noundef zeroext 4)
  %190 = load ptr, ptr %14, align 8, !tbaa !5
  %191 = load ptr, ptr %13, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.buzzoutmsg_swarm_s, ptr %191, i32 0, i32 1
  %193 = load ptr, ptr %192, align 8, !tbaa !17
  %194 = getelementptr inbounds i16, ptr %193, i64 0
  %195 = load i16, ptr %194, align 2, !tbaa !18
  call void @buzzmsg_serialize_u16(ptr noundef %190, i16 noundef zeroext %195)
  %196 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %196, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %233

197:                                              ; preds = %167
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.buzzvm_s, ptr %198, i32 0, i32 17
  %200 = load ptr, ptr %199, align 8, !tbaa !9
  %201 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %200, i32 0, i32 0
  %202 = getelementptr inbounds [6 x ptr], ptr %201, i64 0, i64 5
  %203 = load ptr, ptr %202, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.buzzdarray_s, ptr %203, i32 0, i32 1
  %205 = load i64, ptr %204, align 8, !tbaa !13
  %206 = icmp eq i64 %205, 0
  br i1 %206, label %227, label %207

207:                                              ; preds = %197
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %208 = load ptr, ptr %3, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.buzzvm_s, ptr %208, i32 0, i32 17
  %210 = load ptr, ptr %209, align 8, !tbaa !9
  %211 = getelementptr inbounds %struct.buzzoutmsg_queue_s, ptr %210, i32 0, i32 0
  %212 = getelementptr inbounds [6 x ptr], ptr %211, i64 0, i64 5
  %213 = load ptr, ptr %212, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.buzzdarray_s, ptr %213, i32 0, i32 0
  %215 = load ptr, ptr %214, align 8, !tbaa !16
  %216 = getelementptr inbounds ptr, ptr %215, i64 0
  %217 = load ptr, ptr %216, align 8, !tbaa !5
  store ptr %217, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %218 = call ptr @buzzdarray_new(i32 noundef 5, i32 noundef 1, ptr noundef null)
  store ptr %218, ptr %16, align 8, !tbaa !5
  %219 = load ptr, ptr %16, align 8, !tbaa !5
  call void @buzzmsg_serialize_u8(ptr noundef %219, i8 noundef zeroext 5)
  %220 = load ptr, ptr %16, align 8, !tbaa !5
  %221 = load ptr, ptr %15, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.buzzoutmsg_swarm_s, ptr %221, i32 0, i32 1
  %223 = load ptr, ptr %222, align 8, !tbaa !17
  %224 = getelementptr inbounds i16, ptr %223, i64 0
  %225 = load i16, ptr %224, align 2, !tbaa !18
  call void @buzzmsg_serialize_u16(ptr noundef %220, i16 noundef zeroext %225)
  %226 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %226, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %233

227:                                              ; preds = %197
  br label %228

228:                                              ; preds = %227
  br label %229

229:                                              ; preds = %228
  br label %230

230:                                              ; preds = %229
  br label %231

231:                                              ; preds = %230
  br label %232

232:                                              ; preds = %231
  store ptr null, ptr %2, align 8
  br label %233

233:                                              ; preds = %232, %207, %177, %142, %107, %95, %26
  %234 = load ptr, ptr %2, align 8
  ret ptr %234
}

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

declare void @buzzobj_serialize(ptr noundef, ptr noundef) #1

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

declare void @buzzvstig_elem_serialize(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 128}
!10 = !{!"buzzvm_s", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !12, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !11, i64 152, !11, i64 156, !6, i64 160, !12, i64 168, !6, i64 176, !11, i64 184}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !15, i64 8}
!14 = !{!"buzzdarray_s", !6, i64 0, !15, i64 8, !11, i64 16, !11, i64 20, !6, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !6, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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"

declare ptr @buzzdarray_new(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @buzzoutmsg_queue_first(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 128
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !13
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %16, label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %4, align 8, !tbaa !16
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = tail call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null) #2
  tail call void @buzzmsg_serialize_u8(ptr noundef %11, i8 noundef zeroext 0) #2
  %12 = getelementptr inbounds i8, ptr %10, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  tail call void @buzzobj_serialize(ptr noundef %11, ptr noundef %13) #2
  %14 = getelementptr inbounds i8, ptr %10, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  tail call void @buzzobj_serialize(ptr noundef %11, ptr noundef %15) #2
  br label %.loopexit

16:                                               ; preds = %1
  %17 = getelementptr inbounds i8, ptr %3, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load i64, ptr %19, align 8, !tbaa !13
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %37, label %22

22:                                               ; preds = %16
  %23 = load ptr, ptr %18, align 8, !tbaa !16
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  %25 = tail call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null) #2
  tail call void @buzzmsg_serialize_u8(ptr noundef %25, i8 noundef zeroext 1) #2
  %26 = getelementptr inbounds i8, ptr %24, i64 16
  %27 = load i16, ptr %26, align 8, !tbaa !17
  tail call void @buzzmsg_serialize_u16(ptr noundef %25, i16 noundef zeroext %27) #2
  %28 = load i16, ptr %26, align 8, !tbaa !17
  %.not = icmp eq i16 %28, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %22
  %29 = getelementptr inbounds i8, ptr %24, i64 8
  br label %30

30:                                               ; preds = %.lr.ph, %30
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %30 ]
  %31 = load ptr, ptr %29, align 8, !tbaa !17
  %32 = getelementptr inbounds i16, ptr %31, i64 %indvars.iv
  %33 = load i16, ptr %32, align 2, !tbaa !18
  tail call void @buzzmsg_serialize_u16(ptr noundef %25, i16 noundef zeroext %33) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i16, ptr %26, align 8, !tbaa !17
  %35 = zext i16 %34 to i64
  %36 = icmp ult i64 %indvars.iv.next, %35
  br i1 %36, label %30, label %.loopexit, !llvm.loop !19

37:                                               ; preds = %16
  %38 = getelementptr inbounds i8, ptr %3, i64 16
  %39 = load ptr, ptr %38, align 8, !tbaa !12
  %40 = getelementptr inbounds i8, ptr %39, i64 8
  %41 = load i64, ptr %40, align 8, !tbaa !13
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %53, label %43

43:                                               ; preds = %37
  %44 = load ptr, ptr %39, align 8, !tbaa !16
  %45 = load ptr, ptr %44, align 8, !tbaa !12
  %46 = tail call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null) #2
  tail call void @buzzmsg_serialize_u8(ptr noundef %46, i8 noundef zeroext 2) #2
  %47 = getelementptr inbounds i8, ptr %45, i64 4
  %48 = load i16, ptr %47, align 4, !tbaa !17
  tail call void @buzzmsg_serialize_u16(ptr noundef %46, i16 noundef zeroext %48) #2
  %49 = getelementptr inbounds i8, ptr %45, i64 8
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = getelementptr inbounds i8, ptr %45, i64 16
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  tail call void @buzzvstig_elem_serialize(ptr noundef %46, ptr noundef %50, ptr noundef %52) #2
  br label %.loopexit

53:                                               ; preds = %37
  %54 = getelementptr inbounds i8, ptr %3, i64 24
  %55 = load ptr, ptr %54, align 8, !tbaa !12
  %56 = getelementptr inbounds i8, ptr %55, i64 8
  %57 = load i64, ptr %56, align 8, !tbaa !13
  %58 = icmp eq i64 %57, 0
  br i1 %58, label %69, label %59

59:                                               ; preds = %53
  %60 = load ptr, ptr %55, align 8, !tbaa !16
  %61 = load ptr, ptr %60, align 8, !tbaa !12
  %62 = tail call ptr @buzzdarray_new(i32 noundef 10, i32 noundef 1, ptr noundef null) #2
  tail call void @buzzmsg_serialize_u8(ptr noundef %62, i8 noundef zeroext 3) #2
  %63 = getelementptr inbounds i8, ptr %61, i64 4
  %64 = load i16, ptr %63, align 4, !tbaa !17
  tail call void @buzzmsg_serialize_u16(ptr noundef %62, i16 noundef zeroext %64) #2
  %65 = getelementptr inbounds i8, ptr %61, i64 8
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = getelementptr inbounds i8, ptr %61, i64 16
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  tail call void @buzzvstig_elem_serialize(ptr noundef %62, ptr noundef %66, ptr noundef %68) #2
  br label %.loopexit

69:                                               ; preds = %53
  %70 = getelementptr inbounds i8, ptr %3, i64 32
  %71 = load ptr, ptr %70, align 8, !tbaa !12
  %72 = getelementptr inbounds i8, ptr %71, i64 8
  %73 = load i64, ptr %72, align 8, !tbaa !13
  %74 = icmp eq i64 %73, 0
  br i1 %74, label %82, label %75

75:                                               ; preds = %69
  %76 = load ptr, ptr %71, align 8, !tbaa !16
  %77 = load ptr, ptr %76, align 8, !tbaa !12
  %78 = tail call ptr @buzzdarray_new(i32 noundef 5, i32 noundef 1, ptr noundef null) #2
  tail call void @buzzmsg_serialize_u8(ptr noundef %78, i8 noundef zeroext 4) #2
  %79 = getelementptr inbounds i8, ptr %77, i64 8
  %80 = load ptr, ptr %79, align 8, !tbaa !17
  %81 = load i16, ptr %80, align 2, !tbaa !18
  tail call void @buzzmsg_serialize_u16(ptr noundef %78, i16 noundef zeroext %81) #2
  br label %.loopexit

82:                                               ; preds = %69
  %83 = getelementptr inbounds i8, ptr %3, i64 40
  %84 = load ptr, ptr %83, align 8, !tbaa !12
  %85 = getelementptr inbounds i8, ptr %84, i64 8
  %86 = load i64, ptr %85, align 8, !tbaa !13
  %87 = icmp eq i64 %86, 0
  br i1 %87, label %.loopexit, label %88

88:                                               ; preds = %82
  %89 = load ptr, ptr %84, align 8, !tbaa !16
  %90 = load ptr, ptr %89, align 8, !tbaa !12
  %91 = tail call ptr @buzzdarray_new(i32 noundef 5, i32 noundef 1, ptr noundef null) #2
  tail call void @buzzmsg_serialize_u8(ptr noundef %91, i8 noundef zeroext 5) #2
  %92 = getelementptr inbounds i8, ptr %90, i64 8
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  %94 = load i16, ptr %93, align 2, !tbaa !18
  tail call void @buzzmsg_serialize_u16(ptr noundef %91, i16 noundef zeroext %94) #2
  br label %.loopexit

.loopexit:                                        ; preds = %30, %22, %82, %88, %75, %59, %43, %8
  %.0 = phi ptr [ %91, %88 ], [ %78, %75 ], [ %62, %59 ], [ %46, %43 ], [ %11, %8 ], [ null, %82 ], [ %25, %22 ], [ %25, %30 ]
  ret ptr %.0
}

declare void @buzzmsg_serialize_u8(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

declare void @buzzobj_serialize(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @buzzmsg_serialize_u16(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

declare void @buzzvstig_elem_serialize(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 #2 = { 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, !7, i64 128}
!6 = !{!"buzzvm_s", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !11, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !10, i64 152, !10, i64 156, !7, i64 160, !11, i64 168, !7, i64 176, !10, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !15, i64 8}
!14 = !{!"buzzdarray_s", !7, i64 0, !15, i64 8, !10, i64 16, !10, i64 20, !7, i64 24}
!15 = !{!"long", !8, i64 0}
!16 = !{!14, !7, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!11, !11, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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