; LLVM IR from DionysiosB/CodeForces :: 0100-0199/167C-WizardsAndNumbers.ll (Z3dfsll)

; 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"

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3dfsll(i64 noundef %0, i64 noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  %6 = load i64, ptr %4, align 8, !tbaa !5
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  store i1 true, ptr %3, align 1
  br label %35

9:                                                ; preds = %2
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = load i64, ptr %4, align 8, !tbaa !5
  %12 = srem i64 %10, %11
  %13 = load i64, ptr %4, align 8, !tbaa !5
  %14 = call noundef zeroext i1 @_Z3dfsll(i64 noundef %12, i64 noundef %13)
  br i1 %14, label %15, label %16

15:                                               ; preds = %9
  store i1 false, ptr %3, align 1
  br label %35

16:                                               ; preds = %9
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = srem i64 %17, 2
  %19 = icmp eq i64 %18, 1
  br i1 %19, label %20, label %26

20:                                               ; preds = %16
  %21 = load i64, ptr %5, align 8, !tbaa !5
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = sdiv i64 %21, %22
  %24 = srem i64 %23, 2
  %25 = icmp ne i64 %24, 0
  store i1 %25, ptr %3, align 1
  br label %35

26:                                               ; preds = %16
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = sdiv i64 %27, %28
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1
  %32 = srem i64 %29, %31
  %33 = srem i64 %32, 2
  %34 = icmp ne i64 %33, 0
  store i1 %34, ptr %3, align 1
  br label %35

35:                                               ; preds = %26, %20, %15, %8
  %36 = load i1, ptr %3, align 1
  ret i1 %36
}

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


; 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 nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z3dfsll(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq i64 %0, 0
  br i1 %3, label %19, label %4

4:                                                ; preds = %2
  %5 = srem i64 %1, %0
  %6 = sdiv i64 %1, %0
  %7 = tail call noundef zeroext i1 @_Z3dfsll(i64 noundef %5, i64 noundef %0)
  br i1 %7, label %19, label %8

8:                                                ; preds = %4
  %9 = and i64 %0, -9223372036854775807
  %10 = icmp eq i64 %9, 1
  br i1 %10, label %11, label %14

11:                                               ; preds = %8
  %12 = and i64 %6, 1
  %13 = icmp ne i64 %12, 0
  br label %19

14:                                               ; preds = %8
  %15 = add nsw i64 %0, 1
  %16 = srem i64 %6, %15
  %17 = and i64 %16, 1
  %18 = icmp ne i64 %17, 0
  br label %19

19:                                               ; preds = %4, %2, %14, %11
  %.0 = phi i1 [ %13, %11 ], [ %18, %14 ], [ true, %2 ], [ false, %4 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree 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: DivRemPairsPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass