; LLVM IR from whoiswelliton/Computer_Engineering_UTFPR-PB :: Embedded_Systems/TIVA Connected TM4C1294XL Projects/01 - lwIP_HTTPServer_on_TIVA (netif)

; 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.etharp_entry = type { ptr, %struct.ip4_addr, ptr, %struct.eth_addr, i16, i8 }
%struct.ip4_addr = type { i32 }
%struct.eth_addr = type { [6 x i8] }

@arp_table = external hidden global [10 x %struct.etharp_entry], align 16

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

; Function Attrs: nounwind uwtable
declare hidden void @etharp_free_entry(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 void @etharp_cleanup_netif(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %28, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 10
  br i1 %7, label %8, label %31

8:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [10 x %struct.etharp_entry], ptr @arp_table, i64 0, i64 %10
  %12 = getelementptr inbounds %struct.etharp_entry, ptr %11, i32 0, i32 5
  %13 = load i8, ptr %12, align 8, !tbaa !11
  store i8 %13, ptr %4, align 1, !tbaa !16
  %14 = load i8, ptr %4, align 1, !tbaa !16
  %15 = zext i8 %14 to i32
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %27

17:                                               ; preds = %8
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10 x %struct.etharp_entry], ptr @arp_table, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.etharp_entry, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = icmp eq ptr %22, %23
  br i1 %24, label %25, label %27

25:                                               ; preds = %17
  %26 = load i32, ptr %3, align 4, !tbaa !9
  call void @etharp_free_entry(i32 noundef %26)
  br label %27

27:                                               ; preds = %25, %17, %8
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !18

31:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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, !7, i64 32}
!12 = !{!"etharp_entry", !6, i64 0, !13, i64 8, !6, i64 16, !14, i64 24, !15, i64 30, !7, i64 32}
!13 = !{!"ip4_addr", !10, i64 0}
!14 = !{!"eth_addr", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !6, i64 16}
!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"

%struct.etharp_entry = type { ptr, %struct.ip4_addr, ptr, %struct.eth_addr, i16, i8 }
%struct.ip4_addr = type { i32 }
%struct.eth_addr = type { [6 x i8] }

@arp_table = external hidden local_unnamed_addr global [10 x %struct.etharp_entry], align 16

; Function Attrs: nounwind uwtable
declare hidden void @etharp_free_entry(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @etharp_cleanup_netif(ptr noundef readnone %0) local_unnamed_addr #0 {
  %2 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 32), align 16, !tbaa !5
  %.not = icmp ne i8 %2, 0
  %3 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 16), align 16
  %4 = icmp eq ptr %3, %0
  %or.cond = select i1 %.not, i1 %4, i1 false
  br i1 %or.cond, label %5, label %6

5:                                                ; preds = %1
  tail call void @etharp_free_entry(i32 noundef 0)
  br label %6

6:                                                ; preds = %5, %1
  %7 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 72), align 8, !tbaa !5
  %.not.1 = icmp ne i8 %7, 0
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 56), align 8
  %9 = icmp eq ptr %8, %0
  %or.cond10 = select i1 %.not.1, i1 %9, i1 false
  br i1 %or.cond10, label %10, label %11

10:                                               ; preds = %6
  tail call void @etharp_free_entry(i32 noundef 1)
  br label %11

11:                                               ; preds = %10, %6
  %12 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 112), align 16, !tbaa !5
  %.not.2 = icmp ne i8 %12, 0
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 96), align 16
  %14 = icmp eq ptr %13, %0
  %or.cond12 = select i1 %.not.2, i1 %14, i1 false
  br i1 %or.cond12, label %15, label %16

15:                                               ; preds = %11
  tail call void @etharp_free_entry(i32 noundef 2)
  br label %16

16:                                               ; preds = %15, %11
  %17 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 152), align 8, !tbaa !5
  %.not.3 = icmp ne i8 %17, 0
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 136), align 8
  %19 = icmp eq ptr %18, %0
  %or.cond14 = select i1 %.not.3, i1 %19, i1 false
  br i1 %or.cond14, label %20, label %21

20:                                               ; preds = %16
  tail call void @etharp_free_entry(i32 noundef 3)
  br label %21

21:                                               ; preds = %20, %16
  %22 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 192), align 16, !tbaa !5
  %.not.4 = icmp ne i8 %22, 0
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 176), align 16
  %24 = icmp eq ptr %23, %0
  %or.cond16 = select i1 %.not.4, i1 %24, i1 false
  br i1 %or.cond16, label %25, label %26

25:                                               ; preds = %21
  tail call void @etharp_free_entry(i32 noundef 4)
  br label %26

26:                                               ; preds = %25, %21
  %27 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 232), align 8, !tbaa !5
  %.not.5 = icmp ne i8 %27, 0
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 216), align 8
  %29 = icmp eq ptr %28, %0
  %or.cond18 = select i1 %.not.5, i1 %29, i1 false
  br i1 %or.cond18, label %30, label %31

30:                                               ; preds = %26
  tail call void @etharp_free_entry(i32 noundef 5)
  br label %31

31:                                               ; preds = %30, %26
  %32 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 272), align 16, !tbaa !5
  %.not.6 = icmp ne i8 %32, 0
  %33 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 256), align 16
  %34 = icmp eq ptr %33, %0
  %or.cond20 = select i1 %.not.6, i1 %34, i1 false
  br i1 %or.cond20, label %35, label %36

35:                                               ; preds = %31
  tail call void @etharp_free_entry(i32 noundef 6)
  br label %36

36:                                               ; preds = %35, %31
  %37 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 312), align 8, !tbaa !5
  %.not.7 = icmp ne i8 %37, 0
  %38 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 296), align 8
  %39 = icmp eq ptr %38, %0
  %or.cond22 = select i1 %.not.7, i1 %39, i1 false
  br i1 %or.cond22, label %40, label %41

40:                                               ; preds = %36
  tail call void @etharp_free_entry(i32 noundef 7)
  br label %41

41:                                               ; preds = %40, %36
  %42 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 352), align 16, !tbaa !5
  %.not.8 = icmp ne i8 %42, 0
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 336), align 16
  %44 = icmp eq ptr %43, %0
  %or.cond24 = select i1 %.not.8, i1 %44, i1 false
  br i1 %or.cond24, label %45, label %46

45:                                               ; preds = %41
  tail call void @etharp_free_entry(i32 noundef 8)
  br label %46

46:                                               ; preds = %45, %41
  %47 = load i8, ptr getelementptr inbounds (i8, ptr @arp_table, i64 392), align 8, !tbaa !5
  %.not.9 = icmp ne i8 %47, 0
  %48 = load ptr, ptr getelementptr inbounds (i8, ptr @arp_table, i64 376), align 8
  %49 = icmp eq ptr %48, %0
  %or.cond26 = select i1 %.not.9, i1 %49, i1 false
  br i1 %or.cond26, label %50, label %51

50:                                               ; preds = %46
  tail call void @etharp_free_entry(i32 noundef 9)
  br label %51

51:                                               ; preds = %50, %46
  ret void
}

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, !8, i64 32}
!6 = !{!"etharp_entry", !7, i64 0, !10, i64 8, !7, i64 16, !12, i64 24, !13, i64 30, !8, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"ip4_addr", !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"eth_addr", !8, i64 0}
!13 = !{!"short", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass