; LLVM IR from devicehive/esp8266-firmware :: firmware-src/sources (dhconnector_websocket_api)

; 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.jsonparse_state = type { ptr, i32, i32, i32, i32, i32, i8, i8, [10 x i8] }
%struct.COMMAND_RESULT = type { ptr, %union.CommandResultArgument }
%union.CommandResultArgument = type { ptr }

@connected = external hidden global i8, align 1
@dhconnector_websocket_api_communicate.timestampTemplate = external hidden constant [18 x i8], align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@mTimestamp = external hidden global [192 x i8], align 16
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@dhconnector_websocket_api_communicate.template = external hidden constant [55 x i8], align 4
@dhconnector_websocket_api_communicate.str = external hidden constant [20 x i8], align 4
@dhconnector_websocket_api_communicate.str.12 = external hidden constant [56 x i8], align 4
@.str.13 = external hidden unnamed_addr constant [13 x i8], align 1
@dhconnector_websocket_api_communicate.template.14 = external hidden constant [194 x i8], align 4
@dhconnector_websocket_api_communicate.str.15 = external hidden constant [27 x i8], align 4
@dhconnector_websocket_api_communicate.str.16 = external hidden constant [26 x i8], align 4
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [12 x i8], align 1
@dhconnector_websocket_api_communicate.template.19 = external hidden constant [49 x i8], align 4
@dhconnector_websocket_api_communicate.str.20 = external hidden constant [26 x i8], align 4
@dhconnector_websocket_api_communicate.str.21 = external hidden constant [13 x i8], align 4
@.str.22 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [18 x i8], align 1
@dhconnector_websocket_api_communicate.str.24 = external hidden constant [25 x i8], align 4
@.str.25 = external hidden unnamed_addr constant [15 x i8], align 1
@dhconnector_websocket_api_communicate.str.26 = external hidden constant [29 x i8], align 4

declare i32 @snprintf(ptr noundef, i32 noundef, ptr noundef, ...) #0

declare ptr @dhsettings_get_devicehive_key() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @dhconnector_websocket_api_communicate(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [32 x i8], align 16
  %13 = alloca [128 x i8], align 16
  %14 = alloca [256 x i8], align 16
  %15 = alloca [1025 x i8], align 16
  %16 = alloca [172 x i8], align 16
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.jsonparse_state, align 8
  %21 = alloca i32, align 4
  %22 = alloca %struct.COMMAND_RESULT, align 8
  %23 = alloca i32, align 4
  %24 = alloca [9 x i8], align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 128, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 256, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 1025, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 172, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store ptr null, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !9
  %25 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  store i8 0, ptr %25, align 16, !tbaa !11
  %26 = getelementptr inbounds [128 x i8], ptr %13, i64 0, i64 0
  store i8 0, ptr %26, align 16, !tbaa !11
  %27 = getelementptr inbounds [1025 x i8], ptr %15, i64 0, i64 0
  store i8 0, ptr %27, align 16, !tbaa !11
  %28 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  store i8 0, ptr %28, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 40, ptr %20) #3
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !9
  call void @jsonparse_setup(ptr noundef %20, ptr noundef %29, i32 noundef %30)
  br label %31

31:                                               ; preds = %210, %202, %4
  %32 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !12
  %34 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = icmp slt i32 %33, %35
  br i1 %36, label %37, label %211

37:                                               ; preds = %31
  %38 = call i32 @jsonparse_next(ptr noundef %20)
  store i32 %38, ptr %10, align 4, !tbaa !9
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 78
  br i1 %40, label %41, label %178

41:                                               ; preds = %37
  %42 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str)
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %51

44:                                               ; preds = %41
  %45 = call i32 @jsonparse_next(ptr noundef %20)
  %46 = call i32 @jsonparse_next(ptr noundef %20)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %44
  %49 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.1)
  store i32 %49, ptr %11, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %48, %44
  br label %177

51:                                               ; preds = %41
  %52 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.2)
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %62

54:                                               ; preds = %51
  %55 = call i32 @jsonparse_next(ptr noundef %20)
  %56 = call i32 @jsonparse_next(ptr noundef %20)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %61

58:                                               ; preds = %54
  %59 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  %60 = call i32 @jsonparse_copy_value(ptr noundef %20, ptr noundef %59, i32 noundef 256)
  br label %61

61:                                               ; preds = %58, %54
  br label %176

62:                                               ; preds = %51
  %63 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.3)
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %73

65:                                               ; preds = %62
  %66 = call i32 @jsonparse_next(ptr noundef %20)
  %67 = call i32 @jsonparse_next(ptr noundef %20)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %72

69:                                               ; preds = %65
  %70 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %71 = call i32 @jsonparse_copy_value(ptr noundef %20, ptr noundef %70, i32 noundef 32)
  br label %72

72:                                               ; preds = %69, %65
  br label %175

73:                                               ; preds = %62
  %74 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.4)
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %84

76:                                               ; preds = %73
  %77 = call i32 @jsonparse_next(ptr noundef %20)
  %78 = call i32 @jsonparse_next(ptr noundef %20)
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %76
  %81 = getelementptr inbounds [128 x i8], ptr %13, i64 0, i64 0
  %82 = call i32 @jsonparse_copy_value(ptr noundef %20, ptr noundef %81, i32 noundef 128)
  br label %83

83:                                               ; preds = %80, %76
  br label %174

84:                                               ; preds = %73
  %85 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.5)
  %86 = icmp eq i32 %85, 0
  br i1 %86, label %87, label %95

87:                                               ; preds = %84
  %88 = call i32 @jsonparse_next(ptr noundef %20)
  %89 = call i32 @jsonparse_next(ptr noundef %20)
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %87
  %92 = call i64 @jsonparse_get_value_as_ulong(ptr noundef %20)
  %93 = trunc i64 %92 to i32
  store i32 %93, ptr %19, align 4, !tbaa !9
  br label %94

94:                                               ; preds = %91, %87
  br label %173

95:                                               ; preds = %84
  %96 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.6)
  %97 = icmp eq i32 %96, 0
  br i1 %97, label %98, label %106

98:                                               ; preds = %95
  %99 = call i32 @jsonparse_next(ptr noundef %20)
  %100 = call i32 @jsonparse_next(ptr noundef %20)
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %105

102:                                              ; preds = %98
  %103 = getelementptr inbounds [172 x i8], ptr %16, i64 0, i64 0
  %104 = call i32 @jsonparse_copy_value(ptr noundef %20, ptr noundef %103, i32 noundef 172)
  br label %105

105:                                              ; preds = %102, %98
  br label %172

106:                                              ; preds = %95
  %107 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.7)
  %108 = icmp eq i32 %107, 0
  br i1 %108, label %109, label %159

109:                                              ; preds = %106
  %110 = call i32 @jsonparse_next(ptr noundef %20)
  %111 = call i32 @jsonparse_next(ptr noundef %20)
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %158

113:                                              ; preds = %109
  %114 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !15
  %116 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %117 = load i32, ptr %116, align 8, !tbaa !12
  %118 = sub nsw i32 %117, 1
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i8, ptr %115, i64 %119
  store ptr %120, ptr %17, align 8, !tbaa !5
  %121 = load ptr, ptr %17, align 8, !tbaa !5
  %122 = load i8, ptr %121, align 1, !tbaa !11
  %123 = sext i8 %122 to i32
  %124 = icmp eq i32 %123, 123
  br i1 %124, label %125, label %157

125:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %126 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %127 = load i32, ptr %126, align 8, !tbaa !12
  store i32 %127, ptr %21, align 4, !tbaa !9
  br label %128

128:                                              ; preds = %144, %125
  %129 = load i32, ptr %21, align 4, !tbaa !9
  %130 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 2
  %131 = load i32, ptr %130, align 4, !tbaa !14
  %132 = icmp slt i32 %129, %131
  br i1 %132, label %133, label %142

133:                                              ; preds = %128
  %134 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !15
  %136 = load i32, ptr %21, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds i8, ptr %135, i64 %137
  %139 = load i8, ptr %138, align 1, !tbaa !11
  %140 = sext i8 %139 to i32
  %141 = icmp ne i32 %140, 125
  br label %142

142:                                              ; preds = %133, %128
  %143 = phi i1 [ false, %128 ], [ %141, %133 ]
  br i1 %143, label %144, label %147

144:                                              ; preds = %142
  %145 = load i32, ptr %21, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %21, align 4, !tbaa !9
  br label %128, !llvm.loop !16

147:                                              ; preds = %142
  %148 = load i32, ptr %21, align 4, !tbaa !9
  %149 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %150 = load i32, ptr %149, align 8, !tbaa !12
  %151 = sub nsw i32 %148, %150
  %152 = add nsw i32 %151, 2
  store i32 %152, ptr %18, align 4, !tbaa !9
  %153 = load i32, ptr %18, align 4, !tbaa !9
  %154 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %155 = load i32, ptr %154, align 8, !tbaa !12
  %156 = add i32 %155, %153
  store i32 %156, ptr %154, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %157

157:                                              ; preds = %147, %113
  br label %158

158:                                              ; preds = %157, %109
  br label %171

159:                                              ; preds = %106
  %160 = call i32 @jsonparse_strcmp_value(ptr noundef %20, ptr noundef @.str.8)
  %161 = icmp eq i32 %160, 0
  br i1 %161, label %162, label %170

162:                                              ; preds = %159
  %163 = call i32 @jsonparse_next(ptr noundef %20)
  %164 = call i32 @jsonparse_next(ptr noundef %20)
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %169

166:                                              ; preds = %162
  %167 = getelementptr inbounds [1025 x i8], ptr %15, i64 0, i64 0
  %168 = call i32 @jsonparse_copy_value(ptr noundef %20, ptr noundef %167, i32 noundef 1025)
  br label %169

169:                                              ; preds = %166, %162
  br label %170

170:                                              ; preds = %169, %159
  br label %171

171:                                              ; preds = %170, %158
  br label %172

172:                                              ; preds = %171, %105
  br label %173

173:                                              ; preds = %172, %94
  br label %174

174:                                              ; preds = %173, %83
  br label %175

175:                                              ; preds = %174, %72
  br label %176

176:                                              ; preds = %175, %61
  br label %177

177:                                              ; preds = %176, %50
  br label %210

178:                                              ; preds = %37
  %179 = load i32, ptr %10, align 4, !tbaa !9
  %180 = icmp eq i32 %179, 0
  br i1 %180, label %181, label %209

181:                                              ; preds = %178
  %182 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %183 = load i32, ptr %182, align 8, !tbaa !12
  %184 = icmp sgt i32 %183, 0
  br i1 %184, label %185, label %208

185:                                              ; preds = %181
  %186 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 2
  %187 = load i32, ptr %186, align 4, !tbaa !14
  %188 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %189 = load i32, ptr %188, align 8, !tbaa !12
  %190 = sub nsw i32 %187, %189
  %191 = icmp sge i32 %190, 3
  br i1 %191, label %192, label %208

192:                                              ; preds = %185
  %193 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !15
  %195 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %196 = load i32, ptr %195, align 8, !tbaa !12
  %197 = sub nsw i32 %196, 1
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds i8, ptr %194, i64 %198
  %200 = call i32 @ets_strncmp(ptr noundef %199, ptr noundef @.str.9, i32 noundef 4)
  %201 = icmp eq i32 %200, 0
  br i1 %201, label %202, label %207

202:                                              ; preds = %192
  %203 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 1
  %204 = load i32, ptr %203, align 8, !tbaa !12
  %205 = add nsw i32 %204, 3
  store i32 %205, ptr %203, align 8, !tbaa !12
  %206 = getelementptr inbounds %struct.jsonparse_state, ptr %20, i32 0, i32 6
  store i8 110, ptr %206, align 4, !tbaa !18
  br label %31, !llvm.loop !19

207:                                              ; preds = %192
  br label %208

208:                                              ; preds = %207, %185, %181
  br label %211

209:                                              ; preds = %178
  br label %210

210:                                              ; preds = %209, %177
  br label %31, !llvm.loop !19

211:                                              ; preds = %208, %31
  %212 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %213 = call i32 @ets_strcmp(ptr noundef %212, ptr noundef @.str.10)
  %214 = icmp eq i32 %213, 0
  br i1 %214, label %215, label %224

215:                                              ; preds = %211
  %216 = getelementptr inbounds [172 x i8], ptr %16, i64 0, i64 0
  %217 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef @mTimestamp, i32 noundef 192, ptr noundef @dhconnector_websocket_api_communicate.timestampTemplate, ptr noundef %216)
  call void @llvm.lifetime.start.p0(i64 16, ptr %22) #3
  %218 = getelementptr inbounds %struct.COMMAND_RESULT, ptr %22, i32 0, i32 0
  store ptr @dhsender_response, ptr %218, align 8, !tbaa !20
  %219 = load i32, ptr %19, align 4, !tbaa !9
  %220 = getelementptr inbounds %struct.COMMAND_RESULT, ptr %22, i32 0, i32 1
  store i32 %219, ptr %220, align 8, !tbaa !11
  %221 = getelementptr inbounds [128 x i8], ptr %13, i64 0, i64 0
  %222 = load ptr, ptr %17, align 8, !tbaa !5
  %223 = load i32, ptr %18, align 4, !tbaa !9
  call void @dhcommands_do(ptr noundef %22, ptr noundef %221, ptr noundef %222, i32 noundef %223)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #3
  br label %339

224:                                              ; preds = %211
  %225 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %226 = call i32 @ets_strcmp(ptr noundef %225, ptr noundef @.str.11)
  %227 = icmp eq i32 %226, 0
  br i1 %227, label %228, label %254

228:                                              ; preds = %224
  %229 = getelementptr inbounds [1025 x i8], ptr %15, i64 0, i64 0
  %230 = load i8, ptr %229, align 16, !tbaa !11
  %231 = sext i8 %230 to i32
  %232 = icmp ne i32 %231, 0
  br i1 %232, label %233, label %245

233:                                              ; preds = %228
  %234 = load i32, ptr %11, align 4, !tbaa !9
  %235 = icmp ne i32 %234, 0
  br i1 %235, label %245, label %236

236:                                              ; preds = %233
  br label %237

237:                                              ; preds = %236
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str)
  br label %238

238:                                              ; preds = %237
  br label %239

239:                                              ; preds = %238
  %240 = load ptr, ptr %8, align 8, !tbaa !5
  %241 = load i32, ptr %9, align 4, !tbaa !9
  %242 = getelementptr inbounds [1025 x i8], ptr %15, i64 0, i64 0
  %243 = call ptr @dhsettings_get_devicehive_deviceid()
  %244 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %240, i32 noundef %241, ptr noundef @dhconnector_websocket_api_communicate.template, ptr noundef %242, ptr noundef %243)
  store i32 %244, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %339

245:                                              ; preds = %233, %228
  br label %246

246:                                              ; preds = %245
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.12)
  br label %247

247:                                              ; preds = %246
  br label %248

248:                                              ; preds = %247
  %249 = load ptr, ptr %8, align 8, !tbaa !5
  %250 = load i32, ptr %9, align 4, !tbaa !9
  %251 = call ptr @dhsettings_get_devicehive_key()
  %252 = call ptr @dhsettings_get_devicehive_deviceid()
  %253 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %249, i32 noundef %250, ptr noundef @dhconnector_websocket_api_communicate.template, ptr noundef %251, ptr noundef %252)
  store i32 %253, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %339

254:                                              ; preds = %224
  %255 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %256 = call i32 @ets_strcmp(ptr noundef %255, ptr noundef @.str.13)
  %257 = icmp eq i32 %256, 0
  br i1 %257, label %258, label %282

258:                                              ; preds = %254
  call void @llvm.lifetime.start.p0(i64 9, ptr %24) #3
  %259 = load i32, ptr %11, align 4, !tbaa !9
  %260 = icmp ne i32 %259, 0
  br i1 %260, label %261, label %266

261:                                              ; preds = %258
  br label %262

262:                                              ; preds = %261
  %263 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.15, ptr noundef %263)
  br label %264

264:                                              ; preds = %262
  br label %265

265:                                              ; preds = %264
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %281

266:                                              ; preds = %258
  br label %267

267:                                              ; preds = %266
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.16)
  br label %268

268:                                              ; preds = %267
  br label %269

269:                                              ; preds = %268
  %270 = getelementptr inbounds [9 x i8], ptr %24, i64 0, i64 0
  %271 = call ptr @dhsettings_get_devicehive_key()
  %272 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %270, i32 noundef 9, ptr noundef @.str.17, ptr noundef %271)
  %273 = load ptr, ptr %8, align 8, !tbaa !5
  %274 = load i32, ptr %9, align 4, !tbaa !9
  %275 = call ptr @dhsettings_get_devicehive_deviceid()
  %276 = getelementptr inbounds [9 x i8], ptr %24, i64 0, i64 0
  %277 = call ptr @dhsettings_get_devicehive_deviceid()
  %278 = call ptr @dhsettings_get_devicehive_deviceid()
  %279 = getelementptr inbounds [9 x i8], ptr %24, i64 0, i64 0
  %280 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %273, i32 noundef %274, ptr noundef @dhconnector_websocket_api_communicate.template.14, ptr noundef %275, ptr noundef %276, ptr noundef %277, ptr noundef %278, ptr noundef %279)
  store i32 %280, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %281

281:                                              ; preds = %269, %265
  call void @llvm.lifetime.end.p0(i64 9, ptr %24) #3
  br label %339

282:                                              ; preds = %254
  %283 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %284 = call i32 @ets_strcmp(ptr noundef %283, ptr noundef @.str.18)
  %285 = icmp eq i32 %284, 0
  br i1 %285, label %286, label %307

286:                                              ; preds = %282
  %287 = load i32, ptr %11, align 4, !tbaa !9
  %288 = icmp ne i32 %287, 0
  br i1 %288, label %289, label %294

289:                                              ; preds = %286
  br label %290

290:                                              ; preds = %289
  %291 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.20, ptr noundef %291)
  br label %292

292:                                              ; preds = %290
  br label %293

293:                                              ; preds = %292
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %339

294:                                              ; preds = %286
  br label %295

295:                                              ; preds = %294
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.21)
  br label %296

296:                                              ; preds = %295
  br label %297

297:                                              ; preds = %296
  %298 = load ptr, ptr %8, align 8, !tbaa !5
  %299 = load i32, ptr %9, align 4, !tbaa !9
  %300 = call ptr @dhsettings_get_devicehive_deviceid()
  %301 = load i8, ptr @mTimestamp, align 16, !tbaa !11
  %302 = sext i8 %301 to i32
  %303 = icmp ne i32 %302, 0
  %304 = zext i1 %303 to i64
  %305 = select i1 %303, ptr @mTimestamp, ptr @.str.22
  %306 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %298, i32 noundef %299, ptr noundef @dhconnector_websocket_api_communicate.template.19, ptr noundef %300, ptr noundef %305)
  store i32 %306, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %339

307:                                              ; preds = %282
  %308 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %309 = call i32 @ets_strcmp(ptr noundef %308, ptr noundef @.str.23)
  %310 = icmp eq i32 %309, 0
  br i1 %310, label %311, label %320

311:                                              ; preds = %307
  %312 = load i32, ptr %11, align 4, !tbaa !9
  %313 = icmp ne i32 %312, 0
  br i1 %313, label %314, label %319

314:                                              ; preds = %311
  br label %315

315:                                              ; preds = %314
  %316 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.24, ptr noundef %316)
  br label %317

317:                                              ; preds = %315
  br label %318

318:                                              ; preds = %317
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %339

319:                                              ; preds = %311
  store i8 1, ptr @connected, align 1, !tbaa !11
  br label %334

320:                                              ; preds = %307
  %321 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 0
  %322 = call i32 @ets_strcmp(ptr noundef %321, ptr noundef @.str.25)
  %323 = icmp eq i32 %322, 0
  br i1 %323, label %324, label %333

324:                                              ; preds = %320
  %325 = load i32, ptr %11, align 4, !tbaa !9
  %326 = icmp ne i32 %325, 0
  br i1 %326, label %327, label %332

327:                                              ; preds = %324
  br label %328

328:                                              ; preds = %327
  %329 = getelementptr inbounds [256 x i8], ptr %14, i64 0, i64 0
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhconnector_websocket_api_communicate.str.26, ptr noundef %329)
  br label %330

330:                                              ; preds = %328
  br label %331

331:                                              ; preds = %330
  br label %332

332:                                              ; preds = %331, %324
  br label %333

333:                                              ; preds = %332, %320
  br label %334

334:                                              ; preds = %333, %319
  br label %335

335:                                              ; preds = %334
  br label %336

336:                                              ; preds = %335
  br label %337

337:                                              ; preds = %336
  br label %338

338:                                              ; preds = %337
  store i32 0, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %339

339:                                              ; preds = %338, %318, %297, %293, %281, %248, %239, %215
  call void @llvm.lifetime.end.p0(i64 40, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 172, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 1025, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 256, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 128, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %340 = load i32, ptr %5, align 4
  ret i32 %340
}

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

declare void @jsonparse_setup(ptr noundef, ptr noundef, i32 noundef) #0

declare i32 @jsonparse_next(ptr noundef) #0

declare i32 @jsonparse_strcmp_value(ptr noundef, ptr noundef) #0

declare i32 @jsonparse_copy_value(ptr noundef, ptr noundef, i32 noundef) #0

declare i64 @jsonparse_get_value_as_ulong(ptr noundef) #0

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

declare i32 @ets_strncmp(ptr noundef, ptr noundef, i32 noundef) #0

declare i32 @ets_strcmp(ptr noundef, ptr noundef) #0

declare void @dhsender_response(ptr, i32 noundef, i32 noundef, ...) #0

declare void @dhcommands_do(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

declare void @dhdebug_ram(ptr noundef, ...) #0

declare ptr @dhsettings_get_devicehive_deviceid() #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 8}
!13 = !{!"jsonparse_state", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 30}
!14 = !{!13, !10, i64 12}
!15 = !{!13, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!13, !7, i64 28}
!19 = distinct !{!19, !17}
!20 = !{!21, !6, i64 0}
!21 = !{!"", !6, i64 0, !7, i64 8}


; 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.jsonparse_state = type { ptr, i32, i32, i32, i32, i32, i8, i8, [10 x i8] }
%struct.COMMAND_RESULT = type { ptr, %union.CommandResultArgument }
%union.CommandResultArgument = type { ptr }

@connected = external hidden local_unnamed_addr global i8, align 1
@dhconnector_websocket_api_communicate.timestampTemplate = external hidden constant [18 x i8], align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@mTimestamp = external hidden global [192 x i8], align 16
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1
@dhconnector_websocket_api_communicate.template = external hidden constant [55 x i8], align 4
@dhconnector_websocket_api_communicate.str = external hidden constant [20 x i8], align 4
@dhconnector_websocket_api_communicate.str.12 = external hidden constant [56 x i8], align 4
@.str.13 = external hidden unnamed_addr constant [13 x i8], align 1
@dhconnector_websocket_api_communicate.template.14 = external hidden constant [194 x i8], align 4
@dhconnector_websocket_api_communicate.str.15 = external hidden constant [27 x i8], align 4
@dhconnector_websocket_api_communicate.str.16 = external hidden constant [26 x i8], align 4
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [12 x i8], align 1
@dhconnector_websocket_api_communicate.template.19 = external hidden constant [49 x i8], align 4
@dhconnector_websocket_api_communicate.str.20 = external hidden constant [26 x i8], align 4
@dhconnector_websocket_api_communicate.str.21 = external hidden constant [13 x i8], align 4
@.str.22 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [18 x i8], align 1
@dhconnector_websocket_api_communicate.str.24 = external hidden constant [25 x i8], align 4
@.str.25 = external hidden unnamed_addr constant [15 x i8], align 1
@dhconnector_websocket_api_communicate.str.26 = external hidden constant [29 x i8], align 4

declare i32 @snprintf(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

declare ptr @dhsettings_get_devicehive_key() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @dhconnector_websocket_api_communicate(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca [32 x i8], align 16
  %6 = alloca [128 x i8], align 16
  %7 = alloca [256 x i8], align 16
  %8 = alloca [1025 x i8], align 16
  %9 = alloca [172 x i8], align 16
  %10 = alloca %struct.jsonparse_state, align 8
  %11 = alloca %struct.COMMAND_RESULT, align 8
  %12 = alloca [9 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 1025, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 172, ptr nonnull %9) #3
  store i8 0, ptr %5, align 16, !tbaa !5
  store i8 0, ptr %6, align 16, !tbaa !5
  store i8 0, ptr %8, align 16, !tbaa !5
  store i8 0, ptr %7, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %10) #3
  call void @jsonparse_setup(ptr noundef nonnull %10, ptr noundef %0, i32 noundef %1) #3
  %13 = getelementptr inbounds i8, ptr %10, i64 8
  %14 = getelementptr inbounds i8, ptr %10, i64 12
  %15 = load i32, ptr %13, align 8, !tbaa !8
  %16 = load i32, ptr %14, align 4, !tbaa !12
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %.lr.ph.lr.ph, label %.outer._crit_edge

.lr.ph.lr.ph:                                     ; preds = %4
  %18 = getelementptr inbounds i8, ptr %10, i64 28
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.lr.ph, %.outer
  %.029.ph87 = phi i32 [ 0, %.lr.ph.lr.ph ], [ %.1, %.outer ]
  %.030.ph86 = phi i32 [ 0, %.lr.ph.lr.ph ], [ %.131, %.outer ]
  %.032.ph85 = phi ptr [ null, %.lr.ph.lr.ph ], [ %.133, %.outer ]
  %.034.ph84 = phi i32 [ 1, %.lr.ph.lr.ph ], [ %.135, %.outer ]
  br label %19

19:                                               ; preds = %.lr.ph, %114
  %20 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  switch i32 %20, label %.outer [
    i32 78, label %21
    i32 0, label %100
  ]

21:                                               ; preds = %19
  %22 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str) #3
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  %25 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %26 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not51 = icmp eq i32 %26, 0
  br i1 %.not51, label %.outer, label %27

27:                                               ; preds = %24
  %28 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.1) #3
  br label %.outer

29:                                               ; preds = %21
  %30 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.2) #3
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %37

32:                                               ; preds = %29
  %33 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %34 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not50 = icmp eq i32 %34, 0
  br i1 %.not50, label %.outer, label %35

35:                                               ; preds = %32
  %36 = call i32 @jsonparse_copy_value(ptr noundef nonnull %10, ptr noundef nonnull %7, i32 noundef 256) #3
  br label %.outer

37:                                               ; preds = %29
  %38 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.3) #3
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %37
  %41 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %42 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not49 = icmp eq i32 %42, 0
  br i1 %.not49, label %.outer, label %43

43:                                               ; preds = %40
  %44 = call i32 @jsonparse_copy_value(ptr noundef nonnull %10, ptr noundef nonnull %5, i32 noundef 32) #3
  br label %.outer

45:                                               ; preds = %37
  %46 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.4) #3
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %53

48:                                               ; preds = %45
  %49 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %50 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not48 = icmp eq i32 %50, 0
  br i1 %.not48, label %.outer, label %51

51:                                               ; preds = %48
  %52 = call i32 @jsonparse_copy_value(ptr noundef nonnull %10, ptr noundef nonnull %6, i32 noundef 128) #3
  br label %.outer

53:                                               ; preds = %45
  %54 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.5) #3
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %62

56:                                               ; preds = %53
  %57 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %58 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not47 = icmp eq i32 %58, 0
  br i1 %.not47, label %.outer, label %59

59:                                               ; preds = %56
  %60 = call i64 @jsonparse_get_value_as_ulong(ptr noundef nonnull %10) #3
  %61 = trunc i64 %60 to i32
  br label %.outer

62:                                               ; preds = %53
  %63 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.6) #3
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %67 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not46 = icmp eq i32 %67, 0
  br i1 %.not46, label %.outer, label %68

68:                                               ; preds = %65
  %69 = call i32 @jsonparse_copy_value(ptr noundef nonnull %10, ptr noundef nonnull %9, i32 noundef 172) #3
  br label %.outer

70:                                               ; preds = %62
  %71 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.7) #3
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %92

73:                                               ; preds = %70
  %74 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %75 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not44 = icmp eq i32 %75, 0
  br i1 %.not44, label %.outer, label %76

76:                                               ; preds = %73
  %77 = load ptr, ptr %10, align 8, !tbaa !13
  %78 = load i32, ptr %13, align 8, !tbaa !8
  %79 = sext i32 %78 to i64
  %80 = getelementptr i8, ptr %77, i64 %79
  %81 = getelementptr i8, ptr %80, i64 -1
  %82 = load i8, ptr %81, align 1, !tbaa !5
  %83 = icmp eq i8 %82, 123
  br i1 %83, label %.preheader, label %.outer

.preheader:                                       ; preds = %76
  %84 = load i32, ptr %14, align 4, !tbaa !12
  %85 = icmp slt i32 %78, %84
  br i1 %85, label %.lr.ph80, label %.critedge

.lr.ph80:                                         ; preds = %.preheader, %88
  %indvars.iv = phi i64 [ %indvars.iv.next, %88 ], [ %79, %.preheader ]
  %86 = getelementptr inbounds i8, ptr %77, i64 %indvars.iv
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %.not45 = icmp eq i8 %87, 125
  br i1 %.not45, label %.critedge.loopexit.split.loop.exit103, label %88

88:                                               ; preds = %.lr.ph80
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %84, %lftr.wideiv
  br i1 %exitcond.not, label %.critedge, label %.lr.ph80, !llvm.loop !14

.critedge.loopexit.split.loop.exit103:            ; preds = %.lr.ph80
  %89 = trunc nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %88, %.critedge.loopexit.split.loop.exit103, %.preheader
  %.0.lcssa = phi i32 [ %78, %.preheader ], [ %89, %.critedge.loopexit.split.loop.exit103 ], [ %84, %88 ]
  %reass.sub = sub i32 %.0.lcssa, %78
  %90 = add i32 %reass.sub, 2
  %91 = add i32 %.0.lcssa, 2
  store i32 %91, ptr %13, align 8, !tbaa !8
  br label %.outer

92:                                               ; preds = %70
  %93 = call i32 @jsonparse_strcmp_value(ptr noundef nonnull %10, ptr noundef nonnull @.str.8) #3
  %94 = icmp eq i32 %93, 0
  br i1 %94, label %95, label %.outer

95:                                               ; preds = %92
  %96 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %97 = call i32 @jsonparse_next(ptr noundef nonnull %10) #3
  %.not43 = icmp eq i32 %97, 0
  br i1 %.not43, label %.outer, label %98

98:                                               ; preds = %95
  %99 = call i32 @jsonparse_copy_value(ptr noundef nonnull %10, ptr noundef nonnull %8, i32 noundef 1025) #3
  br label %.outer

100:                                              ; preds = %19
  %101 = load i32, ptr %13, align 8, !tbaa !8
  %102 = icmp sgt i32 %101, 0
  br i1 %102, label %103, label %.outer._crit_edge

103:                                              ; preds = %100
  %104 = load i32, ptr %14, align 4, !tbaa !12
  %105 = sub nsw i32 %104, %101
  %106 = icmp sgt i32 %105, 2
  br i1 %106, label %107, label %.outer._crit_edge

107:                                              ; preds = %103
  %108 = load ptr, ptr %10, align 8, !tbaa !13
  %109 = zext nneg i32 %101 to i64
  %110 = getelementptr i8, ptr %108, i64 %109
  %111 = getelementptr i8, ptr %110, i64 -1
  %112 = call i32 @ets_strncmp(ptr noundef %111, ptr noundef nonnull @.str.9, i32 noundef 4) #3
  %113 = icmp eq i32 %112, 0
  br i1 %113, label %114, label %.outer._crit_edge

114:                                              ; preds = %107
  %115 = load i32, ptr %13, align 8, !tbaa !8
  %116 = add nsw i32 %115, 3
  store i32 %116, ptr %13, align 8, !tbaa !8
  store i8 110, ptr %18, align 4, !tbaa !16
  %117 = load i32, ptr %14, align 4, !tbaa !12
  %118 = icmp slt i32 %116, %117
  br i1 %118, label %19, label %.outer._crit_edge, !llvm.loop !17

.outer:                                           ; preds = %19, %27, %24, %43, %40, %59, %56, %76, %.critedge, %73, %95, %98, %92, %65, %68, %48, %51, %32, %35
  %.135 = phi i32 [ %28, %27 ], [ %.034.ph84, %24 ], [ %.034.ph84, %35 ], [ %.034.ph84, %32 ], [ %.034.ph84, %43 ], [ %.034.ph84, %40 ], [ %.034.ph84, %51 ], [ %.034.ph84, %48 ], [ %.034.ph84, %59 ], [ %.034.ph84, %56 ], [ %.034.ph84, %68 ], [ %.034.ph84, %65 ], [ %.034.ph84, %.critedge ], [ %.034.ph84, %76 ], [ %.034.ph84, %73 ], [ %.034.ph84, %98 ], [ %.034.ph84, %95 ], [ %.034.ph84, %92 ], [ %.034.ph84, %19 ]
  %.133 = phi ptr [ %.032.ph85, %27 ], [ %.032.ph85, %24 ], [ %.032.ph85, %35 ], [ %.032.ph85, %32 ], [ %.032.ph85, %43 ], [ %.032.ph85, %40 ], [ %.032.ph85, %51 ], [ %.032.ph85, %48 ], [ %.032.ph85, %59 ], [ %.032.ph85, %56 ], [ %.032.ph85, %68 ], [ %.032.ph85, %65 ], [ %81, %.critedge ], [ %81, %76 ], [ %.032.ph85, %73 ], [ %.032.ph85, %98 ], [ %.032.ph85, %95 ], [ %.032.ph85, %92 ], [ %.032.ph85, %19 ]
  %.131 = phi i32 [ %.030.ph86, %27 ], [ %.030.ph86, %24 ], [ %.030.ph86, %35 ], [ %.030.ph86, %32 ], [ %.030.ph86, %43 ], [ %.030.ph86, %40 ], [ %.030.ph86, %51 ], [ %.030.ph86, %48 ], [ %.030.ph86, %59 ], [ %.030.ph86, %56 ], [ %.030.ph86, %68 ], [ %.030.ph86, %65 ], [ %90, %.critedge ], [ %.030.ph86, %76 ], [ %.030.ph86, %73 ], [ %.030.ph86, %98 ], [ %.030.ph86, %95 ], [ %.030.ph86, %92 ], [ %.030.ph86, %19 ]
  %.1 = phi i32 [ %.029.ph87, %27 ], [ %.029.ph87, %24 ], [ %.029.ph87, %35 ], [ %.029.ph87, %32 ], [ %.029.ph87, %43 ], [ %.029.ph87, %40 ], [ %.029.ph87, %51 ], [ %.029.ph87, %48 ], [ %61, %59 ], [ %.029.ph87, %56 ], [ %.029.ph87, %68 ], [ %.029.ph87, %65 ], [ %.029.ph87, %.critedge ], [ %.029.ph87, %76 ], [ %.029.ph87, %73 ], [ %.029.ph87, %98 ], [ %.029.ph87, %95 ], [ %.029.ph87, %92 ], [ %.029.ph87, %19 ]
  %119 = load i32, ptr %13, align 8, !tbaa !8
  %120 = load i32, ptr %14, align 4, !tbaa !12
  %121 = icmp slt i32 %119, %120
  br i1 %121, label %.lr.ph, label %.outer._crit_edge, !llvm.loop !17

.outer._crit_edge:                                ; preds = %.outer, %114, %107, %103, %100, %4
  %.034.ph.lcssa = phi i32 [ 1, %4 ], [ %.034.ph84, %100 ], [ %.034.ph84, %103 ], [ %.034.ph84, %107 ], [ %.034.ph84, %114 ], [ %.135, %.outer ]
  %.032.ph.lcssa = phi ptr [ null, %4 ], [ %.032.ph85, %100 ], [ %.032.ph85, %103 ], [ %.032.ph85, %107 ], [ %.032.ph85, %114 ], [ %.133, %.outer ]
  %.030.ph.lcssa = phi i32 [ 0, %4 ], [ %.030.ph86, %100 ], [ %.030.ph86, %103 ], [ %.030.ph86, %107 ], [ %.030.ph86, %114 ], [ %.131, %.outer ]
  %.029.ph.lcssa = phi i32 [ 0, %4 ], [ %.029.ph87, %100 ], [ %.029.ph87, %103 ], [ %.029.ph87, %107 ], [ %.029.ph87, %114 ], [ %.1, %.outer ]
  %122 = call i32 @ets_strcmp(ptr noundef nonnull %5, ptr noundef nonnull @.str.10) #3
  %123 = icmp eq i32 %122, 0
  br i1 %123, label %124, label %127

124:                                              ; preds = %.outer._crit_edge
  %125 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef nonnull @mTimestamp, i32 noundef 192, ptr noundef nonnull @dhconnector_websocket_api_communicate.timestampTemplate, ptr noundef nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %11) #3
  store ptr @dhsender_response, ptr %11, align 8, !tbaa !18
  %126 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %.029.ph.lcssa, ptr %126, align 8, !tbaa !5
  call void @dhcommands_do(ptr noundef nonnull %11, ptr noundef nonnull %6, ptr noundef %.032.ph.lcssa, i32 noundef %.030.ph.lcssa) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #3
  br label %175

127:                                              ; preds = %.outer._crit_edge
  %128 = call i32 @ets_strcmp(ptr noundef nonnull %5, ptr noundef nonnull @.str.11) #3
  %129 = icmp eq i32 %128, 0
  br i1 %129, label %130, label %141

130:                                              ; preds = %127
  %131 = load i8, ptr %8, align 16, !tbaa !5
  %132 = icmp eq i8 %131, 0
  %133 = icmp ne i32 %.034.ph.lcssa, 0
  %or.cond = select i1 %132, i1 true, i1 %133
  br i1 %or.cond, label %137, label %134

