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

; 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.gpio_command_params = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i32, i32, %union.anon, i16, i32, i8, i8, i8, [264 x i8], i32, i32, i32, i32, i32, i32, i32, i32, float }
%union.anon = type { [16 x i32] }
%struct.MIFARE_Key = type { [6 x i8] }
%struct.anon = type { [60 x i8], i8 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [1 x i8], align 1

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

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

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

declare i32 @MFRC522_Set_CS(i32 noundef) #1

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

declare void @MFRC522_PCD_Init(...) #1

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

declare ptr @MFRC522_Get_Uid(...) #1

declare i32 @MFRC522_PICC_Select(ptr noundef, i8 noundef zeroext) #1

declare void @MFRC522_PCD_AntennaOff(...) #1

declare i32 @MFRC522_PICC_HaltA(...) #1

declare ptr @MFRC522_GetStatusCodeName(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @dh_handle_devices_mfrc522_mifare_read_write(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.gpio_command_params, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca [2 x i8], align 1
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca %struct.MIFARE_Key, align 1
  %19 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 408, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call i32 @ets_strcmp(ptr noundef %20, ptr noundef @.str.2)
  %22 = icmp ne i32 0, %21
  %23 = zext i1 %22 to i32
  store i32 %23, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  %28 = zext i1 %27 to i64
  %29 = select i1 %27, i32 65536, i32 0
  %30 = or i32 76021760, %29
  %31 = call ptr @parse_params_pins_set(ptr noundef %24, i32 noundef %25, ptr noundef %9, i32 noundef 1, i32 noundef 0, i32 noundef %30, ptr noundef %10)
  store ptr %31, ptr %12, align 8, !tbaa !5
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %4
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  call void @dh_command_fail(ptr noundef %35, ptr noundef %36)
  store i32 1, ptr %13, align 4
  br label %174

37:                                               ; preds = %4
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = and i32 %38, 8388608
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %49

41:                                               ; preds = %37
  %42 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 26
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = call i32 @MFRC522_Set_CS(i32 noundef %43)
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %41
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dh_command_fail(ptr noundef %47, ptr noundef @.str)
  store i32 1, ptr %13, align 4
  br label %174

48:                                               ; preds = %41
  br label %49

49:                                               ; preds = %48, %37
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = and i32 %50, 524288
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dh_command_fail(ptr noundef %54, ptr noundef @.str.3)
  store i32 1, ptr %13, align 4
  br label %174

55:                                               ; preds = %49
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = and i32 %56, 67108864
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %66

59:                                               ; preds = %55
  %60 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 13
  %61 = getelementptr inbounds %struct.anon, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds [60 x i8], ptr %61, i64 0, i64 0
  %63 = call ptr @ets_memset(ptr noundef %62, i32 noundef 255, i32 noundef 6)
  %64 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 13
  %65 = getelementptr inbounds %struct.anon, ptr %64, i32 0, i32 1
  store i8 6, ptr %65, align 4, !tbaa !15
  br label %75

66:                                               ; preds = %55
  %67 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 13
  %68 = getelementptr inbounds %struct.anon, ptr %67, i32 0, i32 1
  %69 = load i8, ptr %68, align 4, !tbaa !15
  %70 = zext i8 %69 to i32
  %71 = icmp ne i32 %70, 6
  br i1 %71, label %72, label %74

72:                                               ; preds = %66
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dh_command_fail(ptr noundef %73, ptr noundef @.str.4)
  store i32 1, ptr %13, align 4
  br label %174

74:                                               ; preds = %66
  br label %75

75:                                               ; preds = %74, %59
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %92

78:                                               ; preds = %75
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = and i32 %79, 65536
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %84

82:                                               ; preds = %78
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dh_command_fail(ptr noundef %83, ptr noundef @.str.5)
  store i32 1, ptr %13, align 4
  br label %174

84:                                               ; preds = %78
  %85 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 20
  %86 = load i32, ptr %85, align 4, !tbaa !16
  %87 = icmp ne i32 %86, 16
  br i1 %87, label %88, label %90

88:                                               ; preds = %84
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dh_command_fail(ptr noundef %89, ptr noundef @.str.6)
  store i32 1, ptr %13, align 4
  br label %174

90:                                               ; preds = %84
  br label %91

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91, %75
  call void (...) @MFRC522_PCD_Init()
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  store i8 2, ptr %15, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %93 = getelementptr inbounds [2 x i8], ptr %14, i64 0, i64 0
  %94 = call i32 @MFRC522_PICC_RequestA(ptr noundef %93, ptr noundef %15)
  store i32 %94, ptr %16, align 4, !tbaa !9
  %95 = load i32, ptr %16, align 4, !tbaa !9
  %96 = icmp eq i32 %95, 0
  br i1 %96, label %100, label %97

97:                                               ; preds = %92
  %98 = load i32, ptr %16, align 4, !tbaa !9
  %99 = icmp eq i32 %98, 2
  br i1 %99, label %100, label %168

100:                                              ; preds = %97, %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %101 = call ptr (...) @MFRC522_Get_Uid()
  store ptr %101, ptr %17, align 8, !tbaa !5
  %102 = load ptr, ptr %17, align 8, !tbaa !5
  %103 = call i32 @MFRC522_PICC_Select(ptr noundef %102, i8 noundef zeroext 0)
  store i32 %103, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 6, ptr %18) #3
  %104 = getelementptr inbounds %struct.MIFARE_Key, ptr %18, i32 0, i32 0
  %105 = getelementptr inbounds [6 x i8], ptr %104, i64 0, i64 0
  %106 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 13
  %107 = getelementptr inbounds %struct.anon, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds [60 x i8], ptr %107, i64 0, i64 0
  %109 = call ptr @ets_memcpy(ptr noundef %105, ptr noundef %108, i32 noundef 6)
  %110 = load i32, ptr %16, align 4, !tbaa !9
  %111 = icmp eq i32 %110, 0
  br i1 %111, label %112, label %164

112:                                              ; preds = %100
  %113 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 22
  %114 = load i32, ptr %113, align 4, !tbaa !17
  %115 = trunc i32 %114 to i8
  %116 = load ptr, ptr %17, align 8, !tbaa !5
  %117 = call i32 @MFRC522_PCD_Authenticate(i8 noundef zeroext 96, i8 noundef zeroext %115, ptr noundef %18, ptr noundef %116)
  store i32 %117, ptr %16, align 4, !tbaa !9
  %118 = load i32, ptr %16, align 4, !tbaa !9
  %119 = icmp eq i32 %118, 0
  br i1 %119, label %120, label %163

120:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #3
  store i8 -1, ptr %19, align 1, !tbaa !15
  %121 = load i32, ptr %11, align 4, !tbaa !9
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %133

123:                                              ; preds = %120
  %124 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 22
  %125 = load i32, ptr %124, align 4, !tbaa !17
  %126 = trunc i32 %125 to i8
  %127 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 19
  %128 = getelementptr inbounds [264 x i8], ptr %127, i64 0, i64 0
  %129 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 20
  %130 = load i32, ptr %129, align 4, !tbaa !16
  %131 = trunc i32 %130 to i8
  %132 = call i32 @MFRC522_MIFARE_Write(i8 noundef zeroext %126, ptr noundef %128, i8 noundef zeroext %131)
  store i32 %132, ptr %16, align 4, !tbaa !9
  br label %140

133:                                              ; preds = %120
  %134 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 22
  %135 = load i32, ptr %134, align 4, !tbaa !17
  %136 = trunc i32 %135 to i8
  %137 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 19
  %138 = getelementptr inbounds [264 x i8], ptr %137, i64 0, i64 0
  %139 = call i32 @MFRC522_MIFARE_Read(i8 noundef zeroext %136, ptr noundef %138, ptr noundef %19)
  store i32 %139, ptr %16, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %133, %123
  %141 = load i32, ptr %16, align 4, !tbaa !9
  %142 = icmp eq i32 %141, 0
  br i1 %142, label %143, label %159

143:                                              ; preds = %140
  %144 = load i8, ptr %19, align 1, !tbaa !15
  %145 = zext i8 %144 to i32
  %146 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 12
  store i32 %145, ptr %146, align 4, !tbaa !18
  %147 = load i32, ptr %11, align 4, !tbaa !9
  %148 = icmp ne i32 %147, 0
  br i1 %148, label %149, label %151

149:                                              ; preds = %143
  %150 = load ptr, ptr %5, align 8, !tbaa !5
  call void @dh_command_done(ptr noundef %150, ptr noundef @.str.7)
  br label %157

151:                                              ; preds = %143
  %152 = load ptr, ptr %5, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 19
  %154 = getelementptr inbounds [264 x i8], ptr %153, i64 0, i64 0
  %155 = getelementptr inbounds %struct.gpio_command_params, ptr %9, i32 0, i32 12
  %156 = load i32, ptr %155, align 4, !tbaa !18
  call void @dh_command_done_buf(ptr noundef %152, ptr noundef %154, i32 noundef %156)
  br label %157

157:                                              ; preds = %151, %149
  %158 = call i32 (...) @MFRC522_PICC_HaltA()
  call void (...) @MFRC522_PCD_StopCrypto1()
  call void (...) @MFRC522_PCD_AntennaOff()
  store i32 1, ptr %13, align 4
  br label %160

159:                                              ; preds = %140
  store i32 0, ptr %13, align 4
  br label %160

160:                                              ; preds = %159, %157
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #3
  %161 = load i32, ptr %13, align 4
  switch i32 %161, label %165 [
    i32 0, label %162
  ]

162:                                              ; preds = %160
  br label %163

163:                                              ; preds = %162, %112
  br label %164

164:                                              ; preds = %163, %100
  store i32 0, ptr %13, align 4
  br label %165

165:                                              ; preds = %164, %160
  call void @llvm.lifetime.end.p0(i64 6, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  %166 = load i32, ptr %13, align 4
  switch i32 %166, label %173 [
    i32 0, label %167
  ]

167:                                              ; preds = %165
  br label %168

168:                                              ; preds = %167, %97
  %169 = call i32 (...) @MFRC522_PICC_HaltA()
  call void (...) @MFRC522_PCD_StopCrypto1()
  call void (...) @MFRC522_PCD_AntennaOff()
  %170 = load ptr, ptr %5, align 8, !tbaa !5
  %171 = load i32, ptr %16, align 4, !tbaa !9
  %172 = call ptr @MFRC522_GetStatusCodeName(i32 noundef %171)
  call void @dh_command_fail(ptr noundef %170, ptr noundef %172)
  store i32 0, ptr %13, align 4
  br label %173

173:                                              ; preds = %168, %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #3
  br label %174

174:                                              ; preds = %173, %88, %82, %72, %53, %46, %34
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 408, ptr %9) #3
  %175 = load i32, ptr %13, align 4
  switch i32 %175, label %177 [
    i32 0, label %176
    i32 1, label %176
  ]

176:                                              ; preds = %174, %174
  ret void

177:                                              ; preds = %174
  unreachable
}

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

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

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

declare i32 @MFRC522_PCD_Authenticate(i8 noundef zeroext, i8 noundef zeroext, ptr noundef, ptr noundef) #1

declare i32 @MFRC522_MIFARE_Write(i8 noundef zeroext, ptr noundef, i8 noundef zeroext) #1

declare i32 @MFRC522_MIFARE_Read(i8 noundef zeroext, ptr noundef, ptr noundef) #1

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

declare void @dh_command_done_buf(ptr noundef, ptr noundef, i32 noundef) #1

declare void @MFRC522_PCD_StopCrypto1(...) #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 396}
!12 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !13, i64 18, !13, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !13, i64 96, !10, i64 100, !7, i64 104, !7, i64 105, !7, i64 106, !7, i64 107, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !10, i64 388, !10, i64 392, !10, i64 396, !10, i64 400, !14, i64 404}
!13 = !{!"short", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!12, !10, i64 372}
!17 = !{!12, !10, i64 380}
!18 = !{!12, !10, i64 28}


; 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.gpio_command_params = type { i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i32, i32, %union.anon, i16, i32, i8, i8, i8, [264 x i8], i32, i32, i32, i32, i32, i32, i32, i32, float }
%union.anon = type { [16 x i32] }
%struct.MIFARE_Key = type { [6 x i8] }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [1 x i8], align 1

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

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

declare void @dh_command_fail(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @MFRC522_Set_CS(i32 noundef) local_unnamed_addr #1

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

declare void @MFRC522_PCD_Init(...) local_unnamed_addr #1

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

declare ptr @MFRC522_Get_Uid(...) local_unnamed_addr #1

declare i32 @MFRC522_PICC_Select(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @MFRC522_PCD_AntennaOff(...) local_unnamed_addr #1

declare i32 @MFRC522_PICC_HaltA(...) local_unnamed_addr #1

declare ptr @MFRC522_GetStatusCodeName(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @dh_handle_devices_mfrc522_mifare_read_write(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.gpio_command_params, align 4
  %6 = alloca i32, align 4
  %7 = alloca [2 x i8], align 1
  %8 = alloca i8, align 1
  %9 = alloca %struct.MIFARE_Key, align 1
  %10 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 408, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  %11 = tail call i32 @ets_strcmp(ptr noundef %1, ptr noundef nonnull @.str.2) #3
  %.not = icmp eq i32 %11, 0
  %12 = select i1 %.not, i32 76021760, i32 76087296
  %13 = call ptr @parse_params_pins_set(ptr noundef %2, i32 noundef %3, ptr noundef nonnull %5, i32 noundef 1, i32 noundef 0, i32 noundef %12, ptr noundef nonnull %6) #3
  %.not35 = icmp eq ptr %13, null
  br i1 %.not35, label %15, label %14

14:                                               ; preds = %4
  call void @dh_command_fail(ptr noundef %0, ptr noundef nonnull %13) #3
  br label %86

15:                                               ; preds = %4
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = and i32 %16, 8388608
  %.not36 = icmp eq i32 %17, 0
  br i1 %.not36, label %23, label %18

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %5, i64 396
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = call i32 @MFRC522_Set_CS(i32 noundef %20) #3
  %.not37 = icmp eq i32 %21, 0
  br i1 %.not37, label %._crit_edge, label %22

._crit_edge:                                      ; preds = %18
  %.pre = load i32, ptr %6, align 4, !tbaa !5
  br label %23

22:                                               ; preds = %18
  call void @dh_command_fail(ptr noundef %0, ptr noundef nonnull @.str) #3
  br label %86

23:                                               ; preds = %._crit_edge, %15
  %24 = phi i32 [ %.pre, %._crit_edge ], [ %16, %15 ]
  %25 = and i32 %24, 524288
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %23
  call void @dh_command_fail(ptr noundef %0, ptr noundef nonnull @.str.3) #3
  br label %86

28:                                               ; preds = %23
  %29 = and i32 %24, 67108864
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = getelementptr inbounds i8, ptr %5, i64 32
  %33 = call ptr @ets_memset(ptr noundef nonnull %32, i32 noundef 255, i32 noundef 6) #3
  %34 = getelementptr inbounds i8, ptr %5, i64 92
  store i8 6, ptr %34, align 4, !tbaa !13
  br label %39

35:                                               ; preds = %28
  %36 = getelementptr inbounds i8, ptr %5, i64 92
  %37 = load i8, ptr %36, align 4, !tbaa !13
  %.not38 = icmp eq i8 %37, 6
  br i1 %.not38, label %39, label %38

38:                                               ; preds = %35
  call void @dh_command_fail(ptr noundef %0, ptr noundef nonnull @.str.4) #3
  br label %86

39:                                               ; preds = %35, %31
  br i1 %.not, label %49, label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = and i32 %41, 65536
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  call void @dh_command_fail(ptr noundef %0, ptr noundef nonnull @.str.5) #3
  br label %86

45:                                               ; preds = %40
  %46 = getelementptr inbounds i8, ptr %5, i64 372
  %47 = load i32, ptr %46, align 4, !tbaa !14
  %.not39 = icmp eq i32 %47, 16
  br i1 %.not39, label %49, label %48

48:                                               ; preds = %45
  call void @dh_command_fail(ptr noundef %0, ptr noundef nonnull @.str.6) #3
  br label %86

49:                                               ; preds = %45, %39
  call void (...) @MFRC522_PCD_Init() #3
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #3
  store i8 2, ptr %8, align 1, !tbaa !13
  %50 = call i32 @MFRC522_PICC_RequestA(ptr noundef nonnull %7, ptr noundef nonnull %8) #3
  %51 = and i32 %50, -3
  %or.cond = icmp eq i32 %51, 0
  br i1 %or.cond, label %52, label %82

52:                                               ; preds = %49
  %53 = call ptr (...) @MFRC522_Get_Uid() #3
  %54 = call i32 @MFRC522_PICC_Select(ptr noundef %53, i8 noundef zeroext 0) #3
  call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %9) #3
  %55 = getelementptr inbounds i8, ptr %5, i64 32
  %56 = call ptr @ets_memcpy(ptr noundef nonnull %9, ptr noundef nonnull %55, i32 noundef 6) #3
  %57 = icmp eq i32 %54, 0
  br i1 %57, label %58, label %.thread49

58:                                               ; preds = %52
  %59 = getelementptr inbounds i8, ptr %5, i64 380
  %60 = load i32, ptr %59, align 4, !tbaa !15
  %61 = trunc i32 %60 to i8
  %62 = call i32 @MFRC522_PCD_Authenticate(i8 noundef zeroext 96, i8 noundef zeroext %61, ptr noundef nonnull %9, ptr noundef %53) #3
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %.thread49

64:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #3
  store i8 -1, ptr %10, align 1, !tbaa !13
  %65 = load i32, ptr %59, align 4, !tbaa !15
  %66 = trunc i32 %65 to i8
  %67 = getelementptr inbounds i8, ptr %5, i64 107
  br i1 %.not, label %68, label %.thread

68:                                               ; preds = %64
  %69 = call i32 @MFRC522_MIFARE_Read(i8 noundef zeroext %66, ptr noundef nonnull %67, ptr noundef nonnull %10) #3
  %.not40 = icmp eq i32 %69, 0
  br i1 %.not40, label %76, label %.critedge

.thread:                                          ; preds = %64
  %70 = getelementptr inbounds i8, ptr %5, i64 372
  %71 = load i32, ptr %70, align 4, !tbaa !14
  %72 = trunc i32 %71 to i8
  %73 = call i32 @MFRC522_MIFARE_Write(i8 noundef zeroext %66, ptr noundef nonnull %67, i8 noundef zeroext %72) #3
  %.not4042 = icmp eq i32 %73, 0
  br i1 %.not4042, label %74, label %.critedge

74:                                               ; preds = %.thread
  %75 = getelementptr inbounds i8, ptr %5, i64 28
  store i32 255, ptr %75, align 4, !tbaa !16
  call void @dh_command_done(ptr noundef %0, ptr noundef nonnull @.str.7) #3
  br label %80

76:                                               ; preds = %68
  %77 = load i8, ptr %10, align 1, !tbaa !13
  %78 = zext i8 %77 to i32
  %79 = getelementptr inbounds i8, ptr %5, i64 28
  store i32 %78, ptr %79, align 4, !tbaa !16
  call void @dh_command_done_buf(ptr noundef %0, ptr noundef nonnull %67, i32 noundef %78) #3
  br label %80

.critedge:                                        ; preds = %.thread, %68
  %.02943 = phi i32 [ %73, %.thread ], [ %69, %68 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #3
  br label %.thread49

.thread49:                                        ; preds = %.critedge, %58, %52
  %.2.ph = phi i32 [ %.02943, %.critedge ], [ %54, %52 ], [ %62, %58 ]
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %9) #3
  br label %82

80:                                               ; preds = %74, %76
  %81 = call i32 (...) @MFRC522_PICC_HaltA() #3
  call void (...) @MFRC522_PCD_StopCrypto1() #3
  call void (...) @MFRC522_PCD_AntennaOff() #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %9) #3
  br label %85

82:                                               ; preds = %.thread49, %49
  %.3 = phi i32 [ %50, %49 ], [ %.2.ph, %.thread49 ]
  %83 = call i32 (...) @MFRC522_PICC_HaltA() #3
  call void (...) @MFRC522_PCD_StopCrypto1() #3
  call void (...) @MFRC522_PCD_AntennaOff() #3
  %84 = call ptr @MFRC522_GetStatusCodeName(i32 noundef %.3) #3
  call void @dh_command_fail(ptr noundef %0, ptr noundef %84) #3
  br label %85

85:                                               ; preds = %80, %82
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %7) #3
  br label %86

86:                                               ; preds = %85, %48, %44, %38, %27, %22, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 408, ptr nonnull %5) #3
  ret void
}

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

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

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

declare i32 @MFRC522_PCD_Authenticate(i8 noundef zeroext, i8 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @MFRC522_MIFARE_Write(i8 noundef zeroext, ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare i32 @MFRC522_MIFARE_Read(i8 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @dh_command_done(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @dh_command_done_buf(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @MFRC522_PCD_StopCrypto1(...) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 396}
!10 = !{!"", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8, !11, i64 10, !11, i64 12, !11, i64 14, !11, i64 16, !11, i64 18, !11, i64 20, !6, i64 24, !6, i64 28, !7, i64 32, !11, i64 96, !6, i64 100, !7, i64 104, !7, i64 105, !7, i64 106, !7, i64 107, !6, i64 372, !6, i64 376, !6, i64 380, !6, i64 384, !6, i64 388, !6, i64 392, !6, i64 396, !6, i64 400, !12, i64 404}
!11 = !{!"short", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !6, i64 372}
!15 = !{!10, !6, i64 380}
!16 = !{!10, !6, i64 28}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass