; LLVM IR from parallella/pal :: examples/image (harris)

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

@__const.main.src = external hidden unnamed_addr constant <{ [113 x float], [56 x float] }>, align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [169 x float], align 16
  %9 = alloca [81 x float], align 16
  %10 = alloca [363 x float], align 16
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 676, ptr %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const.main.src, i64 676, i1 false)
  call void @llvm.lifetime.start.p0(i64 324, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 1452, ptr %10) #4
  %11 = getelementptr inbounds [169 x float], ptr %8, i64 0, i64 0
  %12 = getelementptr inbounds [81 x float], ptr %9, i64 0, i64 0
  %13 = getelementptr inbounds [363 x float], ptr %10, i64 0, i64 0
  call void @p_harris3x3_f32(ptr noundef %11, ptr noundef %12, ptr noundef %13, i32 noundef 13, i32 noundef 13)
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %36, %2
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 13
  br i1 %16, label %17, label %39

17:                                               ; preds = %14
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %31, %17
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 13
  br i1 %20, label %21, label %34

21:                                               ; preds = %18
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = mul nsw i32 %22, 13
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [169 x float], ptr %8, i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = fpext float %28 to double
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %29)
  br label %31

31:                                               ; preds = %21
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %7, align 4, !tbaa !5
  br label %18, !llvm.loop !13

34:                                               ; preds = %18
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %36

36:                                               ; preds = %34
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %6, align 4, !tbaa !5
  br label %14, !llvm.loop !15

39:                                               ; preds = %14
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %63, %39
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = icmp slt i32 %42, 9
  br i1 %43, label %44, label %66

44:                                               ; preds = %41
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %58, %44
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = icmp slt i32 %46, 9
  br i1 %47, label %48, label %61

48:                                               ; preds = %45
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = mul nsw i32 %49, 9
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = add nsw i32 %50, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [81 x float], ptr %9, i64 0, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !11
  %56 = fpext float %55 to double
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %56)
  br label %58

58:                                               ; preds = %48
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %7, align 4, !tbaa !5
  br label %45, !llvm.loop !16

61:                                               ; preds = %45
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %63

63:                                               ; preds = %61
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %6, align 4, !tbaa !5
  br label %41, !llvm.loop !17

66:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 1452, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 324, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 676, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %67 = load i32, ptr %3, align 4
  ret i32 %67
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @p_harris3x3_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #3

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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

@__const.main.src = external hidden unnamed_addr constant <{ [113 x float], [56 x float] }>, align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca [169 x float], align 16
  %4 = alloca [81 x float], align 16
  %5 = alloca [363 x float], align 16
  call void @llvm.lifetime.start.p0(i64 676, ptr nonnull %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(676) %3, ptr noundef nonnull align 16 dereferenceable(676) @__const.main.src, i64 676, i1 false)
  call void @llvm.lifetime.start.p0(i64 324, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 1452, ptr nonnull %5) #5
  call void @p_harris3x3_f32(ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, i32 noundef 13, i32 noundef 13) #5
  br label %.preheader15

.preheader15:                                     ; preds = %2, %.preheader15
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %.preheader15 ]
  %6 = mul nuw nsw i64 %indvars.iv, 13
  %7 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %6
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = fpext float %8 to double
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %9)
  %11 = add nuw nsw i64 %6, 1
  %12 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %11
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fpext float %13 to double
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %14)
  %16 = add nuw nsw i64 %6, 2
  %17 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %16
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = fpext float %18 to double
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %19)
  %21 = add nuw nsw i64 %6, 3
  %22 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %21
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = fpext float %23 to double
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %24)
  %26 = add nuw nsw i64 %6, 4
  %27 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = fpext float %28 to double
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %29)
  %31 = add nuw nsw i64 %6, 5
  %32 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = fpext float %33 to double
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %34)
  %36 = add nuw nsw i64 %6, 6
  %37 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = fpext float %38 to double
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %39)
  %41 = add nuw nsw i64 %6, 7
  %42 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !5
  %44 = fpext float %43 to double
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %44)
  %46 = add nuw nsw i64 %6, 8
  %47 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !5
  %49 = fpext float %48 to double
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %49)
  %51 = add nuw nsw i64 %6, 9
  %52 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !5
  %54 = fpext float %53 to double
  %55 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %54)
  %56 = add nuw nsw i64 %6, 10
  %57 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !5
  %59 = fpext float %58 to double
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %59)
  %61 = add nuw nsw i64 %6, 11
  %62 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !5
  %64 = fpext float %63 to double
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %64)
  %66 = add nuw nsw i64 %6, 12
  %67 = getelementptr inbounds [169 x float], ptr %3, i64 0, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !5
  %69 = fpext float %68 to double
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %69)
  %71 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 13
  br i1 %exitcond.not, label %72, label %.preheader15, !llvm.loop !9

72:                                               ; preds = %.preheader15
  %73 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.preheader

.preheader:                                       ; preds = %72, %.preheader
  %indvars.iv26 = phi i64 [ 0, %72 ], [ %indvars.iv.next27, %.preheader ]
  %74 = mul nuw nsw i64 %indvars.iv26, 9
  %75 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %74
  %76 = load float, ptr %75, align 4, !tbaa !5
  %77 = fpext float %76 to double
  %78 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %77)
  %79 = add nuw nsw i64 %74, 1
  %80 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %79
  %81 = load float, ptr %80, align 4, !tbaa !5
  %82 = fpext float %81 to double
  %83 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %82)
  %84 = add nuw nsw i64 %74, 2
  %85 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %84
  %86 = load float, ptr %85, align 4, !tbaa !5
  %87 = fpext float %86 to double
  %88 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %87)
  %89 = add nuw nsw i64 %74, 3
  %90 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %89
  %91 = load float, ptr %90, align 4, !tbaa !5
  %92 = fpext float %91 to double
  %93 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %92)
  %94 = add nuw nsw i64 %74, 4
  %95 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %94
  %96 = load float, ptr %95, align 4, !tbaa !5
  %97 = fpext float %96 to double
  %98 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %97)
  %99 = add nuw nsw i64 %74, 5
  %100 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %99
  %101 = load float, ptr %100, align 4, !tbaa !5
  %102 = fpext float %101 to double
  %103 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %102)
  %104 = add nuw nsw i64 %74, 6
  %105 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %104
  %106 = load float, ptr %105, align 4, !tbaa !5
  %107 = fpext float %106 to double
  %108 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %107)
  %109 = add nuw nsw i64 %74, 7
  %110 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %109
  %111 = load float, ptr %110, align 4, !tbaa !5
  %112 = fpext float %111 to double
  %113 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %112)
  %114 = add nuw nsw i64 %74, 8
  %115 = getelementptr inbounds [81 x float], ptr %4, i64 0, i64 %114
  %116 = load float, ptr %115, align 4, !tbaa !5
  %117 = fpext float %116 to double
  %118 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %117)
  %119 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next27, 9
  br i1 %exitcond29.not, label %120, label %.preheader, !llvm.loop !11

120:                                              ; preds = %.preheader
  call void @llvm.lifetime.end.p0(i64 1452, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 324, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 676, ptr nonnull %3) #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: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @p_harris3x3_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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: readwrite) }
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 }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass