; LLVM IR from vmartinv/eldiego :: estructuras/convexhull.trick.ll (Z5inter4LineS_)

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

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

30:                                               ; preds = %4
  %31 = load i64, ptr %7, align 8, !tbaa !10
  %32 = icmp sgt i64 %31, 0
  %33 = zext i1 %32 to i32
  %34 = load i64, ptr %8, align 8, !tbaa !10
  %35 = icmp sgt i64 %34, 0
  %36 = zext i1 %35 to i32
  %37 = xor i32 %33, %36
  %38 = icmp ne i32 %37, 0
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  br label %42

41:                                               ; preds = %4
  br label %42

42:                                               ; preds = %41, %30
  %43 = phi i32 [ %40, %30 ], [ 0, %41 ]
  %44 = sext i32 %43 to i64
  %45 = add nsw i64 %25, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret i64 %45
}

; 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

attributes #0 = { mustprogress 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 = { 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 8}
!6 = !{!"_ZTS4Line", !7, i64 0, !7, i64 8}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!6, !7, i64 0}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i64 @_Z5inter4LineS_(i64 %0, i64 %1, i64 %2, i64 %3) local_unnamed_addr #0 {
  %5 = sub nsw i64 %3, %1
  %6 = sub nsw i64 %0, %2
  %7 = srem i64 %5, %6
  %.not = icmp ne i64 %7, 0
  %8 = icmp sgt i64 %5, 0
  %9 = icmp slt i64 %6, 1
  %10 = xor i1 %9, %8
  %narrow = and i1 %10, %.not
  %11 = zext i1 %narrow to i64
  %12 = sdiv i64 %5, %6
  %13 = add nsw i64 %12, %11
  ret i64 %13
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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" }

!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)"}


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