; LLVM IR from FrancesoM/Bisc8FX :: sdk_projects/bisc8_platform/ps7_cortexa9_0/standalone_domain/bsp/ps7_cortexa9_0_ (putnum)

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

; Function Attrs: nounwind uwtable
define dso_local void @putnum(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca [9 x i8], align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 9, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %15, %1
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 9
  br i1 %10, label %11, label %18

11:                                               ; preds = %8
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 %13
  store i8 48, ptr %14, align 1, !tbaa !9
  br label %15

15:                                               ; preds = %11
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %5, align 4, !tbaa !5
  br label %8, !llvm.loop !10

18:                                               ; preds = %8
  %19 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 0
  store ptr %19, ptr %6, align 8, !tbaa !12
  store i32 7, ptr %4, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %48, %18
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp sge i32 %21, 0
  br i1 %22, label %23, label %51

23:                                               ; preds = %20
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = mul i32 %25, 4
  %27 = lshr i32 %24, %26
  %28 = and i32 %27, 15
  store i32 %28, ptr %7, align 4, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp ule i32 %29, 9
  br i1 %30, label %31, label %39

31:                                               ; preds = %23
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = add i32 %32, 48
  store i32 %33, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = trunc i32 %34 to i8
  %36 = load ptr, ptr %6, align 8, !tbaa !12
  store i8 %35, ptr %36, align 1, !tbaa !9
  %37 = load ptr, ptr %6, align 8, !tbaa !12
  %38 = getelementptr inbounds i8, ptr %37, i64 1
  store ptr %38, ptr %6, align 8, !tbaa !12
  br label %47

39:                                               ; preds = %23
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = add i32 %40, 87
  store i32 %41, ptr %7, align 4, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = trunc i32 %42 to i8
  %44 = load ptr, ptr %6, align 8, !tbaa !12
  store i8 %43, ptr %44, align 1, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !12
  %46 = getelementptr inbounds i8, ptr %45, i64 1
  store ptr %46, ptr %6, align 8, !tbaa !12
  br label %47

47:                                               ; preds = %39, %31
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr %4, align 4, !tbaa !5
  br label %20, !llvm.loop !14

51:                                               ; preds = %20
  %52 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 0
  call void @print(ptr noundef %52)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 9, ptr %3) #3
  ret void
}

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

declare void @print(ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !11}


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

; Function Attrs: nounwind uwtable
define dso_local void @putnum(i32 noundef %0) local_unnamed_addr #0 {
.preheader.preheader:
  %1 = alloca [9 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %1) #3
  %2 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 48, ptr %2, align 1
  %3 = lshr i32 %0, 28
  %4 = icmp ult i32 %0, -1610612736
  %5 = trunc nuw nsw i32 %3 to i8
  %6 = add nuw nsw i8 %5, 87
  %7 = or disjoint i8 %5, 48
  %storemerge = select i1 %4, i8 %7, i8 %6
  store i8 %storemerge, ptr %1, align 1, !tbaa !5
  %.1 = getelementptr inbounds i8, ptr %1, i64 1
  %8 = insertelement <4 x i32> poison, i32 %0, i64 0
  %9 = shufflevector <4 x i32> %8, <4 x i32> poison, <4 x i32> zeroinitializer
  %10 = lshr <4 x i32> %9, <i32 24, i32 20, i32 16, i32 12>
  %11 = and <4 x i32> %10, <i32 15, i32 15, i32 15, i32 15>
  %12 = icmp ult <4 x i32> %11, <i32 10, i32 10, i32 10, i32 10>
  %13 = trunc nuw nsw <4 x i32> %11 to <4 x i8>
  %14 = add nuw nsw <4 x i8> %13, <i8 87, i8 87, i8 87, i8 87>
  %15 = or disjoint <4 x i8> %13, <i8 48, i8 48, i8 48, i8 48>
  %16 = select <4 x i1> %12, <4 x i8> %15, <4 x i8> %14
  store <4 x i8> %16, ptr %.1, align 1, !tbaa !5
  %.1.4 = getelementptr inbounds i8, ptr %1, i64 5
  %17 = lshr i32 %0, 8
  %18 = and i32 %17, 15
  %19 = icmp ult i32 %18, 10
  %20 = trunc nuw nsw i32 %18 to i8
  %21 = add nuw nsw i8 %20, 87
  %22 = or disjoint i8 %20, 48
  %storemerge.5 = select i1 %19, i8 %22, i8 %21
  store i8 %storemerge.5, ptr %.1.4, align 1, !tbaa !5
  %.1.5 = getelementptr inbounds i8, ptr %1, i64 6
  %23 = lshr i32 %0, 4
  %24 = and i32 %23, 15
  %25 = icmp ult i32 %24, 10
  %26 = trunc nuw nsw i32 %24 to i8
  %27 = add nuw nsw i8 %26, 87
  %28 = or disjoint i8 %26, 48
  %storemerge.6 = select i1 %25, i8 %28, i8 %27
  store i8 %storemerge.6, ptr %.1.5, align 1, !tbaa !5
  %.1.6 = getelementptr inbounds i8, ptr %1, i64 7
  %29 = and i32 %0, 15
  %30 = icmp ult i32 %29, 10
  %31 = trunc nuw nsw i32 %29 to i8
  %32 = add nuw nsw i8 %31, 87
  %33 = or disjoint i8 %31, 48
  %storemerge.7 = select i1 %30, i8 %33, i8 %32
  store i8 %storemerge.7, ptr %.1.6, align 1, !tbaa !5
  call void @print(ptr noundef nonnull %1) #3
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %1) #3
  ret void
}

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

declare void @print(ptr noundef) local_unnamed_addr #2

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

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


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