; LLVM IR from Tiramisu-Compiler/tiramisu :: 3rdParty/isl/imath (gmp_compat)

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

@MP_OK = external constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [48 x i8], align 1
@__PRETTY_FUNCTION__.impz_divisible_p = external hidden unnamed_addr constant [37 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [65 x i8], align 1

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

declare void @mp_int_clear(ptr noundef) #1

declare i32 @mp_int_init(ptr noundef) #1

declare i32 @mp_int_compare_zero(ptr noundef) #1

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

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

declare i32 @mp_int_div(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @impz_divisible_p(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.mpz, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr %6, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call i32 @mp_int_compare_zero(ptr noundef %12)
  %14 = icmp eq i32 %13, 0
  %15 = zext i1 %14 to i32
  store i32 %15, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @mp_int_compare_zero(ptr noundef %16)
  %18 = icmp eq i32 %17, 0
  %19 = zext i1 %18 to i32
  store i32 %19, ptr %10, align 4, !tbaa !9
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %2
  %23 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %23, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %49

24:                                               ; preds = %2
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i32 @mp_int_init(ptr noundef %25)
  %27 = load i32, ptr @MP_OK, align 4, !tbaa !9
  %28 = icmp eq i32 %26, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  br i1 true, label %30, label %31

30:                                               ; preds = %29
  br label %32

31:                                               ; preds = %29, %24
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.2, i32 noundef 219, ptr noundef @__PRETTY_FUNCTION__.impz_divisible_p) #5
  unreachable

32:                                               ; preds = %30
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call i32 @mp_int_div(ptr noundef %33, ptr noundef %34, ptr noundef null, ptr noundef %35)
  %37 = load i32, ptr @MP_OK, align 4, !tbaa !9
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %32
  br i1 true, label %40, label %41

40:                                               ; preds = %39
  br label %42

41:                                               ; preds = %39, %32
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.2, i32 noundef 220, ptr noundef @__PRETTY_FUNCTION__.impz_divisible_p) #5
  unreachable

42:                                               ; preds = %40
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call i32 @mp_int_compare_zero(ptr noundef %43)
  %45 = icmp eq i32 %44, 0
  %46 = zext i1 %45 to i32
  store i32 %46, ptr %8, align 4, !tbaa !9
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  call void @mp_int_clear(ptr noundef %47)
  %48 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %48, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %49

49:                                               ; preds = %42, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #4
  %50 = load i32, ptr %3, align 4
  ret i32 %50
}

attributes #0 = { 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 #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 willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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, !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}


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

@MP_OK = external local_unnamed_addr constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [48 x i8], align 1
@__PRETTY_FUNCTION__.impz_divisible_p = external hidden unnamed_addr constant [37 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [65 x i8], align 1

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

declare void @mp_int_clear(ptr noundef) local_unnamed_addr #1

declare i32 @mp_int_init(ptr noundef) local_unnamed_addr #1

declare i32 @mp_int_compare_zero(ptr noundef) local_unnamed_addr #1

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

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

declare i32 @mp_int_div(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @impz_divisible_p(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.mpz, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  %4 = tail call i32 @mp_int_compare_zero(ptr noundef %0) #4
  %5 = tail call i32 @mp_int_compare_zero(ptr noundef %1) #4
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %18, label %7

7:                                                ; preds = %2
  %8 = call i32 @mp_int_init(ptr noundef nonnull %3) #4
  %9 = load i32, ptr @MP_OK, align 4, !tbaa !5
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.2, i32 noundef 219, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_divisible_p) #5
  unreachable

12:                                               ; preds = %7
  %13 = call i32 @mp_int_div(ptr noundef %0, ptr noundef %1, ptr noundef null, ptr noundef nonnull %3) #4
  %14 = icmp eq i32 %13, %8
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.2, i32 noundef 220, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_divisible_p) #5
  unreachable

16:                                               ; preds = %12
  %17 = call i32 @mp_int_compare_zero(ptr noundef nonnull %3) #4
  call void @mp_int_clear(ptr noundef nonnull %3) #4
  br label %18

18:                                               ; preds = %2, %16
  %.0.in.in = phi i32 [ %17, %16 ], [ %4, %2 ]
  %.0.in = icmp eq i32 %.0.in.in, 0
  %.0 = zext i1 %.0.in to i32
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  ret i32 %.0
}

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass