; LLVM IR from themisvaltinos/Partitioned-Hash-Join :: modules/phjoin (jobs)

; 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.histogram_job_args = type { ptr, i32, i32, i32, i8, ptr }
%struct.tuple = type { i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @histogramJob(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.histogram_job_args, ptr %7, i32 0, i32 3
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = shl i32 1, %9
  %11 = call ptr @memAlloc(i32 noundef 4, i32 noundef %10, i1 noundef zeroext true, ptr noundef null)
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.histogram_job_args, ptr %12, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  store ptr %11, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.histogram_job_args, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !13
  store i32 %17, ptr %4, align 4, !tbaa !14
  br label %18

18:                                               ; preds = %54, %1
  %19 = load i32, ptr %4, align 4, !tbaa !14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.histogram_job_args, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 4, !tbaa !15
  %23 = icmp ult i32 %19, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %57

25:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.histogram_job_args, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = load i32, ptr %4, align 4, !tbaa !14
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %struct.tuple, ptr %28, i64 %30
  %32 = getelementptr inbounds %struct.tuple, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !17
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.histogram_job_args, ptr %34, i32 0, i32 4
  %36 = load i8, ptr %35, align 4, !tbaa !19
  %37 = zext i8 %36 to i32
  %38 = lshr i32 %33, %37
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.histogram_job_args, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 8, !tbaa !9
  %42 = shl i32 -1, %41
  %43 = xor i32 %42, -1
  %44 = and i32 %38, %43
  store i32 %44, ptr %5, align 4, !tbaa !14
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.histogram_job_args, ptr %45, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !12
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !14
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr %48, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = add i32 %52, 1
  store i32 %53, ptr %51, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %54

54:                                               ; preds = %25
  %55 = load i32, ptr %4, align 4, !tbaa !14
  %56 = add i32 %55, 1
  store i32 %56, ptr %4, align 4, !tbaa !14
  br label %18, !llvm.loop !20

57:                                               ; preds = %24
  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 ptr @memAlloc(i32 noundef, i32 noundef, i1 noundef zeroext, ptr 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, !11, i64 16}
!10 = !{!"histogram_job_args", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !7, i64 20, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !11, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !6, i64 0}
!17 = !{!18, !11, i64 4}
!18 = !{!"tuple", !11, i64 0, !11, i64 4}
!19 = !{!10, !7, i64 20}
!20 = distinct !{!20, !21}
!21 = !{!"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.tuple = type { i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @histogramJob(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = shl nuw i32 1, %3
  %5 = tail call ptr @memAlloc(i32 noundef 4, i32 noundef %4, i1 noundef zeroext true, ptr noundef null) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  store ptr %5, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !14
  %12 = icmp ult i32 %9, %11
  br i1 %12, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %13 = load ptr, ptr %0, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  %15 = load i8, ptr %14, align 4, !tbaa !16
  %16 = zext nneg i8 %15 to i32
  %17 = load ptr, ptr %6, align 8, !tbaa !11
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = zext i32 %9 to i64
  br label %20

._crit_edge:                                      ; preds = %20, %1
  ret void

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ %19, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = getelementptr inbounds %struct.tuple, ptr %13, i64 %indvars.iv, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !17
  %23 = lshr i32 %22, %16
  %24 = load i32, ptr %2, align 8, !tbaa !5
  %25 = shl nsw i32 -1, %24
  %26 = xor i32 %25, -1
  %27 = and i32 %23, %26
  %28 = zext nneg i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %18, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = add i32 %30, 1
  store i32 %31, ptr %29, align 4, !tbaa !19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load i32, ptr %10, align 4, !tbaa !14
  %33 = zext i32 %32 to i64
  %34 = icmp ult i64 %indvars.iv.next, %33
  br i1 %34, label %20, label %._crit_edge, !llvm.loop !20
}

declare ptr @memAlloc(i32 noundef, i32 noundef, i1 noundef zeroext, ptr 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 16}
!6 = !{!"histogram_job_args", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !8, i64 20, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !8, i64 20}
!17 = !{!18, !10, i64 4}
!18 = !{!"tuple", !10, i64 0, !10, i64 4}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass