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

@MP_OK = external constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [59 x i8], align 1
@__PRETTY_FUNCTION__.impz_lcm = external hidden unnamed_addr constant [38 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [54 x i8], align 1

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

declare i32 @mp_int_abs(ptr noundef, 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 void @mp_int_zero(ptr noundef) #1

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

20:                                               ; preds = %3
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %25

23:                                               ; preds = %20, %3
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mp_int_zero(ptr noundef %24)
  store i32 1, ptr %9, align 4
  br label %45

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call i32 @mp_int_lcm(ptr noundef %26, ptr noundef %27, ptr noundef %28)
  %30 = load i32, ptr @MP_OK, align 4, !tbaa !9
  %31 = icmp eq i32 %29, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %25
  br i1 true, label %33, label %34

33:                                               ; preds = %32
  br label %35

34:                                               ; preds = %32, %25
  call void @__assert_fail(ptr noundef @.str.35, ptr noundef @.str.2, i32 noundef 503, ptr noundef @__PRETTY_FUNCTION__.impz_lcm) #5
  unreachable

35:                                               ; preds = %33
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call i32 @mp_int_abs(ptr noundef %36, ptr noundef %37)
  %39 = load i32, ptr @MP_OK, align 4, !tbaa !9
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %35
  br i1 true, label %42, label %43

42:                                               ; preds = %41
  br label %44

43:                                               ; preds = %41, %35
  call void @__assert_fail(ptr noundef @.str.36, ptr noundef @.str.2, i32 noundef 504, ptr noundef @__PRETTY_FUNCTION__.impz_lcm) #5
  unreachable

44:                                               ; preds = %42
  store i32 0, ptr %9, align 4
  br label %45

45:                                               ; preds = %44, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %46 = load i32, ptr %9, align 4
  switch i32 %46, label %48 [
    i32 0, label %47
    i32 1, label %47
  ]

47:                                               ; preds = %45, %45
  ret void

48:                                               ; preds = %45
  unreachable
}

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

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"

@MP_OK = external local_unnamed_addr constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [59 x i8], align 1
@__PRETTY_FUNCTION__.impz_lcm = external hidden unnamed_addr constant [38 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [54 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 i32 @mp_int_abs(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @mp_int_compare_zero(ptr noundef) local_unnamed_addr #1

declare void @mp_int_zero(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @impz_lcm(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = tail call i32 @mp_int_compare_zero(ptr noundef %1) #3
  %5 = icmp eq i32 %4, 0
  %6 = tail call i32 @mp_int_compare_zero(ptr noundef %2) #3
  %7 = icmp eq i32 %6, 0
  %or.cond = select i1 %5, i1 true, i1 %7
  br i1 %or.cond, label %8, label %9

8:                                                ; preds = %3
  tail call void @mp_int_zero(ptr noundef %0) #3
  br label %18

9:                                                ; preds = %3
  %10 = tail call i32 @mp_int_lcm(ptr noundef %1, ptr noundef %2, ptr noundef %0) #3
  %11 = load i32, ptr @MP_OK, align 4, !tbaa !5
  %12 = icmp eq i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.35, ptr noundef nonnull @.str.2, i32 noundef 503, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_lcm) #4
  unreachable

14:                                               ; preds = %9
  %15 = tail call i32 @mp_int_abs(ptr noundef %0, ptr noundef %0) #3
  %16 = icmp eq i32 %15, %10
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.2, i32 noundef 504, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_lcm) #4
  unreachable

18:                                               ; preds = %14, %8
  ret void
}

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

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 = { 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 #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, !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,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass