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

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

@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [54 x i8], align 1
@__PRETTY_FUNCTION__.mp_int_expt_full = external hidden unnamed_addr constant [51 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_init_copy(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_set_value(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mp_int_clear(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_mul(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_sqr(ptr noundef, ptr noundef) #2

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

16:                                               ; preds = %3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %23

19:                                               ; preds = %16
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19, %16, %3
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 1062, ptr noundef @__PRETTY_FUNCTION__.mp_int_expt_full) #4
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mpz, ptr %25, i32 0, i32 4
  %27 = load i8, ptr %26, align 8, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  store i32 -3, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %100

31:                                               ; preds = %24
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i32 @mp_int_init_copy(ptr noundef %8, ptr noundef %32)
  store i32 %33, ptr %9, align 4, !tbaa !12
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  %36 = load i32, ptr %9, align 4, !tbaa !12
  store i32 %36, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %100

37:                                               ; preds = %31
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = call i32 @mp_int_set_value(ptr noundef %38, i64 noundef 1)
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %40

40:                                               ; preds = %94, %37
  %41 = load i32, ptr %10, align 4, !tbaa !12
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.mpz, ptr %42, i32 0, i32 3
  %44 = load i32, ptr %43, align 4, !tbaa !13
  %45 = icmp ult i32 %41, %44
  br i1 %45, label %46, label %97

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mpz, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = load i32, ptr %10, align 4, !tbaa !12
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %49, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !12
  store i32 %53, ptr %13, align 4, !tbaa !12
  store i32 0, ptr %11, align 4, !tbaa !12
  br label %54

54:                                               ; preds = %87, %46
  %55 = load i32, ptr %11, align 4, !tbaa !12
  %56 = zext i32 %55 to i64
  %57 = icmp ult i64 %56, 32
  br i1 %57, label %58, label %90

58:                                               ; preds = %54
  %59 = load i32, ptr %13, align 4, !tbaa !12
  %60 = and i32 %59, 1
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %69

62:                                               ; preds = %58
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call i32 @mp_int_mul(ptr noundef %63, ptr noundef %8, ptr noundef %64)
  store i32 %65, ptr %9, align 4, !tbaa !12
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  store i32 8, ptr %12, align 4
  br label %91

68:                                               ; preds = %62
  br label %69

69:                                               ; preds = %68, %58
  %70 = load i32, ptr %13, align 4, !tbaa !12
  %71 = lshr i32 %70, 1
  store i32 %71, ptr %13, align 4, !tbaa !12
  %72 = load i32, ptr %13, align 4, !tbaa !12
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %82

74:                                               ; preds = %69
  %75 = load i32, ptr %10, align 4, !tbaa !12
  %76 = add i32 %75, 1
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mpz, ptr %77, i32 0, i32 3
  %79 = load i32, ptr %78, align 4, !tbaa !13
  %80 = icmp eq i32 %76, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %74
  br label %90

82:                                               ; preds = %74, %69
  %83 = call i32 @mp_int_sqr(ptr noundef %8, ptr noundef %8)
  store i32 %83, ptr %9, align 4, !tbaa !12
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %82
  store i32 8, ptr %12, align 4
  br label %91

86:                                               ; preds = %82
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %11, align 4, !tbaa !12
  %89 = add i32 %88, 1
  store i32 %89, ptr %11, align 4, !tbaa !12
  br label %54, !llvm.loop !15

90:                                               ; preds = %81, %54
  store i32 0, ptr %12, align 4
  br label %91

91:                                               ; preds = %90, %85, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  %92 = load i32, ptr %12, align 4
  switch i32 %92, label %100 [
    i32 0, label %93
    i32 8, label %98
  ]

93:                                               ; preds = %91
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %10, align 4, !tbaa !12
  %96 = add i32 %95, 1
  store i32 %96, ptr %10, align 4, !tbaa !12
  br label %40, !llvm.loop !17

97:                                               ; preds = %40
  br label %98

98:                                               ; preds = %97, %91
  call void @mp_int_clear(ptr noundef %8)
  %99 = load i32, ptr %9, align 4, !tbaa !12
  store i32 %99, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %100

100:                                              ; preds = %98, %91, %35, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #3
  %101 = load i32, ptr %4, align 4
  ret i32 %101
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 24}
!10 = !{!"mpz", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !7, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 20}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [54 x i8], align 1
@__PRETTY_FUNCTION__.mp_int_expt_full = external hidden unnamed_addr constant [51 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_init_copy(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_set_value(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @mp_int_clear(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mp_int_sqr(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mp_int_expt_full(ptr noundef %0, ptr noundef readonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.mpz, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #3
  %5 = icmp ne ptr %0, null
  %6 = icmp ne ptr %1, null
  %or.cond = and i1 %5, %6
  %7 = icmp ne ptr %2, null
  %or.cond3 = and i1 %or.cond, %7
  br i1 %or.cond3, label %9, label %8

8:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 1062, ptr noundef nonnull @__PRETTY_FUNCTION__.mp_int_expt_full) #4
  unreachable

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load i8, ptr %10, align 8, !tbaa !5
  %12 = icmp eq i8 %11, 1
  br i1 %12, label %40, label %13

13:                                               ; preds = %9
  %14 = call i32 @mp_int_init_copy(ptr noundef nonnull %4, ptr noundef nonnull %0)
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %40

15:                                               ; preds = %13
  %16 = call i32 @mp_int_set_value(ptr noundef nonnull %2, i64 noundef 1)
  %17 = getelementptr inbounds i8, ptr %1, i64 20
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %.not52 = icmp eq i32 %18, 0
  br i1 %.not52, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %15
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  br label %20

20:                                               ; preds = %.lr.ph, %split
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %split ]
  %21 = load ptr, ptr %19, align 8, !tbaa !12
  %22 = getelementptr inbounds i32, ptr %21, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br label %26

24:                                               ; preds = %37
  %25 = add nuw nsw i32 %.02749, 1
  %exitcond.not = icmp eq i32 %25, 32
  br i1 %exitcond.not, label %._crit_edge, label %26, !llvm.loop !14

._crit_edge:                                      ; preds = %24
  %.pre = load i32, ptr %17, align 4, !tbaa !11
  %.pre55 = zext i32 %.pre to i64
  br label %split

26:                                               ; preds = %20, %24
  %.050 = phi i32 [ %23, %20 ], [ %31, %24 ]
  %.02749 = phi i32 [ 0, %20 ], [ %25, %24 ]
  %27 = and i32 %.050, 1
  %.not40 = icmp eq i32 %27, 0
  br i1 %.not40, label %30, label %28

28:                                               ; preds = %26
  %29 = call i32 @mp_int_mul(ptr noundef nonnull %2, ptr noundef nonnull %4, ptr noundef nonnull %2)
  %.not41 = icmp eq i32 %29, 0
  br i1 %.not41, label %30, label %.loopexit

30:                                               ; preds = %28, %26
  %31 = lshr i32 %.050, 1
  %32 = icmp ult i32 %.050, 2
  br i1 %32, label %33, label %37

33:                                               ; preds = %30
  %34 = load i32, ptr %17, align 4, !tbaa !11
  %35 = zext i32 %34 to i64
  %36 = icmp eq i64 %indvars.iv.next, %35
  br i1 %36, label %split, label %37

37:                                               ; preds = %33, %30
  %38 = call i32 @mp_int_sqr(ptr noundef nonnull %4, ptr noundef nonnull %4)
  %.not42 = icmp eq i32 %38, 0
  br i1 %.not42, label %24, label %.loopexit

split:                                            ; preds = %33, %._crit_edge
  %.pre-phi = phi i64 [ %.pre55, %._crit_edge ], [ %35, %33 ]
  %39 = icmp ult i64 %indvars.iv.next, %.pre-phi
  br i1 %39, label %20, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %split, %28, %37, %15
  %.5 = phi i32 [ 0, %15 ], [ %38, %37 ], [ %29, %28 ], [ 0, %split ]
  call void @mp_int_clear(ptr noundef nonnull %4)
  br label %40

40:                                               ; preds = %13, %9, %.loopexit
  %.030 = phi i32 [ %.5, %.loopexit ], [ -3, %9 ], [ %14, %13 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #3
  ret i32 %.030
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !8, i64 24}
!6 = !{!"mpz", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !8, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 20}
!12 = !{!6, !10, i64 8}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass