; LLVM IR from devicehive/esp8266-firmware :: esp-utils/esp-flasher.ll (Z10flash_sendP10SerialPortP18ESP_REQUEST_HEADERPvb)

; 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.ESP_REQUEST_HEADER = type { i8, i8, i16, i32 }

@TIMEOUT = external dso_local global i32, align 4
@recivedBuf = external dso_local global [4096 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z17clearReciveBufferv() #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z10flash_sendP10SerialPortP18ESP_REQUEST_HEADERPvb(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #3 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  %18 = zext i1 %3 to i8
  store i8 %18, ptr %9, align 1, !tbaa !9
  call void @_Z17clearReciveBufferv()
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %19, ptr %10, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ESP_REQUEST_HEADER, ptr %20, i32 0, i32 2
  %22 = load i16, ptr %21, align 2, !tbaa !11
  %23 = zext i16 %22 to i64
  %24 = add i64 8, %23
  %25 = mul i64 %24, 2
  %26 = call ptr @llvm.stacksave.p0()
  store ptr %26, ptr %11, align 8
  %27 = alloca i8, i64 %25, align 16
  store i64 %25, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !15
  %28 = load i32, ptr %13, align 4, !tbaa !15
  %29 = add i32 %28, 1
  store i32 %29, ptr %13, align 4, !tbaa !15
  %30 = zext i32 %28 to i64
  %31 = getelementptr inbounds i8, ptr %27, i64 %30
  store i8 -64, ptr %31, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !15
  br label %32

32:                                               ; preds = %93, %4
  %33 = load i32, ptr %14, align 4, !tbaa !15
  %34 = zext i32 %33 to i64
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ESP_REQUEST_HEADER, ptr %35, i32 0, i32 2
  %37 = load i16, ptr %36, align 2, !tbaa !11
  %38 = zext i16 %37 to i64
  %39 = add i64 8, %38
  %40 = icmp ult i64 %34, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %96

42:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #5
  %43 = load i32, ptr %14, align 4, !tbaa !15
  %44 = zext i32 %43 to i64
  %45 = icmp uge i64 %44, 8
  br i1 %45, label %46, label %53

46:                                               ; preds = %42
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i32, ptr %14, align 4, !tbaa !15
  %49 = zext i32 %48 to i64
  %50 = sub i64 %49, 8
  %51 = getelementptr inbounds i8, ptr %47, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !16
  store i8 %52, ptr %15, align 1, !tbaa !16
  br label %59

53:                                               ; preds = %42
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load i32, ptr %14, align 4, !tbaa !15
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !16
  store i8 %58, ptr %15, align 1, !tbaa !16
  br label %59

59:                                               ; preds = %53, %46
  %60 = load i8, ptr %15, align 1, !tbaa !16
  %61 = zext i8 %60 to i32
  %62 = icmp eq i32 %61, 219
  br i1 %62, label %63, label %72

63:                                               ; preds = %59
  %64 = load i32, ptr %13, align 4, !tbaa !15
  %65 = add i32 %64, 1
  store i32 %65, ptr %13, align 4, !tbaa !15
  %66 = zext i32 %64 to i64
  %67 = getelementptr inbounds i8, ptr %27, i64 %66
  store i8 -37, ptr %67, align 1, !tbaa !16
  %68 = load i32, ptr %13, align 4, !tbaa !15
  %69 = add i32 %68, 1
  store i32 %69, ptr %13, align 4, !tbaa !15
  %70 = zext i32 %68 to i64
  %71 = getelementptr inbounds i8, ptr %27, i64 %70
  store i8 -35, ptr %71, align 1, !tbaa !16
  br label %92

72:                                               ; preds = %59
  %73 = load i8, ptr %15, align 1, !tbaa !16
  %74 = zext i8 %73 to i32
  %75 = icmp eq i32 %74, 192
  br i1 %75, label %76, label %85

76:                                               ; preds = %72
  %77 = load i32, ptr %13, align 4, !tbaa !15
  %78 = add i32 %77, 1
  store i32 %78, ptr %13, align 4, !tbaa !15
  %79 = zext i32 %77 to i64
  %80 = getelementptr inbounds i8, ptr %27, i64 %79
  store i8 -37, ptr %80, align 1, !tbaa !16
  %81 = load i32, ptr %13, align 4, !tbaa !15
  %82 = add i32 %81, 1
  store i32 %82, ptr %13, align 4, !tbaa !15
  %83 = zext i32 %81 to i64
  %84 = getelementptr inbounds i8, ptr %27, i64 %83
  store i8 -36, ptr %84, align 1, !tbaa !16
  br label %91

85:                                               ; preds = %72
  %86 = load i8, ptr %15, align 1, !tbaa !16
  %87 = load i32, ptr %13, align 4, !tbaa !15
  %88 = add i32 %87, 1
  store i32 %88, ptr %13, align 4, !tbaa !15
  %89 = zext i32 %87 to i64
  %90 = getelementptr inbounds i8, ptr %27, i64 %89
  store i8 %86, ptr %90, align 1, !tbaa !16
  br label %91

91:                                               ; preds = %85, %76
  br label %92

92:                                               ; preds = %91, %63
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %14, align 4, !tbaa !15
  %95 = add i32 %94, 1
  store i32 %95, ptr %14, align 4, !tbaa !15
  br label %32, !llvm.loop !17

96:                                               ; preds = %41
  %97 = load i32, ptr %13, align 4, !tbaa !15
  %98 = add i32 %97, 1
  store i32 %98, ptr %13, align 4, !tbaa !15
  %99 = zext i32 %97 to i64
  %100 = getelementptr inbounds i8, ptr %27, i64 %99
  store i8 -64, ptr %100, align 1, !tbaa !16
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = load i32, ptr %13, align 4, !tbaa !15
  call void @_ZN10SerialPort4sendEPKvj(ptr noundef nonnull align 8 dereferenceable(292) %101, ptr noundef %27, i32 noundef %102)
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr @TIMEOUT, align 4, !tbaa !15
  %105 = call noundef zeroext i1 @_ZN10SerialPort10waitAnswerEjj(ptr noundef nonnull align 8 dereferenceable(292) %103, i32 noundef 5, i32 noundef %104)
  br i1 %105, label %112, label %106

106:                                              ; preds = %96
  %107 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %108 = trunc i8 %107 to i1
  br i1 %108, label %109, label %111

109:                                              ; preds = %106
  %110 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %111

111:                                              ; preds = %109, %106
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %194

112:                                              ; preds = %96
  %113 = load i8, ptr @recivedBuf, align 16, !tbaa !16
  %114 = zext i8 %113 to i32
  %115 = icmp ne i32 %114, 192
  br i1 %115, label %116, label %134

116:                                              ; preds = %112
  %117 = load i8, ptr getelementptr inbounds ([4096 x i8], ptr @recivedBuf, i64 0, i64 1), align 1, !tbaa !16
  %118 = zext i8 %117 to i32
  %119 = icmp ne i32 %118, 1
  br i1 %119, label %120, label %134

120:                                              ; preds = %116
  %121 = load i8, ptr getelementptr inbounds ([4096 x i8], ptr @recivedBuf, i64 0, i64 1), align 1, !tbaa !16
  %122 = zext i8 %121 to i32
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.ESP_REQUEST_HEADER, ptr %123, i32 0, i32 1
  %125 = load i8, ptr %124, align 1, !tbaa !21
  %126 = zext i8 %125 to i32
  %127 = icmp ne i32 %122, %126
  br i1 %127, label %128, label %134

128:                                              ; preds = %120
  %129 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %130 = trunc i8 %129 to i1
  br i1 %130, label %131, label %133

131:                                              ; preds = %128
  %132 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %133

133:                                              ; preds = %131, %128
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %194

134:                                              ; preds = %120, %116, %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %135 = load i8, ptr getelementptr inbounds ([4096 x i8], ptr @recivedBuf, i64 0, i64 3), align 1, !tbaa !16
  %136 = zext i8 %135 to i32
  %137 = load i8, ptr getelementptr inbounds ([4096 x i8], ptr @recivedBuf, i64 0, i64 4), align 4, !tbaa !16
  %138 = zext i8 %137 to i32
  %139 = shl i32 %138, 8
  %140 = or i32 %136, %139
  store i32 %140, ptr %17, align 4, !tbaa !15
  %141 = load ptr, ptr %6, align 8, !tbaa !5
  %142 = load i32, ptr %17, align 4, !tbaa !15
  %143 = add i32 %142, 10
  %144 = load i32, ptr @TIMEOUT, align 4, !tbaa !15
  %145 = call noundef zeroext i1 @_ZN10SerialPort10waitAnswerEjj(ptr noundef nonnull align 8 dereferenceable(292) %141, i32 noundef %143, i32 noundef %144)
  br i1 %145, label %152, label %146

146:                                              ; preds = %134
  %147 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %148 = trunc i8 %147 to i1
  br i1 %148, label %149, label %151

149:                                              ; preds = %146
  %150 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %151

151:                                              ; preds = %149, %146
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %193

152:                                              ; preds = %134
  %153 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN10SerialPort18waitTransmitionEndEj(ptr noundef nonnull align 8 dereferenceable(292) %153, i32 noundef 100)
  %154 = load i32, ptr %17, align 4, !tbaa !15
  %155 = icmp ne i32 %154, 2
  br i1 %155, label %164, label %156

156:                                              ; preds = %152
  %157 = load i32, ptr %17, align 4, !tbaa !15
  %158 = add i32 %157, 9
  %159 = zext i32 %158 to i64
  %160 = getelementptr inbounds [4096 x i8], ptr @recivedBuf, i64 0, i64 %159
  %161 = load i8, ptr %160, align 1, !tbaa !16
  %162 = zext i8 %161 to i32
  %163 = icmp ne i32 %162, 192
  br i1 %163, label %164, label %170

164:                                              ; preds = %156, %152
  %165 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %166 = trunc i8 %165 to i1
  br i1 %166, label %167, label %169

167:                                              ; preds = %164
  %168 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %169

169:                                              ; preds = %167, %164
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %193

170:                                              ; preds = %156
  %171 = load i32, ptr %17, align 4, !tbaa !15
  %172 = add i32 %171, 7
  %173 = zext i32 %172 to i64
  %174 = getelementptr inbounds [4096 x i8], ptr @recivedBuf, i64 0, i64 %173
  %175 = load i8, ptr %174, align 1, !tbaa !16
  %176 = zext i8 %175 to i32
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %192

178:                                              ; preds = %170
  %179 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %180 = trunc i8 %179 to i1
  br i1 %180, label %181, label %191

181:                                              ; preds = %178
  %182 = load i8, ptr getelementptr inbounds ([4096 x i8], ptr @recivedBuf, i64 0, i64 2), align 2, !tbaa !16
  %183 = zext i8 %182 to i32
  %184 = load i32, ptr %17, align 4, !tbaa !15
  %185 = add i32 %184, 8
  %186 = zext i32 %185 to i64
  %187 = getelementptr inbounds [4096 x i8], ptr @recivedBuf, i64 0, i64 %186
  %188 = load i8, ptr %187, align 1, !tbaa !16
  %189 = zext i8 %188 to i32
  %190 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %183, i32 noundef %189)
  br label %191

191:                                              ; preds = %181, %178
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %193

192:                                              ; preds = %170
  store i1 true, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %193

193:                                              ; preds = %192, %191, %169, %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %194

194:                                              ; preds = %193, %133, %111
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %195 = load ptr, ptr %11, align 8
  call void @llvm.stackrestore.p0(ptr %195)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %196 = load i1, ptr %5, align 1
  ret i1 %196
}

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

declare void @_ZN10SerialPort4sendEPKvj(ptr noundef nonnull align 8 dereferenceable(292), ptr noundef, i32 noundef) #0

declare noundef zeroext i1 @_ZN10SerialPort10waitAnswerEjj(ptr noundef nonnull align 8 dereferenceable(292), i32 noundef, i32 noundef) #0

declare void @_ZN10SerialPort18waitTransmitionEndEj(ptr noundef nonnull align 8 dereferenceable(292), i32 noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !13, i64 2}
!12 = !{!"_ZTS18ESP_REQUEST_HEADER", !7, i64 0, !7, i64 1, !13, i64 2, !14, i64 4}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!12, !7, i64 1}


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

@TIMEOUT = external dso_local local_unnamed_addr global i32, align 4
@recivedBuf = external dso_local local_unnamed_addr global [4096 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z17clearReciveBufferv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z10flash_sendP10SerialPortP18ESP_REQUEST_HEADERPvb(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i1 noundef zeroext %3) local_unnamed_addr #2 {
  tail call void @_Z17clearReciveBufferv()
  %5 = getelementptr inbounds i8, ptr %1, i64 2
  %6 = load i16, ptr %5, align 2, !tbaa !5
  %7 = zext i16 %6 to i64
  %8 = shl nuw nsw i64 %7, 1
  %9 = add nuw nsw i64 %8, 16
  %10 = alloca i8, i64 %9, align 16
  store i8 -64, ptr %10, align 16, !tbaa !11
  %invariant.gep = getelementptr i8, ptr %2, i64 -8
  %11 = add nuw nsw i64 %7, 7
  br label %18

12:                                               ; preds = %32
  %13 = add i32 %.142, 1
  %14 = zext i32 %.142 to i64
  %15 = getelementptr inbounds i8, ptr %10, i64 %14
  store i8 -64, ptr %15, align 1, !tbaa !11
  call void @_ZN10SerialPort4sendEPKvj(ptr noundef nonnull align 8 dereferenceable(292) %0, ptr noundef nonnull %10, i32 noundef %13)
  %16 = load i32, ptr @TIMEOUT, align 4, !tbaa !12
  %17 = call noundef zeroext i1 @_ZN10SerialPort10waitAnswerEjj(ptr noundef nonnull align 8 dereferenceable(292) %0, i32 noundef 5, i32 noundef %16)
  br i1 %17, label %36, label %33

18:                                               ; preds = %4, %32
  %indvars.iv = phi i64 [ 0, %4 ], [ %indvars.iv.next, %32 ]
  %.04152 = phi i32 [ 1, %4 ], [ %.142, %32 ]
  %19 = icmp ugt i64 %indvars.iv, 7
  %.039.in.v = select i1 %19, ptr %invariant.gep, ptr %1
  %.039.in = getelementptr i8, ptr %.039.in.v, i64 %indvars.iv
  %.039 = load i8, ptr %.039.in, align 1, !tbaa !11
  %20 = add i32 %.04152, 1
  %21 = zext i32 %.04152 to i64
  %22 = getelementptr inbounds i8, ptr %10, i64 %21
  switch i8 %.039, label %31 [
    i8 -37, label %23
    i8 -64, label %27
  ]

23:                                               ; preds = %18
  store i8 -37, ptr %22, align 1, !tbaa !11
  %24 = add i32 %.04152, 2
  %25 = zext i32 %20 to i64
  %26 = getelementptr inbounds i8, ptr %10, i64 %25
  store i8 -35, ptr %26, align 1, !tbaa !11
  br label %32

27:                                               ; preds = %18
  store i8 -37, ptr %22, align 1, !tbaa !11
  %28 = add i32 %.04152, 2
  %29 = zext i32 %20 to i64
  %30 = getelementptr inbounds i8, ptr %10, i64 %29
  store i8 -36, ptr %30, align 1, !tbaa !11
  br label %32

31:                                               ; preds = %18
  store i8 %.039, ptr %22, align 1, !tbaa !11
  br label %32

32:                                               ; preds = %27, %31, %23
  %.142 = phi i32 [ %24, %23 ], [ %28, %27 ], [ %20, %31 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %11
  br i1 %exitcond.not, label %12, label %18, !llvm.loop !13

33:                                               ; preds = %12
  br i1 %3, label %34, label %73

34:                                               ; preds = %33
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %73

36:                                               ; preds = %12
  %37 = load i8, ptr @recivedBuf, align 16, !tbaa !11
  %38 = icmp ne i8 %37, -64
  %39 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 1), align 1
  %40 = icmp ne i8 %39, 1
  %or.cond = select i1 %38, i1 %40, i1 false
  br i1 %or.cond, label %41, label %47

41:                                               ; preds = %36
  %42 = getelementptr inbounds i8, ptr %1, i64 1
  %43 = load i8, ptr %42, align 1, !tbaa !15
  %.not = icmp eq i8 %39, %43
  br i1 %.not, label %47, label %44

44:                                               ; preds = %41
  br i1 %3, label %45, label %73

45:                                               ; preds = %44
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %73

47:                                               ; preds = %41, %36
  %48 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 3), align 1, !tbaa !11
  %49 = zext i8 %48 to i32
  %50 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 4), align 4, !tbaa !11
  %51 = zext i8 %50 to i32
  %52 = shl nuw nsw i32 %51, 8
  %53 = or disjoint i32 %52, %49
  %54 = add nuw nsw i32 %53, 10
  %55 = load i32, ptr @TIMEOUT, align 4, !tbaa !12
  %56 = call noundef zeroext i1 @_ZN10SerialPort10waitAnswerEjj(ptr noundef nonnull align 8 dereferenceable(292) %0, i32 noundef %54, i32 noundef %55)
  br i1 %56, label %60, label %57

57:                                               ; preds = %47
  br i1 %3, label %58, label %73

58:                                               ; preds = %57
  %59 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %73

60:                                               ; preds = %47
  call void @_ZN10SerialPort18waitTransmitionEndEj(ptr noundef nonnull align 8 dereferenceable(292) %0, i32 noundef 100)
  %.not47 = icmp eq i32 %53, 2
  %61 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 11), align 1
  %.not48 = icmp eq i8 %61, -64
  %or.cond50 = select i1 %.not47, i1 %.not48, i1 false
  br i1 %or.cond50, label %65, label %62

62:                                               ; preds = %60
  br i1 %3, label %63, label %73

63:                                               ; preds = %62
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %73

65:                                               ; preds = %60
  %66 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 9), align 1, !tbaa !11
  %.not49 = icmp eq i8 %66, 0
  %.not51 = xor i1 %3, true
  %brmerge = or i1 %.not49, %.not51
  br i1 %brmerge, label %73, label %67

67:                                               ; preds = %65
  %68 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 2), align 2, !tbaa !11
  %69 = zext i8 %68 to i32
  %70 = load i8, ptr getelementptr inbounds (i8, ptr @recivedBuf, i64 10), align 2, !tbaa !11
  %71 = zext i8 %70 to i32
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %69, i32 noundef %71)
  br label %73

73:                                               ; preds = %65, %58, %57, %63, %62, %67, %44, %45, %33, %34
  %.1 = phi i1 [ false, %34 ], [ false, %33 ], [ false, %45 ], [ false, %44 ], [ false, %58 ], [ false, %57 ], [ false, %63 ], [ false, %62 ], [ false, %67 ], [ %.not49, %65 ]
  ret i1 %.1
}

declare void @_ZN10SerialPort4sendEPKvj(ptr noundef nonnull align 8 dereferenceable(292), ptr noundef, i32 noundef) local_unnamed_addr #3

declare noundef zeroext i1 @_ZN10SerialPort10waitAnswerEjj(ptr noundef nonnull align 8 dereferenceable(292), i32 noundef, i32 noundef) local_unnamed_addr #3

declare void @_ZN10SerialPort18waitTransmitionEndEj(ptr noundef nonnull align 8 dereferenceable(292), i32 noundef) local_unnamed_addr #3

attributes #0 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 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 = { "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" }

!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, !9, i64 2}
!6 = !{!"_ZTS18ESP_REQUEST_HEADER", !7, i64 0, !7, i64 1, !9, i64 2, !10, i64 4}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"short", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 1}


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