; LLVM IR from BrunoLevy/learn-fpga :: FemtoRV/SIM/FPU_funcs.ll (Z5checkPKcjjjjjibb)

; 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.IEEE754 = type { %union.anon }
%union.anon = type { i32 }

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 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

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

; 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 void @_Z6printbji(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5checkPKcjjjjjibb(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i1 noundef zeroext %7, i1 noundef zeroext %8) #2 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i8, align 1
  %19 = alloca i8, align 1
  %20 = alloca %class.IEEE754, align 4
  %21 = alloca %class.IEEE754, align 4
  %22 = alloca %class.IEEE754, align 4
  %23 = alloca %class.IEEE754, align 4
  %24 = alloca %class.IEEE754, align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !9
  store i32 %2, ptr %13, align 4, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !9
  store i32 %4, ptr %15, align 4, !tbaa !9
  store i32 %5, ptr %16, align 4, !tbaa !9
  store i32 %6, ptr %17, align 4, !tbaa !9
  %26 = zext i1 %7 to i8
  store i8 %26, ptr %18, align 1, !tbaa !11
  %27 = zext i1 %8 to i8
  store i8 %27, ptr %19, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %28 = load i32, ptr %12, align 4, !tbaa !9
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %20, i32 noundef %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %29 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %21, i32 noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %30 = load i32, ptr %14, align 4, !tbaa !9
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %22, i32 noundef %30)
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %31 = load i32, ptr %15, align 4, !tbaa !9
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %23, i32 noundef %31)
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %32 = load i32, ptr %16, align 4, !tbaa !9
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %24, i32 noundef %32)
  %33 = call noundef zeroext i1 @_ZNK7IEEE7547is_zeroEv(ptr noundef nonnull align 4 dereferenceable(4) %23)
  br i1 %33, label %34, label %36

34:                                               ; preds = %9
  %35 = call noundef zeroext i1 @_ZNK7IEEE7547is_zeroEv(ptr noundef nonnull align 4 dereferenceable(4) %24)
  br i1 %35, label %98, label %36

36:                                               ; preds = %34, %9
  %37 = load i32, ptr %15, align 4, !tbaa !9
  %38 = load i32, ptr %16, align 4, !tbaa !9
  %39 = icmp ne i32 %37, %38
  br i1 %39, label %40, label %98

40:                                               ; preds = %36
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %41)
  %43 = load i8, ptr %19, align 1, !tbaa !11, !range !13, !noundef !14
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %50

45:                                               ; preds = %40
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %47 = load i32, ptr %12, align 4, !tbaa !9
  call void @_Z6printbji(i32 noundef %47, i32 noundef 32)
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %48)
  br label %56

50:                                               ; preds = %40
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %20)
  %52 = getelementptr inbounds %class.IEEE754, ptr %20, i32 0, i32 0
  %53 = load float, ptr %52, align 4, !tbaa !15
  %54 = fpext float %53 to double
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %54)
  br label %56

56:                                               ; preds = %50, %45
  %57 = load i32, ptr %17, align 4, !tbaa !9
  %58 = icmp sge i32 %57, 2
  br i1 %58, label %59, label %65

59:                                               ; preds = %56
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %21)
  %61 = getelementptr inbounds %class.IEEE754, ptr %21, i32 0, i32 0
  %62 = load float, ptr %61, align 4, !tbaa !15
  %63 = fpext float %62 to double
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %63)
  br label %65

65:                                               ; preds = %59, %56
  %66 = load i32, ptr %17, align 4, !tbaa !9
  %67 = icmp sge i32 %66, 3
  br i1 %67, label %68, label %74

68:                                               ; preds = %65
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %22)
  %70 = getelementptr inbounds %class.IEEE754, ptr %22, i32 0, i32 0
  %71 = load float, ptr %70, align 4, !tbaa !15
  %72 = fpext float %71 to double
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %72)
  br label %74

74:                                               ; preds = %68, %65
  %75 = load i8, ptr %18, align 1, !tbaa !11, !range !13, !noundef !14
  %76 = trunc i8 %75 to i1
  br i1 %76, label %77, label %86

77:                                               ; preds = %74
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %79 = load i32, ptr %15, align 4, !tbaa !9
  call void @_Z6printbji(i32 noundef %79, i32 noundef 32)
  %80 = load i32, ptr %15, align 4, !tbaa !9
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %80)
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %83 = load i32, ptr %16, align 4, !tbaa !9
  call void @_Z6printbji(i32 noundef %83, i32 noundef 32)
  %84 = load i32, ptr %16, align 4, !tbaa !9
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %84)
  br label %97

86:                                               ; preds = %74
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %23)
  %88 = getelementptr inbounds %class.IEEE754, ptr %23, i32 0, i32 0
  %89 = load float, ptr %88, align 4, !tbaa !15
  %90 = fpext float %89 to double
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %90)
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %24)
  %93 = getelementptr inbounds %class.IEEE754, ptr %24, i32 0, i32 0
  %94 = load float, ptr %93, align 4, !tbaa !15
  %95 = fpext float %94 to double
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %95)
  br label %97

97:                                               ; preds = %86, %77
  store i32 0, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %100

98:                                               ; preds = %36, %34
  br label %99

99:                                               ; preds = %98
  store i32 1, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %100

100:                                              ; preds = %99, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  %101 = load i32, ptr %10, align 4
  ret i32 %101
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7IEEE7547is_zeroEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

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

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!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"

%class.IEEE754 = type { %union.anon }
%union.anon = type { i32 }

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; 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 void @_Z6printbji(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z5checkPKcjjjjjibb(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i1 noundef zeroext %7, i1 noundef zeroext %8) local_unnamed_addr #2 {
  %10 = alloca %class.IEEE754, align 4
  %11 = alloca %class.IEEE754, align 4
  %12 = alloca %class.IEEE754, align 4
  %13 = alloca %class.IEEE754, align 4
  %14 = alloca %class.IEEE754, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #4
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %10, i32 noundef %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #4
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #4
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef %4)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #4
  call void @_ZN7IEEE754C2Ej(ptr noundef nonnull align 4 dereferenceable(4) %14, i32 noundef %5)
  %15 = call noundef zeroext i1 @_ZNK7IEEE7547is_zeroEv(ptr noundef nonnull align 4 dereferenceable(4) %13)
  br i1 %15, label %16, label %18

16:                                               ; preds = %9
  %17 = call noundef zeroext i1 @_ZNK7IEEE7547is_zeroEv(ptr noundef nonnull align 4 dereferenceable(4) %14)
  %.not = icmp eq i32 %4, %5
  %or.cond = or i1 %.not, %17
  br i1 %or.cond, label %53, label %19

18:                                               ; preds = %9
  %.not.old = icmp eq i32 %4, %5
  br i1 %.not.old, label %53, label %19

19:                                               ; preds = %16, %18
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef %0)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br i1 %8, label %22, label %24

22:                                               ; preds = %19
  call void @_Z6printbji(i32 noundef %1, i32 noundef 32)
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %1)
  br label %28

24:                                               ; preds = %19
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %10)
  %25 = load float, ptr %10, align 4, !tbaa !5
  %26 = fpext float %25 to double
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %26)
  br label %28

28:                                               ; preds = %24, %22
  %29 = icmp sgt i32 %6, 1
  br i1 %29, label %30, label %.thread

30:                                               ; preds = %28
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %11)
  %32 = load float, ptr %11, align 4, !tbaa !5
  %33 = fpext float %32 to double
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %33)
  %.not20 = icmp eq i32 %6, 2
  br i1 %.not20, label %.thread, label %35

35:                                               ; preds = %30
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %12)
  %37 = load float, ptr %12, align 4, !tbaa !5
  %38 = fpext float %37 to double
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %38)
  br label %.thread

.thread:                                          ; preds = %28, %35, %30
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  br i1 %7, label %41, label %45

41:                                               ; preds = %.thread
  call void @_Z6printbji(i32 noundef %4, i32 noundef 32)
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %4)
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  call void @_Z6printbji(i32 noundef %5, i32 noundef 32)
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %5)
  br label %53

45:                                               ; preds = %.thread
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %13)
  %46 = load float, ptr %13, align 4, !tbaa !5
  %47 = fpext float %46 to double
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %47)
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  call void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4) %14)
  %50 = load float, ptr %14, align 4, !tbaa !5
  %51 = fpext float %50 to double
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %51)
  br label %53

53:                                               ; preds = %18, %16, %41, %45
  %.0 = phi i32 [ 0, %45 ], [ 0, %41 ], [ 1, %16 ], [ 1, %18 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #4
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7IEEE7547is_zeroEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7IEEE7545printEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass