; LLVM IR from wumo/vkg :: src/par/test (test_msquares)

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

; 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
declare dso_local ptr @par_msquares_function(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden float @gray_height(float noundef, float noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @par_msquares_grayscale_multi(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6) #1 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca [2 x ptr], align 16
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %struct.par_gray_context, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #3
  %22 = call noalias ptr @calloc(i64 noundef 16, i64 noundef 1) #4
  %23 = getelementptr inbounds [2 x ptr], ptr %15, i64 0, i64 0
  store ptr %22, ptr %23, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %24 = load i32, ptr %14, align 4, !tbaa !9
  %25 = and i32 %24, 16
  store i32 %25, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %26 = load i32, ptr %14, align 4, !tbaa !9
  %27 = and i32 %26, 8
  store i32 %27, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %28 = load i32, ptr %14, align 4, !tbaa !9
  %29 = and i32 %28, 4
  store i32 %29, ptr %18, align 4, !tbaa !9
  %30 = load i32, ptr %18, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %7
  store i32 0, ptr %16, align 4, !tbaa !9
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %32, %7
  %34 = load i32, ptr %14, align 4, !tbaa !9
  %35 = and i32 %34, -2
  store i32 %35, ptr %14, align 4, !tbaa !9
  %36 = load i32, ptr %14, align 4, !tbaa !9
  %37 = and i32 %36, -3
  store i32 %37, ptr %14, align 4, !tbaa !9
  %38 = load i32, ptr %14, align 4, !tbaa !9
  %39 = and i32 %38, -17
  store i32 %39, ptr %14, align 4, !tbaa !9
  %40 = load i32, ptr %14, align 4, !tbaa !9
  %41 = and i32 %40, -9
  store i32 %41, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %19) #3
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 4
  store i32 %42, ptr %43, align 4, !tbaa !11
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 5
  store i32 %44, ptr %45, align 8, !tbaa !14
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 0
  store ptr %46, ptr %47, align 8, !tbaa !15
  %48 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 2
  store float 0xC7EFFFFFE0000000, ptr %48, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %94, %33
  %50 = load i32, ptr %20, align 4, !tbaa !9
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = icmp sle i32 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  br label %97

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %55 = load i32, ptr %20, align 4, !tbaa !9
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %54
  %58 = load i32, ptr %16, align 4, !tbaa !9
  br label %60

59:                                               ; preds = %54
  br label %60

60:                                               ; preds = %59, %57
  %61 = phi i32 [ %58, %57 ], [ 0, %59 ]
  store i32 %61, ptr %21, align 4, !tbaa !9
  %62 = load i32, ptr %20, align 4, !tbaa !9
  %63 = load i32, ptr %13, align 4, !tbaa !9
  %64 = icmp eq i32 %62, %63
  br i1 %64, label %65, label %70

65:                                               ; preds = %60
  %66 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 3
  store float 0x47EFFFFFE0000000, ptr %66, align 8, !tbaa !17
  %67 = load i32, ptr %17, align 4, !tbaa !9
  %68 = load i32, ptr %21, align 4, !tbaa !9
  %69 = or i32 %68, %67
  store i32 %69, ptr %21, align 4, !tbaa !9
  br label %77

70:                                               ; preds = %60
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i32, ptr %20, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %71, i64 %73
  %75 = load float, ptr %74, align 4, !tbaa !18
  %76 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 3
  store float %75, ptr %76, align 8, !tbaa !17
  br label %77

77:                                               ; preds = %70, %65
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = load i32, ptr %14, align 4, !tbaa !9
  %82 = call ptr @par_msquares_function(i32 noundef %78, i32 noundef %79, i32 noundef %80, i32 noundef %81, ptr noundef %19, ptr noundef @gray_multi_inside, ptr noundef @gray_height)
  %83 = getelementptr inbounds [2 x ptr], ptr %15, i64 0, i64 1
  store ptr %82, ptr %83, align 8, !tbaa !5
  %84 = getelementptr inbounds [2 x ptr], ptr %15, i64 0, i64 0
  %85 = load i32, ptr %21, align 4, !tbaa !9
  %86 = call ptr @par_msquares__merge(ptr noundef %84, i32 noundef 2, i32 noundef %85)
  %87 = getelementptr inbounds [2 x ptr], ptr %15, i64 0, i64 0
  store ptr %86, ptr %87, align 16, !tbaa !5
  %88 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 3
  %89 = load float, ptr %88, align 8, !tbaa !17
  %90 = getelementptr inbounds %struct.par_gray_context, ptr %19, i32 0, i32 2
  store float %89, ptr %90, align 4, !tbaa !16
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = load i32, ptr %14, align 4, !tbaa !9
  %93 = or i32 %92, %91
  store i32 %93, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %94

94:                                               ; preds = %77
  %95 = load i32, ptr %20, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %20, align 4, !tbaa !9
  br label %49, !llvm.loop !19

97:                                               ; preds = %53
  %98 = getelementptr inbounds [2 x ptr], ptr %15, i64 0, i64 0
  %99 = load ptr, ptr %98, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #3
  ret ptr %99
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @gray_multi_inside(i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @par_msquares__merge(ptr noundef, i32 noundef, i32 noundef) #1

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 = { nounwind allocsize(0,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 #3 = { nounwind }
attributes #4 = { nounwind allocsize(0,1) }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 20}
!12 = !{!"", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 24}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !13, i64 12}
!17 = !{!12, !13, i64 16}
!18 = !{!13, !13, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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.par_gray_context = type { ptr, float, float, float, i32, i32 }

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @par_msquares_function(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden float @gray_height(float noundef, float noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @par_msquares_grayscale_multi(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = alloca [2 x ptr], align 16
  %9 = alloca %struct.par_gray_context, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #3
  %10 = tail call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 16, i64 noundef 1) #4
  store ptr %10, ptr %8, align 16, !tbaa !5
  %11 = and i32 %6, 16
  %12 = and i32 %6, 8
  %13 = and i32 %6, 4
  %.not = icmp eq i32 %13, 0
  %spec.select = select i1 %.not, i32 0, i32 %11
  %spec.select35 = select i1 %.not, i32 0, i32 %12
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #3
  %14 = getelementptr inbounds i8, ptr %9, i64 20
  store i32 %1, ptr %14, align 4, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %9, i64 24
  store i32 %2, ptr %15, align 8, !tbaa !13
  store ptr %0, ptr %9, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %9, i64 12
  store float 0xC7EFFFFFE0000000, ptr %16, align 4, !tbaa !15
  %.not3336 = icmp slt i32 %5, 0
  br i1 %.not3336, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %17 = and i32 %6, -28
  %18 = getelementptr inbounds i8, ptr %9, i64 16
  %19 = getelementptr inbounds i8, ptr %8, i64 8
  %20 = or disjoint i32 %spec.select, %17
  %21 = zext nneg i32 %5 to i64
  %22 = add nuw i32 %5, 1
  %wide.trip.count = zext i32 %22 to i64
  %23 = icmp eq i32 %5, 0
  br i1 %23, label %26, label %24

24:                                               ; preds = %.lr.ph
  %25 = load float, ptr %4, align 4, !tbaa !16
  br label %26

26:                                               ; preds = %.lr.ph, %24
  %storemerge = phi float [ %25, %24 ], [ 0x47EFFFFFE0000000, %.lr.ph ]
  %.0.peel = phi i32 [ 0, %24 ], [ %spec.select35, %.lr.ph ]
  store float %storemerge, ptr %18, align 8, !tbaa !17
  %27 = call ptr @par_msquares_function(i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %17, ptr noundef nonnull %9, ptr noundef nonnull @gray_multi_inside, ptr noundef nonnull @gray_height)
  store ptr %27, ptr %19, align 8, !tbaa !5
  %28 = call ptr @par_msquares__merge(ptr noundef nonnull %8, i32 noundef 2, i32 noundef %.0.peel)
  store ptr %28, ptr %8, align 16, !tbaa !5
  %29 = load float, ptr %18, align 8, !tbaa !17
  store float %29, ptr %16, align 4, !tbaa !15
  %exitcond.peel.not = icmp eq i32 %5, 0
  br i1 %exitcond.peel.not, label %._crit_edge, label %.peel.next

.peel.next:                                       ; preds = %26
  %30 = or disjoint i32 %spec.select, %spec.select35
  br label %32

._crit_edge:                                      ; preds = %37, %26, %7
  %31 = phi ptr [ %10, %7 ], [ %28, %26 ], [ %39, %37 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #3
  ret ptr %31

32:                                               ; preds = %.peel.next, %37
  %indvars.iv = phi i64 [ 1, %.peel.next ], [ %indvars.iv.next, %37 ]
  %33 = icmp eq i64 %indvars.iv, %21
  br i1 %33, label %37, label %34

34:                                               ; preds = %32
  %35 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  %36 = load float, ptr %35, align 4, !tbaa !16
  br label %37

37:                                               ; preds = %32, %34
  %.sink = phi float [ %36, %34 ], [ 0x47EFFFFFE0000000, %32 ]
  %.0 = phi i32 [ %spec.select, %34 ], [ %30, %32 ]
  store float %.sink, ptr %18, align 8, !tbaa !17
  %38 = call ptr @par_msquares_function(i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %20, ptr noundef nonnull %9, ptr noundef nonnull @gray_multi_inside, ptr noundef nonnull @gray_height)
  store ptr %38, ptr %19, align 8, !tbaa !5
  %39 = call ptr @par_msquares__merge(ptr noundef nonnull %8, i32 noundef 2, i32 noundef %.0)
  store ptr %39, ptr %8, align 16, !tbaa !5
  %40 = load float, ptr %18, align 8, !tbaa !17
  store float %40, ptr %16, align 4, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %32, !llvm.loop !18
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @gray_multi_inside(i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @par_msquares__merge(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #4 = { nounwind allocsize(0,1) }

!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 20}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20, !12, i64 24}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 24}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !11, i64 12}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 16}
!18 = distinct !{!18, !19, !20}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.peeled.count", i32 1}


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