; LLVM IR from IOsonata/IOsonata :: src/sensors/mag_ak09916.ll (ZN10MagAk0991617SamplingFrequencyEj)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10MagAk0991617SamplingFrequencyEj(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 49, ptr %5, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  store i8 0, ptr %6, align 1, !tbaa !11
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds ptr, ptr %8, i64 26
  %10 = load ptr, ptr %9, align 8
  %11 = call noundef i32 %10(ptr noundef nonnull align 8 dereferenceable(160) %7, i32 noundef 12, ptr noundef %5, i32 noundef 1, ptr noundef %6, i32 noundef 1)
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp ult i32 %12, 20000
  br i1 %13, label %14, label %19

14:                                               ; preds = %2
  %15 = load i8, ptr %6, align 1, !tbaa !11
  %16 = zext i8 %15 to i32
  %17 = or i32 %16, 2
  %18 = trunc i32 %17 to i8
  store i8 %18, ptr %6, align 1, !tbaa !11
  store i32 10000, ptr %4, align 4, !tbaa !9
  br label %42

19:                                               ; preds = %2
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = icmp ult i32 %20, 50000
  br i1 %21, label %22, label %27

22:                                               ; preds = %19
  %23 = load i8, ptr %6, align 1, !tbaa !11
  %24 = zext i8 %23 to i32
  %25 = or i32 %24, 4
  %26 = trunc i32 %25 to i8
  store i8 %26, ptr %6, align 1, !tbaa !11
  store i32 20000, ptr %4, align 4, !tbaa !9
  br label %41

27:                                               ; preds = %19
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = icmp ult i32 %28, 100000
  br i1 %29, label %30, label %35

30:                                               ; preds = %27
  %31 = load i8, ptr %6, align 1, !tbaa !11
  %32 = zext i8 %31 to i32
  %33 = or i32 %32, 6
  %34 = trunc i32 %33 to i8
  store i8 %34, ptr %6, align 1, !tbaa !11
  store i32 50000, ptr %4, align 4, !tbaa !9
  br label %40

35:                                               ; preds = %27
  %36 = load i8, ptr %6, align 1, !tbaa !11
  %37 = zext i8 %36 to i32
  %38 = or i32 %37, 8
  %39 = trunc i32 %38 to i8
  store i8 %39, ptr %6, align 1, !tbaa !11
  store i32 100000, ptr %4, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %35, %30
  br label %41

41:                                               ; preds = %40, %22
  br label %42

42:                                               ; preds = %41, %14
  store i8 4, ptr %6, align 1, !tbaa !11
  %43 = load ptr, ptr %7, align 8, !tbaa !12
  %44 = getelementptr inbounds ptr, ptr %43, i64 26
  %45 = load ptr, ptr %44, align 8
  %46 = call noundef i32 %45(ptr noundef nonnull align 8 dereferenceable(160) %7, i32 noundef 12, ptr noundef %5, i32 noundef 1, ptr noundef %6, i32 noundef 1)
  store i8 0, ptr %6, align 1, !tbaa !11
  %47 = load ptr, ptr %7, align 8, !tbaa !12
  %48 = getelementptr inbounds ptr, ptr %47, i64 25
  %49 = load ptr, ptr %48, align 8
  %50 = call noundef i32 %49(ptr noundef nonnull align 8 dereferenceable(160) %7, i32 noundef 12, ptr noundef %5, i32 noundef 1, ptr noundef %6, i32 noundef 1)
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = call noundef i32 @_ZN6Sensor17SamplingFrequencyEj(ptr noundef nonnull align 8 dereferenceable(73) %7, i32 noundef %51)
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret i32 %52
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6Sensor17SamplingFrequencyEj(ptr noundef nonnull align 8 dereferenceable(73), i32 noundef) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !8, 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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10MagAk0991617SamplingFrequencyEj(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #3
  store i8 49, ptr %3, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #3
  store i8 0, ptr %4, align 1, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %5, i64 208
  %7 = load ptr, ptr %6, align 8
  %8 = call noundef i32 %7(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef 12, ptr noundef nonnull %3, i32 noundef 1, ptr noundef nonnull %4, i32 noundef 1)
  %9 = icmp ult i32 %1, 20000
  br i1 %9, label %14, label %10

10:                                               ; preds = %2
  %11 = icmp ult i32 %1, 50000
  br i1 %11, label %14, label %12

12:                                               ; preds = %10
  %13 = icmp ult i32 %1, 100000
  %. = select i1 %13, i32 50000, i32 100000
  br label %14

14:                                               ; preds = %12, %10, %2
  %.0 = phi i32 [ 10000, %2 ], [ 20000, %10 ], [ %., %12 ]
  store i8 4, ptr %4, align 1, !tbaa !5
  %15 = load ptr, ptr %0, align 8, !tbaa !8
  %16 = getelementptr inbounds i8, ptr %15, i64 208
  %17 = load ptr, ptr %16, align 8
  %18 = call noundef i32 %17(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef 12, ptr noundef nonnull %3, i32 noundef 1, ptr noundef nonnull %4, i32 noundef 1)
  store i8 0, ptr %4, align 1, !tbaa !5
  %19 = load ptr, ptr %0, align 8, !tbaa !8
  %20 = getelementptr inbounds i8, ptr %19, i64 200
  %21 = load ptr, ptr %20, align 8
  %22 = call noundef i32 %21(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef 12, ptr noundef nonnull %3, i32 noundef 1, ptr noundef nonnull %4, i32 noundef 1)
  %23 = call noundef i32 @_ZN6Sensor17SamplingFrequencyEj(ptr noundef nonnull align 8 dereferenceable(73) %0, i32 noundef %.0)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #3
  ret i32 %23
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6Sensor17SamplingFrequencyEj(ptr noundef nonnull align 8 dereferenceable(73), i32 noundef) unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"vtable pointer", !7, i64 0}


; Effective O3 passes: DSEPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass