; LLVM IR from stillwater-sc/universal :: c_api/shim/test/posit (exact_test)

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

%"class.std::linear_congruential_engine" = type { i64 }

@.str.1 = external hidden unnamed_addr constant [21 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: mustprogress uwtable
declare dso_local noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::linear_congruential_engine", align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @_ZNSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %17, %0
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  store i32 2, ptr %6, align 4
  br label %20

12:                                               ; preds = %7
  %13 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef %3)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  store i32 1, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %20

16:                                               ; preds = %12
  br label %17

17:                                               ; preds = %16
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !11

20:                                               ; preds = %15, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %21 = load i32, ptr %6, align 4
  switch i32 %21, label %28 [
    i32 2, label %22
  ]

22:                                               ; preds = %20
  %23 = load i64, ptr %3, align 8, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = sdiv i64 %23, %25
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %26)
  store i32 0, ptr %6, align 4
  br label %28

28:                                               ; preds = %22, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %29 = load i32, ptr %6, align 4
  switch i32 %29, label %32 [
    i32 0, label %30
    i32 1, label %30
  ]

30:                                               ; preds = %28, %28
  %31 = load i32, ptr %1, align 4
  ret i32 %31

32:                                               ; preds = %28
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { "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 = { mustprogress norecurse 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

%"class.std::linear_congruential_engine" = type { i64 }

@.str.1 = external hidden unnamed_addr constant [21 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: mustprogress uwtable
declare dso_local noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef range(i32 0, 2) i32 @main() local_unnamed_addr #3 {
  %1 = alloca %"class.std::linear_congruential_engine", align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @_ZNSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  %3 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %.loopexit

4:                                                ; preds = %0
  %5 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.1 = icmp eq i32 %5, 0
  br i1 %.not.1, label %6, label %.loopexit

6:                                                ; preds = %4
  %7 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.2 = icmp eq i32 %7, 0
  br i1 %.not.2, label %8, label %.loopexit

8:                                                ; preds = %6
  %9 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.3 = icmp eq i32 %9, 0
  br i1 %.not.3, label %10, label %.loopexit

10:                                               ; preds = %8
  %11 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.4 = icmp eq i32 %11, 0
  br i1 %.not.4, label %12, label %.loopexit

12:                                               ; preds = %10
  %13 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.5 = icmp eq i32 %13, 0
  br i1 %.not.5, label %14, label %.loopexit

14:                                               ; preds = %12
  %15 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.6 = icmp eq i32 %15, 0
  br i1 %.not.6, label %16, label %.loopexit

16:                                               ; preds = %14
  %17 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.7 = icmp eq i32 %17, 0
  br i1 %.not.7, label %18, label %.loopexit

18:                                               ; preds = %16
  %19 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.8 = icmp eq i32 %19, 0
  br i1 %.not.8, label %20, label %.loopexit

20:                                               ; preds = %18
  %21 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.9 = icmp eq i32 %21, 0
  br i1 %.not.9, label %22, label %.loopexit

22:                                               ; preds = %20
  %23 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.10 = icmp eq i32 %23, 0
  br i1 %.not.10, label %24, label %.loopexit

24:                                               ; preds = %22
  %25 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.11 = icmp eq i32 %25, 0
  br i1 %.not.11, label %26, label %.loopexit

26:                                               ; preds = %24
  %27 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.12 = icmp eq i32 %27, 0
  br i1 %.not.12, label %28, label %.loopexit

28:                                               ; preds = %26
  %29 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.13 = icmp eq i32 %29, 0
  br i1 %.not.13, label %30, label %.loopexit

30:                                               ; preds = %28
  %31 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.14 = icmp eq i32 %31, 0
  br i1 %.not.14, label %32, label %.loopexit

32:                                               ; preds = %30
  %33 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.15 = icmp eq i32 %33, 0
  br i1 %.not.15, label %34, label %.loopexit

34:                                               ; preds = %32
  %35 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.16 = icmp eq i32 %35, 0
  br i1 %.not.16, label %36, label %.loopexit

36:                                               ; preds = %34
  %37 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.17 = icmp eq i32 %37, 0
  br i1 %.not.17, label %38, label %.loopexit

38:                                               ; preds = %36
  %39 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.18 = icmp eq i32 %39, 0
  br i1 %.not.18, label %40, label %.loopexit

40:                                               ; preds = %38
  %41 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.19 = icmp eq i32 %41, 0
  br i1 %.not.19, label %42, label %.loopexit

42:                                               ; preds = %40
  %43 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.20 = icmp eq i32 %43, 0
  br i1 %.not.20, label %44, label %.loopexit

44:                                               ; preds = %42
  %45 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.21 = icmp eq i32 %45, 0
  br i1 %.not.21, label %46, label %.loopexit

46:                                               ; preds = %44
  %47 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.22 = icmp eq i32 %47, 0
  br i1 %.not.22, label %48, label %.loopexit

48:                                               ; preds = %46
  %49 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.23 = icmp eq i32 %49, 0
  br i1 %.not.23, label %50, label %.loopexit

50:                                               ; preds = %48
  %51 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.24 = icmp eq i32 %51, 0
  br i1 %.not.24, label %52, label %.loopexit

52:                                               ; preds = %50
  %53 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.25 = icmp eq i32 %53, 0
  br i1 %.not.25, label %54, label %.loopexit

54:                                               ; preds = %52
  %55 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.26 = icmp eq i32 %55, 0
  br i1 %.not.26, label %56, label %.loopexit

56:                                               ; preds = %54
  %57 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.27 = icmp eq i32 %57, 0
  br i1 %.not.27, label %58, label %.loopexit

58:                                               ; preds = %56
  %59 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.28 = icmp eq i32 %59, 0
  br i1 %.not.28, label %60, label %.loopexit

60:                                               ; preds = %58
  %61 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.29 = icmp eq i32 %61, 0
  br i1 %.not.29, label %62, label %.loopexit

62:                                               ; preds = %60
  %63 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.30 = icmp eq i32 %63, 0
  br i1 %.not.30, label %64, label %.loopexit

64:                                               ; preds = %62
  %65 = call noundef i32 @_Z7testrunRSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEPm(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %2)
  %.not.31 = icmp eq i32 %65, 0
  br i1 %.not.31, label %66, label %.loopexit

66:                                               ; preds = %64
  %67 = load i64, ptr %2, align 8, !tbaa !5
  %68 = sdiv i64 %67, 32
  %69 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %68)
  br label %.loopexit

.loopexit:                                        ; preds = %0, %4, %6, %8, %10, %12, %14, %16, %18, %20, %22, %24, %26, %28, %30, %32, %34, %36, %38, %40, %42, %44, %46, %48, %50, %52, %54, %56, %58, %60, %62, %64, %66
  %.079 = phi i32 [ 0, %66 ], [ 1, %64 ], [ 1, %62 ], [ 1, %60 ], [ 1, %58 ], [ 1, %56 ], [ 1, %54 ], [ 1, %52 ], [ 1, %50 ], [ 1, %48 ], [ 1, %46 ], [ 1, %44 ], [ 1, %42 ], [ 1, %40 ], [ 1, %38 ], [ 1, %36 ], [ 1, %34 ], [ 1, %32 ], [ 1, %30 ], [ 1, %28 ], [ 1, %26 ], [ 1, %24 ], [ 1, %22 ], [ 1, %20 ], [ 1, %18 ], [ 1, %16 ], [ 1, %14 ], [ 1, %12 ], [ 1, %10 ], [ 1, %8 ], [ 1, %6 ], [ 1, %4 ], [ 1, %0 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 %.079
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt26linear_congruential_engineImLm16807ELm0ELm2147483647EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { nofree 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 #3 = { mustprogress norecurse 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 }

!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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass