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

; 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_bmp_data_t = type { double, double, double }
%struct.rc_filter_t = type { i32, double, double, %struct.rc_vector_t, %struct.rc_vector_t, i32, double, double, i32, i32, double, %struct.rc_ringbuf_t, %struct.rc_ringbuf_t, double, double, i64, i32 }
%struct.rc_vector_t = type { i32, ptr, i32 }
%struct.rc_ringbuf_t = type { ptr, i32, i32, i32 }

@running = external hidden global i32, align 4
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@stdout = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.rc_bmp_data_t, align 8
  %3 = alloca double, align 8
  %4 = alloca %struct.rc_filter_t, align 8
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 192, ptr %4) #5
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 192, i1 false)
  %6 = getelementptr inbounds %struct.rc_filter_t, ptr %4, i32 0, i32 2
  store double 1.000000e+00, ptr %6, align 8
  %7 = call ptr @signal(i32 noundef 2, ptr noundef @signal_handler) #5
  store i32 1, ptr @running, align 4, !tbaa !5
  %8 = call i32 @rc_filter_butterworth_lowpass(ptr noundef %4, i32 noundef 2, double noundef 0x3FA47AE140000000, double noundef 2.000000e+00)
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %0
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %61

11:                                               ; preds = %0
  %12 = call i32 @rc_bmp_init(i32 noundef 20, i32 noundef 0)
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %61

15:                                               ; preds = %11
  %16 = call i32 @rc_bmp_read(ptr noundef %2)
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %61

19:                                               ; preds = %15
  %20 = getelementptr inbounds %struct.rc_bmp_data_t, ptr %2, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = call i32 @rc_filter_prefill_inputs(ptr noundef %4, double noundef %21)
  %23 = getelementptr inbounds %struct.rc_bmp_data_t, ptr %2, i32 0, i32 1
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = call i32 @rc_filter_prefill_outputs(ptr noundef %4, double noundef %24)
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %32

32:                                               ; preds = %39, %38, %19
  %33 = load i32, ptr @running, align 4, !tbaa !5
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %58

35:                                               ; preds = %32
  call void @rc_usleep(i32 noundef 40000)
  %36 = call i32 @rc_bmp_read(ptr noundef %2)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %32, !llvm.loop !12

39:                                               ; preds = %35
  %40 = getelementptr inbounds %struct.rc_bmp_data_t, ptr %2, i32 0, i32 1
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = call double @rc_filter_march(ptr noundef %4, double noundef %41)
  store double %42, ptr %3, align 8, !tbaa !14
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %44 = getelementptr inbounds %struct.rc_bmp_data_t, ptr %2, i32 0, i32 0
  %45 = load double, ptr %44, align 8, !tbaa !15
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, double noundef %45)
  %47 = getelementptr inbounds %struct.rc_bmp_data_t, ptr %2, i32 0, i32 2
  %48 = load double, ptr %47, align 8, !tbaa !16
  %49 = fdiv double %48, 1.000000e+03
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %49)
  %51 = getelementptr inbounds %struct.rc_bmp_data_t, ptr %2, i32 0, i32 1
  %52 = load double, ptr %51, align 8, !tbaa !9
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, double noundef %52)
  %54 = load double, ptr %3, align 8, !tbaa !14
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, double noundef %54)
  %56 = load ptr, ptr @stdout, align 8, !tbaa !17
  %57 = call i32 @fflush(ptr noundef %56)
  br label %32, !llvm.loop !12

58:                                               ; preds = %32
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %60 = call i32 @rc_bmp_power_off()
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %61

61:                                               ; preds = %58, %18, %14, %10
  call void @llvm.lifetime.end.p0(i64 192, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %2) #5
  %62 = load i32, ptr %1, align 4
  ret i32 %62
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

declare i32 @rc_filter_butterworth_lowpass(ptr noundef, i32 noundef, double noundef, double noundef) #4

declare i32 @rc_bmp_init(i32 noundef, i32 noundef) #4

declare i32 @rc_bmp_read(ptr noundef) #4

declare i32 @rc_filter_prefill_inputs(ptr noundef, double noundef) #4

declare i32 @rc_filter_prefill_outputs(ptr noundef, double noundef) #4

declare i32 @printf(ptr noundef, ...) #4

declare void @rc_usleep(i32 noundef) #4

declare double @rc_filter_march(ptr noundef, double noundef) #4

declare i32 @fflush(ptr noundef) #4

declare i32 @rc_bmp_power_off() #4

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 }

!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, !11, i64 8}
!10 = !{!"rc_bmp_data_t", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"double", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !11, i64 16}
!17 = !{!18, !18, i64 0}
!18 = !{!"any pointer", !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"

%struct.rc_bmp_data_t = type { double, double, double }
%struct.rc_filter_t = type { i32, double, double, %struct.rc_vector_t, %struct.rc_vector_t, i32, double, double, i32, i32, double, %struct.rc_ringbuf_t, %struct.rc_ringbuf_t, double, double, i64, i32 }
%struct.rc_vector_t = type { i32, ptr, i32 }
%struct.rc_ringbuf_t = type { ptr, i32, i32, i32 }

@running = external hidden local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.rc_bmp_data_t, align 8
  %2 = alloca %struct.rc_filter_t, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %2) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(192) %2, i8 0, i64 192, i1 false)
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  store double 1.000000e+00, ptr %3, align 8
  %4 = tail call ptr @signal(i32 noundef 2, ptr noundef nonnull @signal_handler) #6
  store i32 1, ptr @running, align 4, !tbaa !5
  %5 = call i32 @rc_filter_butterworth_lowpass(ptr noundef nonnull %2, i32 noundef 2, double noundef 0x3FA47AE140000000, double noundef 2.000000e+00) #6
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %43

6:                                                ; preds = %0
  %7 = call i32 @rc_bmp_init(i32 noundef 20, i32 noundef 0) #6
  %.not1 = icmp eq i32 %7, 0
  br i1 %.not1, label %8, label %43

8:                                                ; preds = %6
  %9 = call i32 @rc_bmp_read(ptr noundef nonnull %1) #6
  %.not2 = icmp eq i32 %9, 0
  br i1 %.not2, label %10, label %43

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = call i32 @rc_filter_prefill_inputs(ptr noundef nonnull %2, double noundef %12) #6
  %14 = load double, ptr %11, align 8, !tbaa !9
  %15 = call i32 @rc_filter_prefill_outputs(ptr noundef nonnull %2, double noundef %14) #6
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %22 = load i32, ptr @running, align 4, !tbaa !5
  %.not35 = icmp eq i32 %22, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %23 = getelementptr inbounds i8, ptr %1, i64 16
  br label %24

24:                                               ; preds = %.lr.ph, %.backedge
  call void @rc_usleep(i32 noundef 40000) #6
  %25 = call i32 @rc_bmp_read(ptr noundef nonnull %1) #6
  %.not4 = icmp eq i32 %25, 0
  br i1 %.not4, label %26, label %.backedge

26:                                               ; preds = %24
  %27 = load double, ptr %11, align 8, !tbaa !9
  %28 = call double @rc_filter_march(ptr noundef nonnull %2, double noundef %27) #6
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %30 = load double, ptr %1, align 8, !tbaa !12
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, double noundef %30)
  %32 = load double, ptr %23, align 8, !tbaa !13
  %33 = fdiv double %32, 1.000000e+03
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %33)
  %35 = load double, ptr %11, align 8, !tbaa !9
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, double noundef %35)
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, double noundef %28)
  %38 = load ptr, ptr @stdout, align 8, !tbaa !14
  %39 = call i32 @fflush(ptr noundef %38)
  br label %.backedge

.backedge:                                        ; preds = %26, %24
  %40 = load i32, ptr @running, align 4, !tbaa !5
  %.not3 = icmp eq i32 %40, 0
  br i1 %.not3, label %._crit_edge, label %24, !llvm.loop !16

._crit_edge:                                      ; preds = %.backedge, %10
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %42 = call i32 @rc_bmp_power_off() #6
  br label %43

43:                                               ; preds = %8, %6, %0, %._crit_edge
  %.0 = phi i32 [ 0, %._crit_edge ], [ -1, %0 ], [ -1, %6 ], [ -1, %8 ]
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #6
  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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

declare i32 @rc_filter_butterworth_lowpass(ptr noundef, i32 noundef, double noundef, double noundef) local_unnamed_addr #4

declare i32 @rc_bmp_init(i32 noundef, i32 noundef) local_unnamed_addr #4

declare i32 @rc_bmp_read(ptr noundef) local_unnamed_addr #4

declare i32 @rc_filter_prefill_inputs(ptr noundef, double noundef) local_unnamed_addr #4

declare i32 @rc_filter_prefill_outputs(ptr noundef, double noundef) local_unnamed_addr #4

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

declare void @rc_usleep(i32 noundef) local_unnamed_addr #4

declare double @rc_filter_march(ptr noundef, double noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #5

declare i32 @rc_bmp_power_off() local_unnamed_addr #4

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 = { 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 #6 = { 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, !11, i64 8}
!10 = !{!"rc_bmp_data_t", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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