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

; 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.ip4_addr = type { i32 }
%struct.pbuf = type { ptr, ptr, i16, i16, i8, i8, i8, i8 }
%struct.etharp_hdr = type { i16, i16, i8, i8, i16, %struct.eth_addr, %struct.ip4_addr_wordaligned, %struct.eth_addr, %struct.ip4_addr_wordaligned }
%struct.eth_addr = type { [6 x i8] }
%struct.ip4_addr_wordaligned = type { [2 x i16] }
%struct.netif = type { ptr, %struct.ip4_addr, %struct.ip4_addr, %struct.ip4_addr, ptr, ptr, ptr, ptr, ptr, [1 x ptr], i16, [6 x i8], i8, i8, [2 x i8], i8, i8 }

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

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

; Function Attrs: nounwind uwtable
define dso_local void @etharp_input(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.ip4_addr, align 4
  %7 = alloca %struct.ip4_addr, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  br label %10

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

13:                                               ; preds = %10
  br label %14

14:                                               ; preds = %13
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.4, i32 noundef 650, ptr noundef @.str.2)
  br label %16

16:                                               ; preds = %14
  br label %17

17:                                               ; preds = %16
  store i32 1, ptr %9, align 4
  br label %120

18:                                               ; preds = %10
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.pbuf, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  store ptr %23, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.etharp_hdr, ptr %24, i32 0, i32 0
  %26 = load i16, ptr %25, align 1, !tbaa !12
  %27 = zext i16 %26 to i32
  %28 = icmp ne i32 %27, 256
  br i1 %28, label %47, label %29

29:                                               ; preds = %20
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.etharp_hdr, ptr %30, i32 0, i32 2
  %32 = load i8, ptr %31, align 1, !tbaa !16
  %33 = zext i8 %32 to i32
  %34 = icmp ne i32 %33, 6
  br i1 %34, label %47, label %35

35:                                               ; preds = %29
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.etharp_hdr, ptr %36, i32 0, i32 3
  %38 = load i8, ptr %37, align 1, !tbaa !17
  %39 = zext i8 %38 to i64
  %40 = icmp ne i64 %39, 4
  br i1 %40, label %47, label %41

41:                                               ; preds = %35
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.etharp_hdr, ptr %42, i32 0, i32 1
  %44 = load i16, ptr %43, align 1, !tbaa !18
  %45 = zext i16 %44 to i32
  %46 = icmp ne i32 %45, 8
  br i1 %46, label %47, label %50

47:                                               ; preds = %41, %35, %29, %20
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = call zeroext i8 @pbuf_free(ptr noundef %48)
  store i32 1, ptr %9, align 4
  br label %120

50:                                               ; preds = %41
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.etharp_hdr, ptr %51, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 1 %52, i64 4, i1 false)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.etharp_hdr, ptr %53, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 1 %54, i64 4, i1 false)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.netif, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.ip4_addr, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !19
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %50
  store i8 0, ptr %8, align 1, !tbaa !22
  br label %71

61:                                               ; preds = %50
  %62 = getelementptr inbounds %struct.ip4_addr, ptr %7, i32 0, i32 0
  %63 = load i32, ptr %62, align 4, !tbaa !19
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.netif, ptr %64, i32 0, i32 1
  %66 = getelementptr inbounds %struct.ip4_addr, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !19
  %68 = icmp eq i32 %63, %67
  %69 = zext i1 %68 to i32
  %70 = trunc i32 %69 to i8
  store i8 %70, ptr %8, align 1, !tbaa !22
  br label %71

71:                                               ; preds = %61, %60
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.etharp_hdr, ptr %73, i32 0, i32 5
  %75 = load i8, ptr %8, align 1, !tbaa !22
  %76 = zext i8 %75 to i32
  %77 = icmp ne i32 %76, 0
  %78 = zext i1 %77 to i64
  %79 = select i1 %77, i32 1, i32 2
  %80 = trunc i32 %79 to i8
  %81 = call signext i8 @etharp_update_arp_entry(ptr noundef %72, ptr noundef %6, ptr noundef %74, i8 noundef zeroext %80)
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.etharp_hdr, ptr %82, i32 0, i32 4
  %84 = load i16, ptr %83, align 1, !tbaa !23
  %85 = zext i16 %84 to i32
  switch i32 %85, label %116 [
    i32 256, label %86
    i32 512, label %114
  ]

86:                                               ; preds = %71
  %87 = load i8, ptr %8, align 1, !tbaa !22
  %88 = icmp ne i8 %87, 0
  br i1 %88, label %89, label %104

89:                                               ; preds = %86
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.netif, ptr %91, i32 0, i32 11
  %93 = getelementptr inbounds [6 x i8], ptr %92, i64 0, i64 0
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.etharp_hdr, ptr %94, i32 0, i32 5
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.netif, ptr %96, i32 0, i32 11
  %98 = getelementptr inbounds [6 x i8], ptr %97, i64 0, i64 0
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.netif, ptr %99, i32 0, i32 1
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.etharp_hdr, ptr %101, i32 0, i32 5
  %103 = call signext i8 @etharp_raw(ptr noundef %90, ptr noundef %93, ptr noundef %95, ptr noundef %98, ptr noundef %100, ptr noundef %102, ptr noundef %6, i16 noundef zeroext 2)
  br label %113

104:                                              ; preds = %86
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.netif, ptr %105, i32 0, i32 1
  %107 = getelementptr inbounds %struct.ip4_addr, ptr %106, i32 0, i32 0
  %108 = load i32, ptr %107, align 8, !tbaa !19
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %110, label %111

110:                                              ; preds = %104
  br label %112

111:                                              ; preds = %104
  br label %112

112:                                              ; preds = %111, %110
  br label %113

113:                                              ; preds = %112, %89
  br label %117

114:                                              ; preds = %71
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  call void @dhcp_arp_reply(ptr noundef %115, ptr noundef %6)
  br label %117

116:                                              ; preds = %71
  br label %117

117:                                              ; preds = %116, %114, %113
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = call zeroext i8 @pbuf_free(ptr noundef %118)
  store i32 0, ptr %9, align 4
  br label %120

120:                                              ; preds = %117, %47, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %121 = load i32, ptr %9, align 4
  switch i32 %121, label %123 [
    i32 0, label %122
    i32 1, label %122
  ]

122:                                              ; preds = %120, %120
  ret void

123:                                              ; preds = %120
  unreachable
}

declare zeroext i8 @pbuf_free(ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare hidden signext i8 @etharp_update_arp_entry(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #2

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

declare void @dhcp_arp_reply(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !6, i64 8}
!10 = !{!"pbuf", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 18, !7, i64 20, !7, i64 21, !7, i64 22, !7, i64 23}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"etharp_hdr", !11, i64 0, !11, i64 2, !7, i64 4, !7, i64 5, !11, i64 6, !14, i64 8, !15, i64 14, !14, i64 18, !15, i64 24}
!14 = !{!"eth_addr", !7, i64 0}
!15 = !{!"ip4_addr_wordaligned", !7, i64 0}
!16 = !{!13, !7, i64 4}
!17 = !{!13, !7, i64 5}
!18 = !{!13, !11, i64 2}
!19 = !{!20, !21, i64 0}
!20 = !{!"ip4_addr", !21, i64 0}
!21 = !{!"int", !7, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!13, !11, i64 6}


; 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.ip4_addr = type { i32 }

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [186 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @etharp_input(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.ip4_addr, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.4, i32 noundef 650, ptr noundef nonnull @.str.2)
  br label %42

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = load i16, ptr %8, align 1, !tbaa !11
  %.not25 = icmp eq i16 %9, 256
  br i1 %.not25, label %10, label %19

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %8, i64 4
  %12 = load i8, ptr %11, align 1, !tbaa !15
  %.not26 = icmp eq i8 %12, 6
  br i1 %.not26, label %13, label %19

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %8, i64 5
  %15 = load i8, ptr %14, align 1, !tbaa !16
  %.not27 = icmp eq i8 %15, 4
  br i1 %.not27, label %16, label %19

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %8, i64 2
  %18 = load i16, ptr %17, align 1, !tbaa !17
  %.not28 = icmp eq i16 %18, 8
  br i1 %.not28, label %21, label %19

19:                                               ; preds = %16, %13, %10, %6
  %20 = tail call zeroext i8 @pbuf_free(ptr noundef nonnull %0) #4
  br label %42

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %8, i64 14
  %23 = load i32, ptr %22, align 1
  store i32 %23, ptr %3, align 4
  %24 = getelementptr inbounds i8, ptr %1, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %.thread, label %27

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %8, i64 24
  %.sroa.0.0.copyload = load i32, ptr %28, align 1
  %29 = icmp ne i32 %.sroa.0.0.copyload, %25
  %cond.fr = freeze i1 %29
  %spec.select = select i1 %cond.fr, i8 2, i8 1
  br label %.thread

.thread:                                          ; preds = %21, %27
  %.033 = phi i1 [ %cond.fr, %27 ], [ true, %21 ]
  %30 = phi i8 [ %spec.select, %27 ], [ 2, %21 ]
  %31 = getelementptr inbounds i8, ptr %8, i64 8
  %32 = call signext i8 @etharp_update_arp_entry(ptr noundef nonnull %1, ptr noundef nonnull %3, ptr noundef nonnull %31, i8 noundef zeroext %30)
  %33 = getelementptr inbounds i8, ptr %8, i64 6
  %34 = load i16, ptr %33, align 1, !tbaa !21
  switch i16 %34, label %40 [
    i16 256, label %35
    i16 512, label %39
  ]

35:                                               ; preds = %.thread
  br i1 %.033, label %40, label %36

36:                                               ; preds = %35
  %37 = getelementptr inbounds i8, ptr %1, i64 74
  %38 = call signext i8 @etharp_raw(ptr noundef nonnull %1, ptr noundef nonnull %37, ptr noundef nonnull %31, ptr noundef nonnull %37, ptr noundef nonnull %24, ptr noundef nonnull %31, ptr noundef nonnull %3, i16 noundef zeroext 2)
  br label %40

39:                                               ; preds = %.thread
  call void @dhcp_arp_reply(ptr noundef nonnull %1, ptr noundef nonnull %3) #4
  br label %40

40:                                               ; preds = %.thread, %36, %35, %39
  %41 = call zeroext i8 @pbuf_free(ptr noundef nonnull %0) #4
  br label %42

42:                                               ; preds = %40, %19, %4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret void
}

declare zeroext i8 @pbuf_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden signext i8 @etharp_update_arp_entry(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

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

declare void @dhcp_arp_reply(ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #3 = { "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 #4 = { 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, !7, i64 8}
!6 = !{!"pbuf", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 18, !8, i64 20, !8, i64 21, !8, i64 22, !8, i64 23}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"etharp_hdr", !10, i64 0, !10, i64 2, !8, i64 4, !8, i64 5, !10, i64 6, !13, i64 8, !14, i64 14, !13, i64 18, !14, i64 24}
!13 = !{!"eth_addr", !8, i64 0}
!14 = !{!"ip4_addr_wordaligned", !8, i64 0}
!15 = !{!12, !8, i64 4}
!16 = !{!12, !8, i64 5}
!17 = !{!12, !10, i64 2}
!18 = !{!19, !20, i64 0}
!19 = !{!"ip4_addr", !20, i64 0}
!20 = !{!"int", !8, i64 0}
!21 = !{!12, !10, i64 6}


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