; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (pgm)

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @vl_pgm_get_npixels(ptr noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare ptr @vl_malloc(i64 noundef) #2

declare void @vl_free(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @vl_pgm_read_new(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_pgm_read_new_f(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call i32 @vl_pgm_read_new(ptr noundef %14, ptr noundef %15, ptr noundef %10)
  store i32 %16, ptr %8, align 4, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %3
  %20 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %20, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %55

21:                                               ; preds = %3
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call i64 @vl_pgm_get_npixels(ptr noundef %22)
  store i64 %23, ptr %9, align 8, !tbaa !11
  %24 = load i64, ptr %9, align 8, !tbaa !11
  %25 = mul i64 4, %24
  %26 = call ptr @vl_malloc(i64 noundef %25)
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %26, ptr %27, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._VlPgmImage, ptr %28, i32 0, i32 2
  %30 = load i64, ptr %29, align 8, !tbaa !13
  %31 = uitofp i64 %30 to float
  %32 = fdiv float 1.000000e+00, %31
  store float %32, ptr %13, align 4, !tbaa !16
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %50, %21
  %34 = load i64, ptr %12, align 8, !tbaa !11
  %35 = load i64, ptr %9, align 8, !tbaa !11
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %37, label %53

37:                                               ; preds = %33
  %38 = load float, ptr %13, align 4, !tbaa !16
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = load i64, ptr %12, align 8, !tbaa !11
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !18
  %43 = zext i8 %42 to i32
  %44 = sitofp i32 %43 to float
  %45 = fmul float %38, %44
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = load i64, ptr %12, align 8, !tbaa !11
  %49 = getelementptr inbounds float, ptr %47, i64 %48
  store float %45, ptr %49, align 4, !tbaa !16
  br label %50

50:                                               ; preds = %37
  %51 = load i64, ptr %12, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %12, align 8, !tbaa !11
  br label %33, !llvm.loop !19

53:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  call void @vl_free(ptr noundef %54)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %55

55:                                               ; preds = %53, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %56 = load i32, ptr %4, align 4
  ret i32 %56
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 16}
!14 = !{!"_VlPgmImage", !15, i64 0, !15, i64 8, !15, i64 16, !10, i64 24}
!15 = !{!"long long", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!7, !7, 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"

; Function Attrs: nounwind uwtable
declare dso_local i64 @vl_pgm_get_npixels(ptr noundef) local_unnamed_addr #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare ptr @vl_malloc(i64 noundef) local_unnamed_addr #2

declare void @vl_free(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @vl_pgm_read_new_f(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = call i32 @vl_pgm_read_new(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %4)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %56

6:                                                ; preds = %3
  %7 = call i64 @vl_pgm_get_npixels(ptr noundef %1)
  %8 = shl i64 %7, 2
  %9 = call ptr @vl_malloc(i64 noundef %8) #3
  store ptr %9, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = uitofp i64 %11 to float
  %13 = fdiv float 1.000000e+00, %12
  %.not18 = icmp eq i64 %7, 0
  %.pre = load ptr, ptr %4, align 8, !tbaa !5
  br i1 %.not18, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %min.iters.check = icmp ult i64 %7, 8
  br i1 %min.iters.check, label %.lr.ph.preheader21, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %14 = shl i64 %7, 2
  %scevgep = getelementptr i8, ptr %9, i64 %14
  %scevgep19 = getelementptr i8, ptr %.pre, i64 %7
  %bound0 = icmp ult ptr %9, %scevgep19
  %bound1 = icmp ult ptr %.pre, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader21, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %7, -8
  %broadcast.splatinsert = insertelement <4 x float> poison, float %13, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %15 = getelementptr inbounds i8, ptr %.pre, i64 %index
  %16 = getelementptr inbounds i8, ptr %15, i64 4
  %wide.load = load <4 x i8>, ptr %15, align 1, !tbaa !13, !alias.scope !14
  %wide.load20 = load <4 x i8>, ptr %16, align 1, !tbaa !13, !alias.scope !14
  %17 = uitofp <4 x i8> %wide.load to <4 x float>
  %18 = uitofp <4 x i8> %wide.load20 to <4 x float>
  %19 = fmul <4 x float> %broadcast.splat, %17
  %20 = fmul <4 x float> %broadcast.splat, %18
  %21 = getelementptr inbounds float, ptr %9, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store <4 x float> %19, ptr %21, align 4, !tbaa !17, !alias.scope !19, !noalias !14
  store <4 x float> %20, ptr %22, align 4, !tbaa !17, !alias.scope !19, !noalias !14
  %index.next = add nuw i64 %index, 8
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !21

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %7, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader21

.lr.ph.preheader21:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.01517.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %7, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader21, %.lr.ph.prol
  %.01517.prol = phi i64 [ %29, %.lr.ph.prol ], [ %.01517.ph, %.lr.ph.preheader21 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader21 ]
  %24 = getelementptr inbounds i8, ptr %.pre, i64 %.01517.prol
  %25 = load i8, ptr %24, align 1, !tbaa !13
  %26 = uitofp i8 %25 to float
  %27 = fmul float %13, %26
  %28 = getelementptr inbounds float, ptr %9, i64 %.01517.prol
  store float %27, ptr %28, align 4, !tbaa !17
  %29 = add nuw i64 %.01517.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !25

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader21
  %.01517.unr = phi i64 [ %.01517.ph, %.lr.ph.preheader21 ], [ %29, %.lr.ph.prol ]
  %30 = sub i64 %.01517.ph, %7
  %31 = icmp ugt i64 %30, -4
  br i1 %31, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.01517 = phi i64 [ %55, %.lr.ph ], [ %.01517.unr, %.lr.ph.prol.loopexit ]
  %32 = getelementptr inbounds i8, ptr %.pre, i64 %.01517
  %33 = load i8, ptr %32, align 1, !tbaa !13
  %34 = uitofp i8 %33 to float
  %35 = fmul float %13, %34
  %36 = getelementptr inbounds float, ptr %9, i64 %.01517
  store float %35, ptr %36, align 4, !tbaa !17
  %37 = add nuw i64 %.01517, 1
  %38 = getelementptr inbounds i8, ptr %.pre, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = uitofp i8 %39 to float
  %41 = fmul float %13, %40
  %42 = getelementptr inbounds float, ptr %9, i64 %37
  store float %41, ptr %42, align 4, !tbaa !17
  %43 = add nuw i64 %.01517, 2
  %44 = getelementptr inbounds i8, ptr %.pre, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !13
  %46 = uitofp i8 %45 to float
  %47 = fmul float %13, %46
  %48 = getelementptr inbounds float, ptr %9, i64 %43
  store float %47, ptr %48, align 4, !tbaa !17
  %49 = add nuw i64 %.01517, 3
  %50 = getelementptr inbounds i8, ptr %.pre, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !13
  %52 = uitofp i8 %51 to float
  %53 = fmul float %13, %52
  %54 = getelementptr inbounds float, ptr %9, i64 %49
  store float %53, ptr %54, align 4, !tbaa !17
  %55 = add nuw i64 %.01517, 4
  %exitcond.not.3 = icmp eq i64 %55, %7
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !27

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %6
  call void @vl_free(ptr noundef %.pre) #3
  br label %56

56:                                               ; preds = %3, %._crit_edge
  %.0 = phi i32 [ 0, %._crit_edge ], [ %5, %3 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 %.0
}

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 = { "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 16}
!10 = !{!"_VlPgmImage", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15}
!15 = distinct !{!15, !16}
!16 = distinct !{!16, !"LVerDomain"}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!20}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.unroll.disable"}
!27 = distinct !{!27, !22, !23}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass