; 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
@MP_RANGE = external constant i32, align 4
@.str.34 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__.impz_get_si = external hidden unnamed_addr constant [25 x i8], align 1
@MP_NEG = external constant i8, align 1

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @get_long_bits(ptr noundef) #2

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

14:                                               ; preds = %1
  %15 = load i64, ptr %4, align 8, !tbaa !11
  store i64 %15, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %58

16:                                               ; preds = %1
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = load i32, ptr @MP_RANGE, align 4, !tbaa !9
  %19 = icmp eq i32 %17, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %16
  %21 = load i32, ptr @MP_OK, align 4, !tbaa !9
  br label %24

22:                                               ; preds = %16
  %23 = load i32, ptr @MP_RANGE, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %22, %20
  %25 = phi i32 [ %21, %20 ], [ %23, %22 ]
  %26 = load i32, ptr @MP_OK, align 4, !tbaa !9
  %27 = icmp eq i32 %25, %26
  br i1 %27, label %28, label %30

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

29:                                               ; preds = %28
  br label %31

30:                                               ; preds = %28, %24
  call void @__assert_fail(ptr noundef @.str.34, ptr noundef @.str.2, i32 noundef 474, ptr noundef @__PRETTY_FUNCTION__.impz_get_si) #5
  unreachable

31:                                               ; preds = %29
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = load i32, ptr @MP_RANGE, align 4, !tbaa !9
  %34 = icmp ne i32 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i64 0, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %58

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = call i64 @get_long_bits(ptr noundef %37)
  store i64 %38, ptr %5, align 8, !tbaa !11
  store i32 63, ptr %6, align 4, !tbaa !9
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = shl i64 1, %40
  %42 = xor i64 %41, -1
  %43 = load i64, ptr %5, align 8, !tbaa !11
  %44 = and i64 %43, %42
  store i64 %44, ptr %5, align 8, !tbaa !11
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mpz, ptr %45, i32 0, i32 4
  %47 = load i8, ptr %46, align 8, !tbaa !13
  %48 = zext i8 %47 to i32
  %49 = load i8, ptr @MP_NEG, align 1, !tbaa !15
  %50 = zext i8 %49 to i32
  %51 = icmp eq i32 %48, %50
  br i1 %51, label %52, label %55

52:                                               ; preds = %36
  %53 = load i64, ptr %5, align 8, !tbaa !11
  %54 = sub i64 0, %53
  store i64 %54, ptr %5, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %52, %36
  %56 = load i64, ptr %5, align 8, !tbaa !11
  store i64 %56, ptr %4, align 8, !tbaa !11
  %57 = load i64, ptr %4, align 8, !tbaa !11
  store i64 %57, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %58

58:                                               ; preds = %55, %35, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %59 = load i64, ptr %2, align 8
  ret i64 %59
}

declare i32 @mp_int_to_int(ptr noundef, ptr noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !7, i64 24}
!14 = !{!"mpz", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !7, i64 24}
!15 = !{!7, !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
@MP_RANGE = external local_unnamed_addr constant i32, align 4
@.str.34 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__.impz_get_si = external hidden unnamed_addr constant [25 x i8], align 1
@MP_NEG = external local_unnamed_addr constant i8, align 1

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i64 @get_long_bits(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i64 @impz_get_si(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %3 = call i32 @mp_int_to_int(ptr noundef %0, ptr noundef nonnull %2) #4
  %4 = load i32, ptr @MP_OK, align 4
  %5 = icmp eq i32 %3, %4
  br i1 %5, label %6, label %8

6:                                                ; preds = %1
  %7 = load i64, ptr %2, align 8, !tbaa !5
  br label %23

8:                                                ; preds = %1
  %9 = load i32, ptr @MP_RANGE, align 4
  %10 = icmp eq i32 %3, %9
  %11 = icmp eq i32 %9, %4
  %12 = or i1 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  call void @__assert_fail(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.2, i32 noundef 474, ptr noundef nonnull @__PRETTY_FUNCTION__.impz_get_si) #5
  unreachable

14:                                               ; preds = %8
  br i1 %10, label %15, label %23

15:                                               ; preds = %14
  %16 = call i64 @get_long_bits(ptr noundef %0)
  %17 = and i64 %16, 9223372036854775807
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load i8, ptr %18, align 8, !tbaa !9
  %20 = load i8, ptr @MP_NEG, align 1, !tbaa !13
  %21 = icmp eq i8 %19, %20
  %22 = sub nsw i64 0, %17
  %spec.select = select i1 %21, i64 %22, i64 %17
  br label %23

23:                                               ; preds = %14, %15, %6
  %.0 = phi i64 [ %7, %6 ], [ %spec.select, %15 ], [ 0, %14 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret i64 %.0
}

declare i32 @mp_int_to_int(ptr noundef, ptr noundef) local_unnamed_addr #3

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


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