134:                                              ; preds = %130
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str) #3
  %135 = call ptr @dhsettings_get_devicehive_deviceid() #3
  %136 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %2, i32 noundef %3, ptr noundef nonnull @dhconnector_websocket_api_communicate.template, ptr noundef nonnull %8, ptr noundef %135) #3
  br label %175

137:                                              ; preds = %130
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.12) #3
  %138 = call ptr @dhsettings_get_devicehive_key() #3
  %139 = call ptr @dhsettings_get_devicehive_deviceid() #3
  %140 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %2, i32 noundef %3, ptr noundef nonnull @dhconnector_websocket_api_communicate.template, ptr noundef %138, ptr noundef %139) #3
  br label %175

141:                                              ; preds = %127
  %142 = call i32 @ets_strcmp(ptr noundef nonnull %5, ptr noundef nonnull @.str.13) #3
  %143 = icmp eq i32 %142, 0
  br i1 %143, label %144, label %154

144:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %12) #3
  %.not42 = icmp eq i32 %.034.ph.lcssa, 0
  br i1 %.not42, label %146, label %145

145:                                              ; preds = %144
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.15, ptr noundef nonnull %7) #3
  br label %153

146:                                              ; preds = %144
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.16) #3
  %147 = call ptr @dhsettings_get_devicehive_key() #3
  %148 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef nonnull %12, i32 noundef 9, ptr noundef nonnull @.str.17, ptr noundef %147) #3
  %149 = call ptr @dhsettings_get_devicehive_deviceid() #3
  %150 = call ptr @dhsettings_get_devicehive_deviceid() #3
  %151 = call ptr @dhsettings_get_devicehive_deviceid() #3
  %152 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %2, i32 noundef %3, ptr noundef nonnull @dhconnector_websocket_api_communicate.template.14, ptr noundef %149, ptr noundef nonnull %12, ptr noundef %150, ptr noundef %151, ptr noundef nonnull %12) #3
  br label %153

153:                                              ; preds = %146, %145
  %.036 = phi i32 [ -1, %145 ], [ %152, %146 ]
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %12) #3
  br label %175

154:                                              ; preds = %141
  %155 = call i32 @ets_strcmp(ptr noundef nonnull %5, ptr noundef nonnull @.str.18) #3
  %156 = icmp eq i32 %155, 0
  br i1 %156, label %157, label %164

157:                                              ; preds = %154
  %.not40 = icmp eq i32 %.034.ph.lcssa, 0
  br i1 %.not40, label %159, label %158

158:                                              ; preds = %157
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.20, ptr noundef nonnull %7) #3
  br label %175

159:                                              ; preds = %157
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.21) #3
  %160 = call ptr @dhsettings_get_devicehive_deviceid() #3
  %161 = load i8, ptr @mTimestamp, align 16, !tbaa !5
  %.not41 = icmp eq i8 %161, 0
  %162 = select i1 %.not41, ptr @.str.22, ptr @mTimestamp
  %163 = call i32 (ptr, i32, ptr, ...) @snprintf(ptr noundef %2, i32 noundef %3, ptr noundef nonnull @dhconnector_websocket_api_communicate.template.19, ptr noundef %160, ptr noundef nonnull %162) #3
  br label %175

164:                                              ; preds = %154
  %165 = call i32 @ets_strcmp(ptr noundef nonnull %5, ptr noundef nonnull @.str.23) #3
  %166 = icmp eq i32 %165, 0
  br i1 %166, label %167, label %170

167:                                              ; preds = %164
  %.not = icmp eq i32 %.034.ph.lcssa, 0
  br i1 %.not, label %169, label %168

168:                                              ; preds = %167
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.24, ptr noundef nonnull %7) #3
  br label %175

169:                                              ; preds = %167
  store i8 1, ptr @connected, align 1, !tbaa !5
  br label %175

170:                                              ; preds = %164
  %171 = call i32 @ets_strcmp(ptr noundef nonnull %5, ptr noundef nonnull @.str.25) #3
  %172 = icmp eq i32 %171, 0
  %173 = icmp ne i32 %.034.ph.lcssa, 0
  %or.cond3 = select i1 %172, i1 %173, i1 false
  br i1 %or.cond3, label %174, label %175

174:                                              ; preds = %170
  call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhconnector_websocket_api_communicate.str.26, ptr noundef nonnull %7) #3
  br label %175

175:                                              ; preds = %169, %174, %170, %168, %159, %158, %153, %137, %134, %124
  %.137 = phi i32 [ 0, %124 ], [ %140, %137 ], [ %136, %134 ], [ %.036, %153 ], [ -1, %158 ], [ %163, %159 ], [ -1, %168 ], [ 0, %170 ], [ 0, %174 ], [ 0, %169 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 172, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 1025, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #3
  ret i32 %.137
}

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

declare void @jsonparse_setup(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @jsonparse_next(ptr noundef) local_unnamed_addr #0

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

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

declare i64 @jsonparse_get_value_as_ulong(ptr noundef) local_unnamed_addr #0

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

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

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

declare void @dhsender_response(ptr, i32 noundef, i32 noundef, ...) #0

declare void @dhcommands_do(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @dhdebug_ram(ptr noundef, ...) local_unnamed_addr #0

declare ptr @dhsettings_get_devicehive_deviceid() 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"jsonparse_state", !10, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 28, !6, i64 29, !6, i64 30}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!9, !11, i64 12}
!13 = !{!9, !10, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!9, !6, i64 28}
!17 = distinct !{!17, !15}
!18 = !{!19, !10, i64 0}
!19 = !{!"", !10, i64 0, !6, i64 8}


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