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

; 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.XSdPs = type { %struct.XSdPs_Config, i32, i32, i32, i32, i8, i8, i8, i8, i32, i8, [4 x i32], i32, [4 x i32], i32, i32, i32, i32, i32, i64, i16, i32, i8, i32 }
%struct.XSdPs_Config = type { i16, i32, i32, i32, i32, i32, i32, i32, i8 }

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

declare i32 @XSdPs_CmdTransfer(ptr noundef, i32 noundef, i32 noundef, i32 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: inlinehint nounwind uwtable
declare hidden i32 @Xil_In32(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @XSdPs_GetCardId(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = call i32 @XSdPs_CmdTransfer(ptr noundef %4, i32 noundef 512, i32 noundef 0, i32 noundef 0)
  store i32 %5, ptr %3, align 4, !tbaa !9
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = sext i32 %6 to i64
  %8 = icmp ne i64 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %95

10:                                               ; preds = %1
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.XSdPs, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.XSdPs_Config, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = add i32 %14, 16
  %16 = zext i32 %15 to i64
  %17 = call i32 @Xil_In32(i64 noundef %16)
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.XSdPs, ptr %18, i32 0, i32 11
  %20 = getelementptr inbounds [4 x i32], ptr %19, i64 0, i64 0
  store i32 %17, ptr %20, align 8, !tbaa !9
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.XSdPs, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.XSdPs_Config, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = add i32 %24, 20
  %26 = zext i32 %25 to i64
  %27 = call i32 @Xil_In32(i64 noundef %26)
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.XSdPs, ptr %28, i32 0, i32 11
  %30 = getelementptr inbounds [4 x i32], ptr %29, i64 0, i64 1
  store i32 %27, ptr %30, align 4, !tbaa !9
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.XSdPs, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.XSdPs_Config, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = add i32 %34, 24
  %36 = zext i32 %35 to i64
  %37 = call i32 @Xil_In32(i64 noundef %36)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.XSdPs, ptr %38, i32 0, i32 11
  %40 = getelementptr inbounds [4 x i32], ptr %39, i64 0, i64 2
  store i32 %37, ptr %40, align 8, !tbaa !9
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.XSdPs, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.XSdPs_Config, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = add i32 %44, 28
  %46 = zext i32 %45 to i64
  %47 = call i32 @Xil_In32(i64 noundef %46)
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.XSdPs, ptr %48, i32 0, i32 11
  %50 = getelementptr inbounds [4 x i32], ptr %49, i64 0, i64 3
  store i32 %47, ptr %50, align 4, !tbaa !9
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.XSdPs, ptr %51, i32 0, i32 5
  %53 = load i8, ptr %52, align 4, !tbaa !16
  %54 = zext i8 %53 to i32
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %81

56:                                               ; preds = %10
  br label %57

57:                                               ; preds = %75, %56
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = call i32 @XSdPs_CmdTransfer(ptr noundef %58, i32 noundef 768, i32 noundef 0, i32 noundef 0)
  store i32 %59, ptr %3, align 4, !tbaa !9
  %60 = load i32, ptr %3, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %95

64:                                               ; preds = %57
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.XSdPs, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.XSdPs_Config, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = add i32 %68, 16
  %70 = zext i32 %69 to i64
  %71 = call i32 @Xil_In32(i64 noundef %70)
  %72 = and i32 %71, -65536
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.XSdPs, ptr %73, i32 0, i32 12
  store i32 %72, ptr %74, align 8, !tbaa !17
  br label %75

75:                                               ; preds = %64
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.XSdPs, ptr %76, i32 0, i32 12
  %78 = load i32, ptr %77, align 8, !tbaa !17
  %79 = icmp eq i32 %78, 0
  br i1 %79, label %57, label %80, !llvm.loop !18

80:                                               ; preds = %75
  br label %94

81:                                               ; preds = %10
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.XSdPs, ptr %82, i32 0, i32 12
  store i32 305397760, ptr %83, align 8, !tbaa !17
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.XSdPs, ptr %85, i32 0, i32 12
  %87 = load i32, ptr %86, align 8, !tbaa !17
  %88 = call i32 @XSdPs_CmdTransfer(ptr noundef %84, i32 noundef 768, i32 noundef %87, i32 noundef 0)
  store i32 %88, ptr %3, align 4, !tbaa !9
  %89 = load i32, ptr %3, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %81
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %95

93:                                               ; preds = %81
  br label %94

94:                                               ; preds = %93, %80
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %94, %92, %63, %9
  %96 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %96
}

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 = { inlinehint 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 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"", !13, i64 0, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 52, !7, i64 53, !7, i64 54, !7, i64 55, !10, i64 56, !7, i64 60, !7, i64 64, !10, i64 80, !7, i64 84, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !15, i64 120, !14, i64 128, !10, i64 132, !7, i64 136, !10, i64 140}
!13 = !{!"", !14, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !7, i64 52}
!17 = !{!12, !10, i64 80}
!18 = distinct !{!18, !19}
!19 = !{!"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"

declare i32 @XSdPs_CmdTransfer(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @Xil_In32(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @XSdPs_GetCardId(ptr noundef %0) local_unnamed_addr #2 {
  %2 = tail call i32 @XSdPs_CmdTransfer(ptr noundef %0, i32 noundef 512, i32 noundef 0, i32 noundef 0) #3
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %3, label %.loopexit

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = add i32 %5, 16
  %7 = zext i32 %6 to i64
  %8 = tail call i32 @Xil_In32(i64 noundef %7)
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %8, ptr %9, align 8, !tbaa !13
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = add i32 %10, 20
  %12 = zext i32 %11 to i64
  %13 = tail call i32 @Xil_In32(i64 noundef %12)
  %14 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 %13, ptr %14, align 4, !tbaa !13
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = add i32 %15, 24
  %17 = zext i32 %16 to i64
  %18 = tail call i32 @Xil_In32(i64 noundef %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  store i32 %18, ptr %19, align 8, !tbaa !13
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = add i32 %20, 28
  %22 = zext i32 %21 to i64
  %23 = tail call i32 @Xil_In32(i64 noundef %22)
  %24 = getelementptr inbounds i8, ptr %0, i64 76
  store i32 %23, ptr %24, align 4, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %0, i64 52
  %26 = load i8, ptr %25, align 4, !tbaa !14
  %27 = icmp eq i8 %26, 1
  %28 = getelementptr inbounds i8, ptr %0, i64 80
  br i1 %27, label %.preheader, label %37

.preheader:                                       ; preds = %3, %30
  %29 = tail call i32 @XSdPs_CmdTransfer(ptr noundef nonnull %0, i32 noundef 768, i32 noundef 0, i32 noundef 0) #3
  %.not21 = icmp eq i32 %29, 0
  br i1 %.not21, label %30, label %.loopexit

30:                                               ; preds = %.preheader
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add i32 %31, 16
  %33 = zext i32 %32 to i64
  %34 = tail call i32 @Xil_In32(i64 noundef %33)
  %35 = and i32 %34, -65536
  store i32 %35, ptr %28, align 8, !tbaa !15
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %.preheader, label %.loopexit22, !llvm.loop !16

37:                                               ; preds = %3
  store i32 305397760, ptr %28, align 8, !tbaa !15
  %38 = tail call i32 @XSdPs_CmdTransfer(ptr noundef nonnull %0, i32 noundef 768, i32 noundef 305397760, i32 noundef 0) #3
  %.not20 = icmp eq i32 %38, 0
  br i1 %.not20, label %.loopexit22, label %.loopexit

.loopexit22:                                      ; preds = %30, %37
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %37, %1, %.loopexit22
  %.0 = phi i32 [ 0, %.loopexit22 ], [ 1, %1 ], [ 1, %37 ], [ 1, %.preheader ]
  ret i32 %.0
}

attributes #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 = { inlinehint 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 #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 }

!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, !11, i64 4}
!6 = !{!"", !7, i64 0, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !9, i64 52, !9, i64 53, !9, i64 54, !9, i64 55, !11, i64 56, !9, i64 60, !9, i64 64, !11, i64 80, !9, i64 84, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !12, i64 120, !8, i64 128, !11, i64 132, !9, i64 136, !11, i64 140}
!7 = !{!"", !8, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !9, i64 32}
!8 = !{!"short", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!6, !9, i64 52}
!15 = !{!6, !11, i64 80}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass