; LLVM IR from parallella/pal :: benchmark/image (all)

; 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.p_bench_specification = type { %struct.p_bench_raw_memory, i64 }
%struct.p_bench_raw_memory = type { %union.anon, %union.anon.0, %union.anon.1, %union.anon.2, %union.p_bench_param, %union.p_bench_param, %union.p_bench_param, %union.p_bench_param }
%union.anon = type { %union.p_bench_param }
%union.anon.0 = type { %union.p_bench_param }
%union.anon.1 = type { %union.p_bench_param }
%union.anon.2 = type { %union.p_bench_param }
%union.p_bench_param = type { ptr }

; Function Attrs: nounwind uwtable
define dso_local void @bench_p_box3x3_f32(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.p_bench_specification, ptr %5, i32 0, i32 1
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = lshr i64 %7, 1
  store i64 %8, ptr %3, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  br label %9

9:                                                ; preds = %17, %1
  %10 = load i64, ptr %3, align 8, !tbaa !13
  %11 = load i64, ptr %3, align 8, !tbaa !13
  %12 = mul i64 %10, %11
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.p_bench_specification, ptr %13, i32 0, i32 1
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = icmp ugt i64 %12, %15
  br i1 %16, label %17, label %20

17:                                               ; preds = %9
  %18 = load i64, ptr %3, align 8, !tbaa !13
  %19 = lshr i64 %18, 1
  store i64 %19, ptr %3, align 8, !tbaa !13
  br label %9, !llvm.loop !14

20:                                               ; preds = %9
  %21 = load i64, ptr %3, align 8, !tbaa !13
  store i64 %21, ptr %4, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %31, %20
  %23 = load i64, ptr %4, align 8, !tbaa !13
  %24 = shl i64 %23, 1
  %25 = load i64, ptr %3, align 8, !tbaa !13
  %26 = mul i64 %24, %25
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.p_bench_specification, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = icmp ult i64 %26, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %22
  %32 = load i64, ptr %4, align 8, !tbaa !13
  %33 = shl i64 %32, 1
  store i64 %33, ptr %4, align 8, !tbaa !13
  br label %22, !llvm.loop !16

34:                                               ; preds = %22
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.p_bench_specification, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.p_bench_raw_memory, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.p_bench_specification, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.p_bench_raw_memory, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = load i64, ptr %4, align 8, !tbaa !13
  %44 = trunc i64 %43 to i32
  %45 = load i64, ptr %3, align 8, !tbaa !13
  %46 = trunc i64 %45 to i32
  call void @p_box3x3_f32(ptr noundef %38, ptr noundef %42, i32 noundef %44, i32 noundef %46)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

declare void @p_box3x3_f32(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; 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 = { "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, !12, i64 64}
!10 = !{!"p_bench_specification", !11, i64 0, !12, i64 64}
!11 = !{!"p_bench_raw_memory", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!12 = !{!"long", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!7, !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"

; Function Attrs: nounwind uwtable
define dso_local void @bench_p_box3x3_f32(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i64, ptr %2, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %4, %1
  %.013.in = phi i64 [ %3, %1 ], [ %.013, %4 ]
  %.013 = lshr i64 %.013.in, 1
  %5 = mul i64 %.013, %.013
  %6 = icmp ugt i64 %5, %3
  br i1 %6, label %4, label %.preheader, !llvm.loop !11

.preheader:                                       ; preds = %4, %.preheader
  %.0 = phi i64 [ %7, %.preheader ], [ %.013, %4 ]
  %7 = shl i64 %.0, 1
  %8 = mul i64 %7, %.013
  %9 = icmp ult i64 %8, %3
  br i1 %9, label %.preheader, label %10, !llvm.loop !13

10:                                               ; preds = %.preheader
  %11 = load ptr, ptr %0, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = trunc i64 %.0 to i32
  %15 = trunc i64 %.013 to i32
  tail call void @p_box3x3_f32(ptr noundef %11, ptr noundef %13, i32 noundef %14, i32 noundef %15) #2
  ret void
}

declare void @p_box3x3_f32(ptr noundef, ptr noundef, i32 noundef, i32 noundef) 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 = { "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 = { 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, !10, i64 64}
!6 = !{!"p_bench_specification", !7, i64 0, !10, i64 64}
!7 = !{!"p_bench_raw_memory", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass