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

; 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.XUsbPs = type { %struct.XUsbPs_SetupData, %struct.XUsbPs_Config, i32, ptr, %struct.XUsbPs_DeviceConfig, ptr, ptr, i32, ptr, i8, ptr }
%struct.XUsbPs_SetupData = type { i8, i8, i16, i16, i16 }
%struct.XUsbPs_Config = type { i16, i32 }
%struct.XUsbPs_DeviceConfig = type { i8, [12 x %struct.XUsbPs_EpConfig], i32, [12 x %struct.XUsbPs_Endpoint], i32 }
%struct.XUsbPs_EpConfig = type { %struct.XUsbPs_EpSetup, %struct.XUsbPs_EpSetup }
%struct.XUsbPs_EpSetup = type { i32, i32, i32, i16 }
%struct.XUsbPs_Endpoint = type { %struct.XUsbPs_EpOut, %struct.XUsbPs_EpIn }
%struct.XUsbPs_EpOut = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i8, i32 }
%struct.XUsbPs_EpIn = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32 }

@Xil_AssertStatus = external global i32, align 4
@.str = external hidden unnamed_addr constant [171 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 void @Xil_Assert(ptr 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: nounwind uwtable
define dso_local i32 @XUsbPs_EpSetHandler(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i8 %1, ptr %8, align 1, !tbaa !9
  store i8 %2, ptr %9, align 1, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %5
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %18

17:                                               ; preds = %5
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 678)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %69

18:                                               ; preds = %16
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %23

22:                                               ; preds = %18
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 679)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %69

23:                                               ; preds = %21
  %24 = load i8, ptr %8, align 1, !tbaa !9
  %25 = zext i8 %24 to i32
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.XUsbPs, ptr %26, i32 0, i32 4
  %28 = getelementptr inbounds %struct.XUsbPs_DeviceConfig, ptr %27, i32 0, i32 0
  %29 = load i8, ptr %28, align 8, !tbaa !12
  %30 = zext i8 %29 to i32
  %31 = icmp slt i32 %25, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %23
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !10
  br label %34

33:                                               ; preds = %23
  call void @Xil_Assert(ptr noundef @.str, i32 noundef 680)
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !10
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %69

34:                                               ; preds = %32
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.XUsbPs, ptr %35, i32 0, i32 4
  %37 = getelementptr inbounds %struct.XUsbPs_DeviceConfig, ptr %36, i32 0, i32 3
  %38 = load i8, ptr %8, align 1, !tbaa !9
  %39 = zext i8 %38 to i64
  %40 = getelementptr inbounds [12 x %struct.XUsbPs_Endpoint], ptr %37, i64 0, i64 %39
  store ptr %40, ptr %12, align 8, !tbaa !5
  %41 = load i8, ptr %9, align 1, !tbaa !9
  %42 = zext i8 %41 to i32
  %43 = and i32 %42, 2
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %54

45:                                               ; preds = %34
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.XUsbPs_Endpoint, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.XUsbPs_EpOut, ptr %48, i32 0, i32 4
  store ptr %46, ptr %49, align 8, !tbaa !18
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.XUsbPs_Endpoint, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.XUsbPs_EpOut, ptr %52, i32 0, i32 6
  store ptr %50, ptr %53, align 8, !tbaa !22
  br label %54

54:                                               ; preds = %45, %34
  %55 = load i8, ptr %9, align 1, !tbaa !9
  %56 = zext i8 %55 to i32
  %57 = and i32 %56, 1
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %68

59:                                               ; preds = %54
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.XUsbPs_Endpoint, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct.XUsbPs_EpIn, ptr %62, i32 0, i32 4
  store ptr %60, ptr %63, align 8, !tbaa !23
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.XUsbPs_Endpoint, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.XUsbPs_EpIn, ptr %66, i32 0, i32 6
  store ptr %64, ptr %67, align 8, !tbaa !24
  br label %68

68:                                               ; preds = %59, %54
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %69

69:                                               ; preds = %68, %33, %22, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %70 = load i32, ptr %6, align 4
  ret i32 %70
}

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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !7, i64 32}
!13 = !{!"", !14, i64 0, !16, i64 8, !11, i64 16, !6, i64 24, !17, i64 32, !6, i64 2352, !6, i64 2360, !11, i64 2368, !6, i64 2376, !7, i64 2384, !6, i64 2392}
!14 = !{!"", !7, i64 0, !7, i64 1, !15, i64 2, !15, i64 4, !15, i64 6}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !15, i64 0, !11, i64 4}
!17 = !{!"", !7, i64 0, !7, i64 4, !11, i64 388, !7, i64 392, !11, i64 2312}
!18 = !{!19, !6, i64 32}
!19 = !{!"", !20, i64 0, !21, i64 80}
!20 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !6, i64 64, !7, i64 72, !11, i64 76}
!21 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !6, i64 64, !11, i64 72}
!22 = !{!19, !6, i64 48}
!23 = !{!19, !6, i64 112}
!24 = !{!19, !6, i64 128}


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

