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

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

@.str.40 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [10 x i8], align 1
@dhesperrors_wifi_state.str = external hidden constant [6 x i8], align 4
@dhesperrors_wifi_state.str.47 = external hidden constant [6 x i8], align 4

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @dhesperrors_wifi_state(ptr noundef %0, i8 noundef zeroext %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  %6 = load i8, ptr %4, align 1, !tbaa !9
  %7 = zext i8 %6 to i32
  switch i32 %7, label %15 [
    i32 0, label %8
    i32 1, label %9
    i32 2, label %10
    i32 3, label %11
    i32 5, label %12
    i32 6, label %13
    i32 10, label %14
  ]

8:                                                ; preds = %2
  store ptr @.str.40, ptr %5, align 8, !tbaa !5
  br label %15

9:                                                ; preds = %2
  store ptr @.str.41, ptr %5, align 8, !tbaa !5
  br label %15

10:                                               ; preds = %2
  store ptr @.str.42, ptr %5, align 8, !tbaa !5
  br label %15

11:                                               ; preds = %2
  store ptr @.str.43, ptr %5, align 8, !tbaa !5
  br label %15

12:                                               ; preds = %2
  store ptr @.str.44, ptr %5, align 8, !tbaa !5
  br label %15

13:                                               ; preds = %2
  store ptr @.str.45, ptr %5, align 8, !tbaa !5
  br label %15

14:                                               ; preds = %2
  store ptr @.str.46, ptr %5, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %14, %13, %12, %11, %10, %9, %8, %2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhesperrors_wifi_state.str, ptr noundef %20, ptr noundef %21)
  br label %22

22:                                               ; preds = %19
  br label %23

23:                                               ; preds = %22
  br label %31

24:                                               ; preds = %15
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i8, ptr %4, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  call void (ptr, ...) @dhdebug_ram(ptr noundef @dhesperrors_wifi_state.str.47, ptr noundef %26, i32 noundef %28)
  br label %29

29:                                               ; preds = %25
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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 = !{!7, !7, i64 0}


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

@.str.40 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [10 x i8], align 1
@dhesperrors_wifi_state.str = external hidden constant [6 x i8], align 4
@dhesperrors_wifi_state.str.47 = external hidden constant [6 x i8], align 4
@switch.table.dhesperrors_wifi_state = private unnamed_addr constant [11 x ptr] [ptr @.str.40, ptr @.str.41, ptr @.str.42, ptr @.str.43, ptr @.str.40, ptr @.str.44, ptr @.str.45, ptr @.str.40, ptr @.str.40, ptr @.str.40, ptr @.str.46], align 8

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

; Function Attrs: nounwind uwtable
define dso_local void @dhesperrors_wifi_state(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #1 {
  %3 = icmp ult i8 %1, 11
  br i1 %3, label %switch.hole_check, label %5

switch.hole_check:                                ; preds = %2
  %switch.maskindex = zext nneg i8 %1 to i16
  %switch.shifted = lshr i16 1135, %switch.maskindex
  %switch.lobit = trunc i16 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %5

switch.lookup:                                    ; preds = %switch.hole_check
  %4 = zext nneg i8 %1 to i64
  %switch.gep = getelementptr inbounds [11 x ptr], ptr @switch.table.dhesperrors_wifi_state, i64 0, i64 %4
  %switch.load = load ptr, ptr %switch.gep, align 8
  tail call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhesperrors_wifi_state.str, ptr noundef %0, ptr noundef nonnull %switch.load) #2
  br label %7

5:                                                ; preds = %switch.hole_check, %2
  %6 = zext i8 %1 to i32
  tail call void (ptr, ...) @dhdebug_ram(ptr noundef nonnull @dhesperrors_wifi_state.str.47, ptr noundef %0, i32 noundef %6) #2
  br label %7

7:                                                ; preds = %5, %switch.lookup
  ret void
}

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


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