; 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_add_new_fragment(ptr noundef %0, i16 noundef zeroext %1, ptr noundef %2) #0 {
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i16 %1, ptr %6, align 2, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.NetIfaceStruct, ptr %8, i32 0, i32 3
  %10 = load i8, ptr %9, align 8, !tbaa !11
  %11 = zext i8 %10 to i32
  %12 = and i32 %11, 1
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %35, label %14

14:                                               ; preds = %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.NetIfaceStruct, ptr %15, i32 0, i32 3
  %17 = load i8, ptr %16, align 8, !tbaa !11
  %18 = zext i8 %17 to i32
  %19 = or i32 %18, 1
  %20 = trunc i32 %19 to i8
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.NetIfaceStruct, ptr %21, i32 0, i32 3
  store i8 %20, ptr %22, align 8, !tbaa !11
  %23 = load i16, ptr %6, align 2, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.NetIfaceStruct, ptr %24, i32 0, i32 8
  %26 = getelementptr inbounds %struct.NetFragStruct, ptr %25, i32 0, i32 0
  store i16 %23, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.NetIfaceStruct, ptr %28, i32 0, i32 8
  %30 = getelementptr inbounds %struct.NetFragStruct, ptr %29, i32 0, i32 2
  %31 = getelementptr inbounds [32 x ptr], ptr %30, i64 0, i64 0
  store ptr %27, ptr %31, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.NetIfaceStruct, ptr %32, i32 0, i32 8
  %34 = getelementptr inbounds %struct.NetFragStruct, ptr %33, i32 0, i32 1
  store i8 1, ptr %34, align 2, !tbaa !16
  store i8 1, ptr %4, align 1
  br label %65

35:                                               ; preds = %3
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.NetIfaceStruct, ptr %36, i32 0, i32 3
  %38 = load i8, ptr %37, align 8, !tbaa !11
  %39 = zext i8 %38 to i32
  %40 = and i32 %39, 2
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %63, label %42

42:                                               ; preds = %35
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.NetIfaceStruct, ptr %43, i32 0, i32 3
  %45 = load i8, ptr %44, align 8, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = or i32 %46, 2
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.NetIfaceStruct, ptr %49, i32 0, i32 3
  store i8 %48, ptr %50, align 8, !tbaa !11
  %51 = load i16, ptr %6, align 2, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.NetIfaceStruct, ptr %52, i32 0, i32 9
  %54 = getelementptr inbounds %struct.NetFragStruct, ptr %53, i32 0, i32 0
  store i16 %51, ptr %54, align 8, !tbaa !17
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.NetIfaceStruct, ptr %56, i32 0, i32 9
  %58 = getelementptr inbounds %struct.NetFragStruct, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds [32 x ptr], ptr %58, i64 0, i64 0
  store ptr %55, ptr %59, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.NetIfaceStruct, ptr %60, i32 0, i32 9
  %62 = getelementptr inbounds %struct.NetFragStruct, ptr %61, i32 0, i32 1
  store i8 1, ptr %62, align 2, !tbaa !18
  store i8 1, ptr %4, align 1
  br label %65

63:                                               ; preds = %35
  br label %64

64:                                               ; preds = %63
  store i8 0, ptr %4, align 1
  br label %65

65:                                               ; preds = %64, %42, %14
  %66 = load i8, ptr %4, align 1
  ret i8 %66
}

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, !7, i64 1050}
!17 = !{!12, !10, i64 1312}
!18 = !{!12, !7, i64 1314}


; 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: readwrite) uwtable
define dso_local zeroext range(i8 0, 2) i8 @ipv4_add_new_fragment(ptr nocapture noundef %0, i16 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i8, ptr %4, align 8, !tbaa !5
  %6 = zext i8 %5 to i32
  %7 = and i32 %6, 1
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.sink.split, label %8

8:                                                ; preds = %3
  %9 = and i32 %6, 2
  %.not16 = icmp eq i32 %9, 0
  br i1 %.not16, label %.sink.split, label %14

.sink.split:                                      ; preds = %8, %3
  %.sink20 = phi i8 [ 1, %3 ], [ 2, %8 ]
  %.sink19 = phi i64 [ 1048, %3 ], [ 1312, %8 ]
  %.sink18 = phi i64 [ 1056, %3 ], [ 1320, %8 ]
  %.sink17 = phi i64 [ 1050, %3 ], [ 1314, %8 ]
  %10 = or i8 %5, %.sink20
  store i8 %10, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 %.sink19
  store i16 %1, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 %.sink18
  store ptr %2, ptr %12, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %0, i64 %.sink17
  store i8 1, ptr %13, align 2, !tbaa !15
  br label %14

14:                                               ; preds = %.sink.split, %8
  %.0 = phi i8 [ 0, %8 ], [ 1, %.sink.split ]
  ret i8 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = !{!10, !10, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!8, !8, i64 0}


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