%struct.XUsbPs_Endpoint = type { %struct.XUsbPs_EpOut, %struct.XUsbPs_EpIn }
%struct.XUsbPs_EpOut = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i8, i32 }
%struct.XUsbPs_EpIn = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32 }

@Xil_AssertStatus = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [171 x i8], align 1

declare void @Xil_Assert(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @XUsbPs_EpSetHandler(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %5
  store i32 0, ptr @Xil_AssertStatus, align 4, !tbaa !5
  %.not17 = icmp eq ptr %3, null
  br i1 %.not17, label %12, label %8

7:                                                ; preds = %5
  tail call void @Xil_Assert(ptr noundef nonnull @.str, i32 noundef 678) #2
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !5
  br label %28

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i8, ptr %9, align 8, !tbaa !9
  %11 = icmp ugt i8 %10, %1
  br i1 %11, label %13, label %19

12:                                               ; preds = %6
  tail call void @Xil_Assert(ptr noundef nonnull @.str, i32 noundef 679) #2
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !5
  br label %28

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %0, i64 424
  %15 = zext i8 %1 to i64
  %16 = getelementptr inbounds [12 x %struct.XUsbPs_Endpoint], ptr %14, i64 0, i64 %15
  %17 = zext i8 %2 to i32
  %18 = and i32 %17, 2
  %.not18 = icmp eq i32 %18, 0
  br i1 %.not18, label %23, label %20

19:                                               ; preds = %8
  tail call void @Xil_Assert(ptr noundef nonnull @.str, i32 noundef 680) #2
  store i32 1, ptr @Xil_AssertStatus, align 4, !tbaa !5
  br label %28

20:                                               ; preds = %13
  %21 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %3, ptr %21, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %16, i64 48
  store ptr %4, ptr %22, align 8, !tbaa !20
  br label %23

23:                                               ; preds = %20, %13
  %24 = and i32 %17, 1
  %.not19 = icmp eq i32 %24, 0
  br i1 %.not19, label %28, label %25

25:                                               ; preds = %23
  %26 = getelementptr inbounds i8, ptr %16, i64 112
  store ptr %3, ptr %26, align 8, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %16, i64 128
  store ptr %4, ptr %27, align 8, !tbaa !22
  br label %28

28:                                               ; preds = %23, %25, %19, %12, %7
  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 = { 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 }

!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 = !{!10, !7, i64 32}
!10 = !{!"", !11, i64 0, !13, i64 8, !6, i64 16, !14, i64 24, !15, i64 32, !14, i64 2352, !14, i64 2360, !6, i64 2368, !14, i64 2376, !7, i64 2384, !14, i64 2392}
!11 = !{!"", !7, i64 0, !7, i64 1, !12, i64 2, !12, i64 4, !12, i64 6}
!12 = !{!"short", !7, i64 0}
!13 = !{!"", !12, i64 0, !6, i64 4}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 4, !6, i64 388, !7, i64 392, !6, i64 2312}
!16 = !{!17, !14, i64 32}
!17 = !{!"", !18, i64 0, !19, i64 80}
!18 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !6, i64 56, !6, i64 60, !14, i64 64, !7, i64 72, !6, i64 76}
!19 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !6, i64 56, !6, i64 60, !14, i64 64, !6, i64 72}
!20 = !{!17, !14, i64 48}
!21 = !{!17, !14, i64 112}
!22 = !{!17, !14, i64 128}


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