; LLVM IR from beagleboard/librobotcontrol :: examples/src (rc_test_dmp_tap)

; 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.rc_mpu_data_t = type { [3 x double], [3 x double], [3 x double], double, [3 x i16], [3 x i16], double, double, [4 x double], [3 x double], i32, i32, i32, [4 x double], [3 x double], double, double }
%struct.rc_mpu_config_t = type { i32, i32, i32, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32 }

@running = external hidden global i32, align 4
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.rc_mpu_data_t, align 8
  %3 = alloca %struct.rc_mpu_config_t, align 8
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr %2) #4
  %5 = call ptr @signal(i32 noundef 2, ptr noundef @__signal_handler) #4
  store i32 1, ptr @running, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 88, ptr %3) #4
  call void @rc_mpu_default_config(ptr dead_on_unwind writable sret(%struct.rc_mpu_config_t) align 8 %3)
  %6 = getelementptr inbounds %struct.rc_mpu_config_t, ptr %3, i32 0, i32 2
  store i32 2, ptr %6, align 8, !tbaa !9
  %7 = call i32 @rc_mpu_initialize_dmp(ptr noundef %2, ptr noundef byval(%struct.rc_mpu_config_t) align 8 %3)
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %12

9:                                                ; preds = %0
  %10 = load ptr, ptr @stderr, align 8, !tbaa !12
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str) #4
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %20

12:                                               ; preds = %0
  %13 = call i32 @rc_mpu_set_tap_callback(ptr noundef @__tap_callback_func)
  br label %14

14:                                               ; preds = %17, %12
  %15 = load i32, ptr @running, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  call void @rc_usleep(i32 noundef 100000)
  br label %14, !llvm.loop !14

18:                                               ; preds = %14
  %19 = call i32 @rc_mpu_power_off()
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %20

20:                                               ; preds = %18, %9
  call void @llvm.lifetime.end.p0(i64 88, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %2) #4
  %21 = load i32, ptr %1, align 4
  ret i32 %21
}

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

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @__signal_handler(i32 noundef) #0

declare void @rc_mpu_default_config(ptr dead_on_unwind writable sret(%struct.rc_mpu_config_t) align 8) #3

declare i32 @rc_mpu_initialize_dmp(ptr noundef, ptr noundef byval(%struct.rc_mpu_config_t) align 8) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare i32 @rc_mpu_set_tap_callback(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @__tap_callback_func(i32 noundef, i32 noundef) #0

declare void @rc_usleep(i32 noundef) #3

declare i32 @rc_mpu_power_off() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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" }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"rc_mpu_config_t", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !11, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80}
!11 = !{!"double", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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.rc_mpu_data_t = type { [3 x double], [3 x double], [3 x double], double, [3 x i16], [3 x i16], double, double, [4 x double], [3 x double], i32, i32, i32, [4 x double], [3 x double], double, double }
%struct.rc_mpu_config_t = type { i32, i32, i32, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32 }

@running = external hidden local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.rc_mpu_data_t, align 8
  %2 = alloca %struct.rc_mpu_config_t, align 8
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %1) #5
  %3 = tail call ptr @signal(i32 noundef 2, ptr noundef nonnull @__signal_handler) #5
  store i32 1, ptr @running, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %2) #5
  call void @rc_mpu_default_config(ptr dead_on_unwind nonnull writable sret(%struct.rc_mpu_config_t) align 8 %2) #5
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 2, ptr %4, align 8, !tbaa !9
  %5 = call i32 @rc_mpu_initialize_dmp(ptr noundef nonnull %1, ptr noundef nonnull byval(%struct.rc_mpu_config_t) align 8 %2) #5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %9, label %6

6:                                                ; preds = %0
  %7 = load ptr, ptr @stderr, align 8, !tbaa !12
  %8 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str) #6
  br label %14

9:                                                ; preds = %0
  %10 = call i32 @rc_mpu_set_tap_callback(ptr noundef nonnull @__tap_callback_func) #5
  %11 = load i32, ptr @running, align 4, !tbaa !5
  %.not12 = icmp eq i32 %11, 0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  call void @rc_usleep(i32 noundef 100000) #5
  %12 = load i32, ptr @running, align 4, !tbaa !5
  %.not1 = icmp eq i32 %12, 0
  br i1 %.not1, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %9
  %13 = call i32 @rc_mpu_power_off() #5
  br label %14

14:                                               ; preds = %._crit_edge, %6
  %.0 = phi i32 [ -1, %6 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %1) #5
  ret i32 %.0
}

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

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @__signal_handler(i32 noundef) #0

declare void @rc_mpu_default_config(ptr dead_on_unwind writable sret(%struct.rc_mpu_config_t) align 8) local_unnamed_addr #3

declare i32 @rc_mpu_initialize_dmp(ptr noundef, ptr noundef byval(%struct.rc_mpu_config_t) align 8) local_unnamed_addr #3

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

declare i32 @rc_mpu_set_tap_callback(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @__tap_callback_func(i32 noundef, i32 noundef) #0

declare void @rc_usleep(i32 noundef) local_unnamed_addr #3

declare i32 @rc_mpu_power_off() local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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" }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { cold 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 8}
!10 = !{!"rc_mpu_config_t", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !11, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80}
!11 = !{!"double", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass