; 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.27 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__.impz_pow_ui = external hidden unnamed_addr constant [48 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [67 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_set_value(ptr noundef, i64 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_init_uvalue(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @impz_pow_ui(ptr noundef %0, ptr noundef %1, i64 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.mpz, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr %7, ptr %8, align 8, !tbaa !5
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %25

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call i32 @mp_int_compare_zero(ptr noundef %13)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %25

16:                                               ; preds = %12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i32 @mp_int_set_value(ptr noundef %17, i64 noundef 1)
  %19 = load i32, ptr @MP_OK, align 4, !tbaa !11
  %20 = icmp eq i32 %18, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %16
  br i1 true, label %22, label %23

22:                                               ; preds = %21
  br label %24

23:                                               ; preds = %21, %16
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.2, i32 noundef 282, ptr noundef @__PRETTY_FUNCTION__.impz_pow_ui) #5
  unreachable

24:                                               ; preds = %22
  store i32 1, ptr %9, align 4
  br label %46

25:                                               ; preds = %12, %3
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = call i32 @mp_int_init_uvalue(ptr noundef %26, i64 noundef %27)
  %29 = load i32, ptr @MP_OK, align 4, !tbaa !11
  %30 = icmp eq i32 %28, %29
  br i1 %30, label %31, label %33

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

32:                                               ; preds = %31
  br label %34

33:                                               ; preds = %31, %25
  call void @__assert_fail(ptr noundef @.str.28, ptr noundef @.str.2, i32 noundef 287, ptr noundef @__PRETTY_FUNCTION__.impz_pow_ui) #5
  unreachable

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

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

42:                                               ; preds = %41
  br label %44

43:                                               ; preds = %41, %34
  call void @__assert_fail(ptr noundef @.str.29, ptr noundef @.str.2, i32 noundef 288, ptr noundef @__PRETTY_FUNCTION__.impz_pow_ui) #5
  unreachable

44:                                               ; preds = %42
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mp_int_clear(ptr noundef %45)
  store i32 0, ptr %9, align 4
  br label %46

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

48:                                               ; preds = %46, %46
  ret void

49:                                               ; preds = %46
  unreachable
}

declare i32 @mp_int_expt_full(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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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.27 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__.impz_pow_ui = external hidden unnamed_addr constant [48 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [67 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_set_value(ptr noundef, i64 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_init_uvalue(ptr noundef, i64 noundef) local_unnamed_addr #1

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

6:                                                ; preds = %3
  %7 = tail call i32 @mp_int_compare_zero(ptr noundef %1) #4
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %14

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

13:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.2, i32 noundef 282, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_pow_ui) #5
  unreachable

14:                                               ; preds = %6, %3
  %15 = call i32 @mp_int_init_uvalue(ptr noundef nonnull %4, i64 noundef %2) #4
  %16 = load i32, ptr @MP_OK, align 4, !tbaa !5
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @__assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.2, i32 noundef 287, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_pow_ui) #5
  unreachable

19:                                               ; preds = %14
  %20 = call i32 @mp_int_expt_full(ptr noundef %1, ptr noundef nonnull %4, ptr noundef %0) #4
  %21 = icmp eq i32 %20, %15
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @__assert_fail(ptr noundef nonnull @.str.29, ptr noundef nonnull @.str.2, i32 noundef 288, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_pow_ui) #5
  unreachable

23:                                               ; preds = %19
  call void @mp_int_clear(ptr noundef nonnull %4) #4
  br label %24

24:                                               ; preds = %9, %23
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  ret void
}

declare i32 @mp_int_expt_full(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 = { 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,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass