; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (Mtftp4WrqOackValid)

; 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.MTFTP4_OPTION = type { i16, i8, i32, i32, i16, i8, i32 }

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @Mtftp4WrqOackValid(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %6, i32 0, i32 6
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %9, i32 0, i32 6
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = xor i32 %11, -1
  %13 = and i32 %8, %12
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i8 0, ptr %3, align 1
  br label %50

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %17, i32 0, i32 6
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = and i32 %19, 1
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %32

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %23, i32 0, i32 0
  %25 = load i16, ptr %24, align 4, !tbaa !13
  %26 = zext i16 %25 to i32
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %27, i32 0, i32 0
  %29 = load i16, ptr %28, align 4, !tbaa !13
  %30 = zext i16 %29 to i32
  %31 = icmp sgt i32 %26, %30
  br i1 %31, label %48, label %32

32:                                               ; preds = %22, %16
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %33, i32 0, i32 6
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = and i32 %35, 2
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %49

38:                                               ; preds = %32
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %39, i32 0, i32 1
  %41 = load i8, ptr %40, align 2, !tbaa !14
  %42 = zext i8 %41 to i32
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.MTFTP4_OPTION, ptr %43, i32 0, i32 1
  %45 = load i8, ptr %44, align 2, !tbaa !14
  %46 = zext i8 %45 to i32
  %47 = icmp ne i32 %42, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %38, %22
  store i8 0, ptr %3, align 1
  br label %50

49:                                               ; preds = %38, %32
  store i8 1, ptr %3, align 1
  br label %50

50:                                               ; preds = %49, %48, %15
  %51 = load i8, ptr %3, align 1
  ret i8 %51
}

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

!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, !12, i64 16}
!10 = !{!"", !11, i64 0, !7, i64 2, !12, i64 4, !12, i64 8, !11, i64 12, !7, i64 14, !12, i64 16}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !7, i64 2}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local zeroext range(i8 0, 2) i8 @Mtftp4WrqOackValid(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = xor i32 %6, -1
  %8 = and i32 %4, %7
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %23

9:                                                ; preds = %2
  %10 = and i32 %4, 1
  %.not8 = icmp eq i32 %10, 0
  br i1 %.not8, label %15, label %11

11:                                               ; preds = %9
  %12 = load i16, ptr %0, align 4, !tbaa !11
  %13 = load i16, ptr %1, align 4, !tbaa !11
  %14 = icmp ugt i16 %12, %13
  br i1 %14, label %23, label %15

15:                                               ; preds = %11, %9
  %16 = and i32 %4, 2
  %.not9 = icmp eq i32 %16, 0
  br i1 %.not9, label %22, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 2
  %19 = load i8, ptr %18, align 2, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %1, i64 2
  %21 = load i8, ptr %20, align 2, !tbaa !12
  %.not10 = icmp eq i8 %19, %21
  br i1 %.not10, label %22, label %23

22:                                               ; preds = %17, %15
  br label %23

23:                                               ; preds = %11, %17, %2, %22
  %.0 = phi i8 [ 1, %22 ], [ 0, %2 ], [ 0, %17 ], [ 0, %11 ]
  ret i8 %.0
}

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

!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, !10, i64 16}
!6 = !{!"", !7, i64 0, !8, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !8, i64 14, !10, i64 16}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !8, i64 2}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass