; LLVM IR from MRPT/mrpt :: 3rdparty/xspublic/xstypes (xsdeviceid)

; 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.XsDeviceId = type { i64, [24 x i8], i16, i32 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @XsDeviceId_isLegacyDeviceId(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @XsDeviceId_isAhrs(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call i32 @XsDeviceId_isLegacyDeviceId(ptr noundef %6)
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %30

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.XsDeviceId, ptr %10, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = and i64 %12, 267386880
  %14 = icmp eq i64 %13, 58720256
  br i1 %14, label %27, label %15

15:                                               ; preds = %9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.XsDeviceId, ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = and i64 %18, 267386880
  %20 = icmp eq i64 %19, 56623104
  br i1 %20, label %27, label %21

21:                                               ; preds = %15
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.XsDeviceId, ptr %22, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = and i64 %24, 267386880
  %26 = icmp eq i64 %25, 57671680
  br label %27

27:                                               ; preds = %21, %15, %9
  %28 = phi i1 [ true, %15 ], [ true, %9 ], [ %26, %21 ]
  %29 = zext i1 %28 to i32
  store i32 %29, ptr %2, align 4
  br label %62

30:                                               ; preds = %1
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.XsDeviceId, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds [24 x i8], ptr %32, i64 0, i64 0
  %34 = call i32 @memcmp(ptr noundef %33, ptr noundef @.str, i64 noundef 4) #3
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store i32 0, ptr %2, align 4
  br label %62

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.XsDeviceId, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds [24 x i8], ptr %39, i64 0, i64 4
  %41 = load i8, ptr %40, align 4, !tbaa !14
  %42 = sext i8 %41 to i32
  %43 = sub nsw i32 %42, 48
  store i32 %43, ptr %4, align 4, !tbaa !15
  %44 = load i32, ptr %4, align 4, !tbaa !15
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %37
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %61

47:                                               ; preds = %37
  %48 = load i32, ptr %4, align 4, !tbaa !15
  %49 = icmp eq i32 %48, 6
  br i1 %49, label %50, label %57

50:                                               ; preds = %47
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.XsDeviceId, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds [24 x i8], ptr %52, i64 0, i64 5
  %54 = load i8, ptr %53, align 1, !tbaa !14
  %55 = sext i8 %54 to i32
  %56 = sub nsw i32 %55, 48
  store i32 %56, ptr %4, align 4, !tbaa !15
  br label %57

57:                                               ; preds = %50, %47
  %58 = load i32, ptr %4, align 4, !tbaa !15
  %59 = icmp eq i32 %58, 3
  %60 = zext i1 %59 to i32
  store i32 %60, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %61

61:                                               ; preds = %57, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %62

62:                                               ; preds = %61, %36, %27
  %63 = load i32, ptr %2, align 4
  ret i32 %63
}

attributes #0 = { 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 #1 = { nounwind willreturn memory(read) "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 willreturn memory(read) }
attributes #4 = { 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, !11, i64 0}
!10 = !{!"XsDeviceId", !11, i64 0, !7, i64 8, !12, i64 32, !13, i64 36}
!11 = !{!"long", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!13, !13, 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 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @XsDeviceId_isLegacyDeviceId(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @XsDeviceId_isAhrs(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @XsDeviceId_isLegacyDeviceId(ptr noundef %0)
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %7, label %3

3:                                                ; preds = %1
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = and i64 %4, 267386880
  switch i64 %5, label %6 [
    i64 58720256, label %switch.edge
    i64 56623104, label %switch.edge
    i64 57671680, label %switch.edge
  ]

6:                                                ; preds = %3
  br label %switch.edge

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %8, ptr noundef nonnull dereferenceable(4) @.str, i64 4)
  %.not13 = icmp eq i32 %bcmp, 0
  br i1 %.not13, label %9, label %switch.edge

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i8, ptr %10, align 4, !tbaa !12
  switch i8 %11, label %15 [
    i8 48, label %switch.edge
    i8 54, label %12
  ]

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 13
  %14 = load i8, ptr %13, align 1, !tbaa !12
  br label %15

15:                                               ; preds = %9, %12
  %.0.in.in = phi i8 [ %14, %12 ], [ %11, %9 ]
  %16 = icmp eq i8 %.0.in.in, 51
  %17 = zext i1 %16 to i32
  br label %switch.edge

switch.edge:                                      ; preds = %3, %3, %3, %15, %9, %7, %6
  %.1.shrunk = phi i32 [ 1, %3 ], [ 0, %6 ], [ 1, %3 ], [ 0, %7 ], [ %17, %15 ], [ 0, %9 ], [ 1, %3 ]
  ret i32 %.1.shrunk
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #1

attributes #0 = { 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 #1 = { nofree nounwind willreturn memory(argmem: read) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"XsDeviceId", !7, i64 0, !8, i64 8, !10, i64 32, !11, i64 36}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!8, !8, i64 0}


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