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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @vl_quickshift_new(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = call ptr @vl_malloc(i64 noundef 64)
  store ptr %10, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %9, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._VlQS, ptr %12, i32 0, i32 0
  store ptr %11, ptr %13, align 8, !tbaa !11
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._VlQS, ptr %15, i32 0, i32 1
  store i32 %14, ptr %16, align 8, !tbaa !14
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._VlQS, ptr %18, i32 0, i32 2
  store i32 %17, ptr %19, align 4, !tbaa !15
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._VlQS, ptr %21, i32 0, i32 3
  store i32 %20, ptr %22, align 8, !tbaa !16
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._VlQS, ptr %23, i32 0, i32 4
  store i32 0, ptr %24, align 4, !tbaa !17
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = icmp sgt i32 %25, %26
  br i1 %27, label %28, label %30

28:                                               ; preds = %4
  %29 = load i32, ptr %6, align 4, !tbaa !9
  br label %32

30:                                               ; preds = %4
  %31 = load i32, ptr %7, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %30, %28
  %33 = phi i32 [ %29, %28 ], [ %31, %30 ]
  %34 = sdiv i32 %33, 50
  %35 = sitofp i32 %34 to double
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._VlQS, ptr %36, i32 0, i32 6
  store double %35, ptr %37, align 8, !tbaa !18
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._VlQS, ptr %38, i32 0, i32 6
  %40 = load double, ptr %39, align 8, !tbaa !18
  %41 = fdiv double %40, 3.000000e+00
  %42 = fcmp ogt double 2.000000e+00, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %32
  br label %49

44:                                               ; preds = %32
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._VlQS, ptr %45, i32 0, i32 6
  %47 = load double, ptr %46, align 8, !tbaa !18
  %48 = fdiv double %47, 3.000000e+00
  br label %49

49:                                               ; preds = %44, %43
  %50 = phi double [ 2.000000e+00, %43 ], [ %48, %44 ]
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._VlQS, ptr %51, i32 0, i32 5
  store double %50, ptr %52, align 8, !tbaa !19
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = mul nsw i32 %53, %54
  %56 = sext i32 %55 to i64
  %57 = call ptr @vl_calloc(i64 noundef %56, i64 noundef 8)
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._VlQS, ptr %58, i32 0, i32 8
  store ptr %57, ptr %59, align 8, !tbaa !20
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = mul nsw i32 %60, %61
  %63 = sext i32 %62 to i64
  %64 = call ptr @vl_calloc(i64 noundef %63, i64 noundef 4)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._VlQS, ptr %65, i32 0, i32 7
  store ptr %64, ptr %66, align 8, !tbaa !21
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = mul nsw i32 %67, %68
  %70 = sext i32 %69 to i64
  %71 = call ptr @vl_calloc(i64 noundef %70, i64 noundef 8)
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._VlQS, ptr %72, i32 0, i32 9
  store ptr %71, ptr %73, align 8, !tbaa !22
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %74
}

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

declare ptr @vl_malloc(i64 noundef) #2

declare ptr @vl_calloc(i64 noundef, i64 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_VlQS", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 20}
!18 = !{!12, !13, i64 32}
!19 = !{!12, !13, i64 24}
!20 = !{!12, !6, i64 48}
!21 = !{!12, !6, i64 40}
!22 = !{!12, !6, i64 56}


; 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 noundef ptr @vl_quickshift_new(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @vl_malloc(i64 noundef 64) #3
  store ptr %0, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %1, ptr %6, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 %2, ptr %7, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %3, ptr %8, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %5, i64 20
  store i32 0, ptr %9, align 4, !tbaa !15
  %10 = tail call i32 @llvm.smax.i32(i32 %1, i32 %2)
  %11 = sdiv i32 %10, 50
  %12 = sitofp i32 %11 to double
  %13 = getelementptr inbounds i8, ptr %5, i64 32
  store double %12, ptr %13, align 8, !tbaa !16
  %14 = fdiv double %12, 3.000000e+00
  %15 = fcmp olt double %14, 2.000000e+00
  %16 = select i1 %15, double 2.000000e+00, double %14
  %17 = getelementptr inbounds i8, ptr %5, i64 24
  store double %16, ptr %17, align 8, !tbaa !17
  %18 = mul nsw i32 %2, %1
  %19 = sext i32 %18 to i64
  %20 = tail call ptr @vl_calloc(i64 noundef %19, i64 noundef 8) #3
  %21 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr %20, ptr %21, align 8, !tbaa !18
  %22 = tail call ptr @vl_calloc(i64 noundef %19, i64 noundef 4) #3
  %23 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr %22, ptr %23, align 8, !tbaa !19
  %24 = tail call ptr @vl_calloc(i64 noundef %19, i64 noundef 8) #3
  %25 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr %24, ptr %25, align 8, !tbaa !20
  ret ptr %5
}

declare ptr @vl_malloc(i64 noundef) local_unnamed_addr #1

declare ptr @vl_calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_VlQS", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 12}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 20}
!16 = !{!6, !11, i64 32}
!17 = !{!6, !11, i64 24}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !7, i64 40}
!20 = !{!6, !7, i64 56}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass