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

; 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
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [186 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

; 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 i64 @etharp_find_addr(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i16, align 2
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #3
  br label %12

12:                                               ; preds = %4
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %12
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %23, label %18

18:                                               ; preds = %15, %12
  br label %19

19:                                               ; preds = %18
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 589, ptr noundef @.str.2)
  br label %21

21:                                               ; preds = %19
  br label %22

22:                                               ; preds = %21
  br label %23

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

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call signext i16 @etharp_find_entry(ptr noundef %27, i8 noundef zeroext 2, ptr noundef %28)
  store i16 %29, ptr %10, align 2, !tbaa !9
  %30 = load i16, ptr %10, align 2, !tbaa !9
  %31 = sext i16 %30 to i32
  %32 = icmp sge i32 %31, 0
  br i1 %32, label %33, label %54

33:                                               ; preds = %25
  %34 = load i16, ptr %10, align 2, !tbaa !9
  %35 = sext i16 %34 to i64
  %36 = getelementptr inbounds [10 x %struct.etharp_entry], ptr @arp_table, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.etharp_entry, ptr %36, i32 0, i32 5
  %38 = load i8, ptr %37, align 8, !tbaa !11
  %39 = zext i8 %38 to i32
  %40 = icmp sge i32 %39, 2
  br i1 %40, label %41, label %54

41:                                               ; preds = %33
  %42 = load i16, ptr %10, align 2, !tbaa !9
  %43 = sext i16 %42 to i64
  %44 = getelementptr inbounds [10 x %struct.etharp_entry], ptr @arp_table, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.etharp_entry, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %45, ptr %46, align 8, !tbaa !5
  %47 = load i16, ptr %10, align 2, !tbaa !9
  %48 = sext i16 %47 to i64
  %49 = getelementptr inbounds [10 x %struct.etharp_entry], ptr @arp_table, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.etharp_entry, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %50, ptr %51, align 8, !tbaa !5
  %52 = load i16, ptr %10, align 2, !tbaa !9
  %53 = sext i16 %52 to i64
  store i64 %53, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %55

54:                                               ; preds = %33, %25
  store i64 -1, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %55

55:                                               ; preds = %54, %41
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #3
  %56 = load i64, ptr %5, align 8
  ret i64 %56
}

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare hidden signext i16 @etharp_find_entry(ptr noundef, i8 noundef zeroext, ptr noundef) #1

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 = { "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 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !7, i64 32}
!12 = !{!"etharp_entry", !6, i64 0, !13, i64 8, !6, i64 16, !15, i64 24, !10, i64 30, !7, i64 32}
!13 = !{!"ip4_addr", !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"eth_addr", !7, i64 0}


; 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 global [10 x %struct.etharp_entry], align 16
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [186 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -32768, 32768) i64 @etharp_find_addr(ptr noundef %0, ptr noundef %1, ptr noundef writeonly %2, ptr noundef writeonly %3) local_unnamed_addr #0 {
  %5 = icmp ne ptr %2, null
  %6 = icmp ne ptr %3, null
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %9, label %7

7:                                                ; preds = %4
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.1, i32 noundef 589, ptr noundef nonnull @.str.2)
  br label %9

9:                                                ; preds = %4, %7
  %10 = tail call signext i16 @etharp_find_entry(ptr noundef %1, i8 noundef zeroext 2, ptr noundef %0)
  %11 = icmp sgt i16 %10, -1
  br i1 %11, label %12, label %21

12:                                               ; preds = %9
  %13 = zext nneg i16 %10 to i64
  %14 = getelementptr inbounds [10 x %struct.etharp_entry], ptr @arp_table, i64 0, i64 %13
  %15 = getelementptr inbounds i8, ptr %14, i64 32
  %16 = load i8, ptr %15, align 8, !tbaa !5
  %17 = icmp ugt i8 %16, 1
  br i1 %17, label %18, label %21

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %14, i64 24
  store ptr %19, ptr %2, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %14, i64 8
  store ptr %20, ptr %3, align 8, !tbaa !14
  br label %21

21:                                               ; preds = %9, %12, %18
  %.0 = phi i64 [ %13, %18 ], [ -1, %12 ], [ -1, %9 ]
  ret i64 %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden signext i16 @etharp_find_entry(ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #0

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" }
attributes #1 = { nofree nounwind "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}
!14 = !{!7, !7, i64 0}


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