; LLVM IR from asllop/AppOS :: net/ipv4 (ipv4_internal)

; 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.NetIfaceStruct = type { i32, i8, i16, i8, i32, i32, i32, [128 x ptr], %struct.NetFragStruct, %struct.NetFragStruct }
%struct.NetFragStruct = type { i16, i8, [32 x ptr] }

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @ipv4_fragment_present(ptr noundef %0, i16 noundef zeroext %1) #0 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.NetIfaceStruct, ptr %6, i32 0, i32 3
  %8 = load i8, ptr %7, align 8, !tbaa !11
  %9 = zext i8 %8 to i32
  %10 = and i32 %9, 1
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %23

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.NetIfaceStruct, ptr %13, i32 0, i32 8
  %15 = getelementptr inbounds %struct.NetFragStruct, ptr %14, i32 0, i32 0
  %16 = load i16, ptr %15, align 8, !tbaa !15
  %17 = zext i16 %16 to i32
  %18 = load i16, ptr %5, align 2, !tbaa !9
  %19 = zext i16 %18 to i32
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %12
  store i8 1, ptr %3, align 1
  br label %43

22:                                               ; preds = %12
  br label %42

23:                                               ; preds = %2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.NetIfaceStruct, ptr %24, i32 0, i32 3
  %26 = load i8, ptr %25, align 8, !tbaa !11
  %27 = zext i8 %26 to i32
  %28 = and i32 %27, 2
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %41

30:                                               ; preds = %23
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.NetIfaceStruct, ptr %31, i32 0, i32 9
  %33 = getelementptr inbounds %struct.NetFragStruct, ptr %32, i32 0, i32 0
  %34 = load i16, ptr %33, align 8, !tbaa !16
  %35 = zext i16 %34 to i32
  %36 = load i16, ptr %5, align 2, !tbaa !9
  %37 = zext i16 %36 to i32
  %38 = icmp eq i32 %35, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %30
  store i8 2, ptr %3, align 1
  br label %43

40:                                               ; preds = %30
  br label %41

41:                                               ; preds = %40, %23
  br label %42

42:                                               ; preds = %41, %22
  store i8 0, ptr %3, align 1
  br label %43

43:                                               ; preds = %42, %39, %21
  %44 = load i8, ptr %3, align 1
  ret i8 %44
}

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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !7, i64 8}
!12 = !{!"NetIfaceStruct", !13, i64 0, !7, i64 4, !10, i64 6, !7, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !7, i64 24, !14, i64 1048, !14, i64 1312}
!13 = !{!"int", !7, i64 0}
!14 = !{!"NetFragStruct", !10, i64 0, !7, i64 2, !7, i64 8}
!15 = !{!12, !10, i64 1048}
!16 = !{!12, !10, i64 1312}


; 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, 3) i8 @ipv4_fragment_present(ptr nocapture noundef readonly %0, i16 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i8, ptr %3, align 8, !tbaa !5
  %5 = zext i8 %4 to i32
  %6 = and i32 %5, 1
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %11, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 1048
  %9 = load i16, ptr %8, align 8, !tbaa !12
  %10 = icmp eq i16 %9, %1
  br i1 %10, label %18, label %17

11:                                               ; preds = %2
  %12 = and i32 %5, 2
  %.not6 = icmp eq i32 %12, 0
  br i1 %.not6, label %17, label %13

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %0, i64 1312
  %15 = load i16, ptr %14, align 8, !tbaa !13
  %16 = icmp eq i16 %15, %1
  br i1 %16, label %18, label %17

17:                                               ; preds = %11, %13, %7
  br label %18

18:                                               ; preds = %13, %7, %17
  %.0 = phi i8 [ 0, %17 ], [ 1, %7 ], [ 2, %13 ]
  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, !8, i64 8}
!6 = !{!"NetIfaceStruct", !7, i64 0, !8, i64 4, !10, i64 6, !8, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24, !11, i64 1048, !11, i64 1312}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"NetFragStruct", !10, i64 0, !8, i64 2, !8, i64 8}
!12 = !{!6, !10, i64 1048}
!13 = !{!6, !10, i64 1312}


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