; LLVM IR from themisvaltinos/Partitioned-Hash-Join :: tests/test_phjoin.ll (parseRelation)

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

@.str.36 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._parseRelation = external hidden unnamed_addr constant [44 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [100 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [62 x i8], align 1

; 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
define dso_local void @_parseRelation(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.join_relation, ptr %7, i32 0, i32 1
  %9 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %6, ptr noundef @.str.36, ptr noundef %8)
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %13

12:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.37, ptr noundef @.str.38, i32 noundef 20, ptr noundef @__PRETTY_FUNCTION__._parseRelation) #4
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.join_relation, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = call ptr @memAlloc(i32 noundef 8, i32 noundef %16, i1 noundef zeroext false, ptr noundef null)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.join_relation, ptr %18, i32 0, i32 0
  store ptr %17, ptr %19, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %20

20:                                               ; preds = %62, %13
  %21 = load i32, ptr %5, align 4, !tbaa !13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.join_relation, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = icmp ult i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %65

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.join_relation, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = load i32, ptr %5, align 4, !tbaa !13
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds %struct.tuple, ptr %31, i64 %33
  %35 = getelementptr inbounds %struct.tuple, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.join_relation, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !12
  %39 = load i32, ptr %5, align 4, !tbaa !13
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds %struct.tuple, ptr %38, i64 %40
  %42 = getelementptr inbounds %struct.tuple, ptr %41, i32 0, i32 1
  %43 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %28, ptr noundef @.str.39, ptr noundef %35, ptr noundef %42)
  %44 = icmp eq i32 %43, 2
  br i1 %44, label %45, label %46

45:                                               ; preds = %27
  br label %47

46:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.40, ptr noundef @.str.38, i32 noundef 25, ptr noundef @__PRETTY_FUNCTION__._parseRelation) #4
  unreachable

47:                                               ; preds = %45
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !13
  %50 = add i32 %49, 1
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.join_relation, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !9
  %54 = icmp eq i32 %50, %53
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, ptr @.str.41, ptr @.str.42
  %57 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %48, ptr noundef %56)
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %47
  br label %61

60:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str.43, ptr noundef @.str.38, i32 noundef 26, ptr noundef @__PRETTY_FUNCTION__._parseRelation) #4
  unreachable

61:                                               ; preds = %59
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %5, align 4, !tbaa !13
  %64 = add i32 %63, 1
  store i32 %64, ptr %5, align 4, !tbaa !13
  br label %20, !llvm.loop !14

65:                                               ; preds = %26
  ret void
}

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare ptr @memAlloc(i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef) #2

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 = { "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 = { noreturn 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 #4 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"join_relation", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 }

@.str.36 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._parseRelation = external hidden unnamed_addr constant [44 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [100 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [62 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @_parseRelation(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = tail call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull @.str.36, ptr noundef nonnull %3) #3
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.38, i32 noundef 20, ptr noundef nonnull @__PRETTY_FUNCTION__._parseRelation) #4
  unreachable

7:                                                ; preds = %2
  %8 = load i32, ptr %3, align 8, !tbaa !5
  %9 = tail call ptr @memAlloc(i32 noundef 8, i32 noundef %8, i1 noundef zeroext false, ptr noundef null) #3
  store ptr %9, ptr %1, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %22, %7
  %indvars.iv = phi i64 [ %indvars.iv.next, %22 ], [ 0, %7 ]
  %11 = load i32, ptr %3, align 8, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = icmp ult i64 %indvars.iv, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  ret void

15:                                               ; preds = %10
  %16 = load ptr, ptr %1, align 8, !tbaa !11
  %17 = getelementptr inbounds %struct.tuple, ptr %16, i64 %indvars.iv
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = tail call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull @.str.39, ptr noundef %17, ptr noundef nonnull %18) #3
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %22, label %21

21:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.40, ptr noundef nonnull @.str.38, i32 noundef 25, ptr noundef nonnull @__PRETTY_FUNCTION__._parseRelation) #4
  unreachable

22:                                               ; preds = %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %3, align 8, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = icmp eq i64 %indvars.iv.next, %24
  %26 = select i1 %25, ptr @.str.41, ptr @.str.42
  %27 = tail call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull %26) #3
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %10, label %29, !llvm.loop !12

29:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str.43, ptr noundef nonnull @.str.38, i32 noundef 26, ptr noundef nonnull @__PRETTY_FUNCTION__._parseRelation) #4
  unreachable
}

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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 = { noreturn 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 #3 = { nounwind }
attributes #4 = { noreturn 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 8}
!6 = !{!"join_relation", !7, i64 0, !10, i64 8}
!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 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass