; LLVM IR from introlab/odas :: src/signal (area)

; 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.areas_obj = type { i32, i32, i32, ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; 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: nounwind uwtable
define dso_local void @areas_printf(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.areas_obj, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %8)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.areas_obj, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %12)
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.areas_obj, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %16)
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %18

18:                                               ; preds = %76, %1
  %19 = load i32, ptr %3, align 4, !tbaa !14
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.areas_obj, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp ult i32 %19, %22
  br i1 %23, label %24, label %79

24:                                               ; preds = %18
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %25

25:                                               ; preds = %72, %24
  %26 = load i32, ptr %4, align 4, !tbaa !14
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.areas_obj, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %30 = icmp ult i32 %26, %29
  br i1 %30, label %31, label %75

31:                                               ; preds = %25
  %32 = load i32, ptr %3, align 4, !tbaa !14
  %33 = load i32, ptr %4, align 4, !tbaa !14
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %32, i32 noundef %33)
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %35

35:                                               ; preds = %67, %31
  %36 = load i32, ptr %5, align 4, !tbaa !14
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.areas_obj, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = icmp ult i32 %36, %39
  br i1 %40, label %41, label %70

41:                                               ; preds = %35
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.areas_obj, ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !15
  %45 = load i32, ptr %3, align 4, !tbaa !14
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.areas_obj, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !12
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.areas_obj, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = mul i32 %48, %51
  %53 = mul i32 %45, %52
  %54 = load i32, ptr %4, align 4, !tbaa !14
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.areas_obj, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 8, !tbaa !13
  %58 = mul i32 %54, %57
  %59 = add i32 %53, %58
  %60 = load i32, ptr %5, align 4, !tbaa !14
  %61 = add i32 %59, %60
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds float, ptr %44, i64 %62
  %64 = load float, ptr %63, align 4, !tbaa !16
  %65 = fpext float %64 to double
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %65)
  br label %67

67:                                               ; preds = %41
  %68 = load i32, ptr %5, align 4, !tbaa !14
  %69 = add i32 %68, 1
  store i32 %69, ptr %5, align 4, !tbaa !14
  br label %35, !llvm.loop !18

70:                                               ; preds = %35
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %72

72:                                               ; preds = %70
  %73 = load i32, ptr %4, align 4, !tbaa !14
  %74 = add i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !14
  br label %25, !llvm.loop !20

75:                                               ; preds = %25
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %3, align 4, !tbaa !14
  %78 = add i32 %77, 1
  store i32 %78, ptr %3, align 4, !tbaa !14
  br label %18, !llvm.loop !21

79:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!10, !11, i64 0}
!10 = !{!"areas_obj", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}


; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @areas_printf(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !11
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !12
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %8)
  %10 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %._crit_edge28, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i32, ptr %4, align 4, !tbaa !11
  %.not29 = icmp eq i32 %12, 0
  br i1 %.not29, label %._crit_edge28, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge26
  %13 = phi i32 [ %34, %._crit_edge26 ], [ %10, %.preheader.lr.ph ]
  %14 = phi i32 [ %35, %._crit_edge26 ], [ 1, %.preheader.lr.ph ]
  %.02127 = phi i32 [ %36, %._crit_edge26 ], [ 0, %.preheader.lr.ph ]
  %.not30 = icmp eq i32 %14, 0
  br i1 %.not30, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %.preheader, %._crit_edge
  %.02024 = phi i32 [ %31, %._crit_edge ], [ 0, %.preheader ]
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.02127, i32 noundef %.02024)
  %16 = load i32, ptr %7, align 8, !tbaa !12
  %.not31 = icmp eq i32 %16, 0
  br i1 %.not31, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph25, %.lr.ph
  %17 = phi i32 [ %28, %.lr.ph ], [ %16, %.lr.ph25 ]
  %.023 = phi i32 [ %27, %.lr.ph ], [ 0, %.lr.ph25 ]
  %18 = load ptr, ptr %11, align 8, !tbaa !13
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = mul i32 %19, %.02127
  %reass.add = add i32 %20, %.02024
  %reass.mul = mul i32 %reass.add, %17
  %21 = add i32 %reass.mul, %.023
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %18, i64 %22
  %24 = load float, ptr %23, align 4, !tbaa !14
  %25 = fpext float %24 to double
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %25)
  %27 = add nuw i32 %.023, 1
  %28 = load i32, ptr %7, align 8, !tbaa !12
  %29 = icmp ult i32 %27, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph25
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %31 = add nuw i32 %.02024, 1
  %32 = load i32, ptr %4, align 4, !tbaa !11
  %33 = icmp ult i32 %31, %32
  br i1 %33, label %.lr.ph25, label %._crit_edge26.loopexit, !llvm.loop !18

._crit_edge26.loopexit:                           ; preds = %._crit_edge
  %.pre = load i32, ptr %0, align 8, !tbaa !5
  br label %._crit_edge26

._crit_edge26:                                    ; preds = %._crit_edge26.loopexit, %.preheader
  %34 = phi i32 [ %.pre, %._crit_edge26.loopexit ], [ %13, %.preheader ]
  %35 = phi i32 [ %32, %._crit_edge26.loopexit ], [ 0, %.preheader ]
  %36 = add nuw i32 %.02127, 1
  %37 = icmp ult i32 %36, %34
  br i1 %37, label %.preheader, label %._crit_edge28, !llvm.loop !19

._crit_edge28:                                    ; preds = %._crit_edge26, %.preheader.lr.ph, %1
  ret void
}

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

attributes #0 = { nofree 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 "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" }

!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 = !{!"areas_obj", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17, !20}
!20 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass