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

@ethbroadcast = external dso_local constant %struct.eth_addr, align 1

; Function Attrs: nounwind uwtable
define dso_local signext i8 @ethernet_input(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca i16, align 2
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #4
  store i16 14, ptr %8, align 2, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.pbuf, ptr %10, i32 0, i32 3
  %12 = load i16, ptr %11, align 2, !tbaa !11
  %13 = zext i16 %12 to i32
  %14 = icmp sle i32 %13, 14
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  br label %138

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.pbuf, ptr %17, i32 0, i32 7
  %19 = load i8, ptr %18, align 1, !tbaa !13
  %20 = zext i8 %19 to i32
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %31

22:                                               ; preds = %16
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.netif, ptr %23, i32 0, i32 15
  %25 = load i8, ptr %24, align 4, !tbaa !14
  %26 = zext i8 %25 to i32
  %27 = add nsw i32 %26, 1
  %28 = trunc i32 %27 to i8
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.pbuf, ptr %29, i32 0, i32 7
  store i8 %28, ptr %30, align 1, !tbaa !13
  br label %31

31:                                               ; preds = %22, %16
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.pbuf, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  store ptr %34, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.eth_hdr, ptr %35, i32 0, i32 2
  %37 = load i16, ptr %36, align 1, !tbaa !19
  store i16 %37, ptr %7, align 2, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.eth_hdr, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.eth_addr, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds [6 x i8], ptr %40, i64 0, i64 0
  %42 = load i8, ptr %41, align 1, !tbaa !22
  %43 = zext i8 %42 to i32
  %44 = and i32 %43, 1
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %94

46:                                               ; preds = %31
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.eth_hdr, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.eth_addr, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds [6 x i8], ptr %49, i64 0, i64 0
  %51 = load i8, ptr %50, align 1, !tbaa !22
  %52 = zext i8 %51 to i32
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %78

54:                                               ; preds = %46
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.eth_hdr, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds %struct.eth_addr, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds [6 x i8], ptr %57, i64 0, i64 1
  %59 = load i8, ptr %58, align 1, !tbaa !22
  %60 = zext i8 %59 to i32
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %77

62:                                               ; preds = %54
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.eth_hdr, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %struct.eth_addr, ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds [6 x i8], ptr %65, i64 0, i64 2
  %67 = load i8, ptr %66, align 1, !tbaa !22
  %68 = zext i8 %67 to i32
  %69 = icmp eq i32 %68, 94
  br i1 %69, label %70, label %77

70:                                               ; preds = %62
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.pbuf, ptr %71, i32 0, i32 5
  %73 = load i8, ptr %72, align 1, !tbaa !23
  %74 = zext i8 %73 to i32
  %75 = or i32 %74, 16
  %76 = trunc i32 %75 to i8
  store i8 %76, ptr %72, align 1, !tbaa !23
  br label %77

77:                                               ; preds = %70, %62, %54
  br label %93

78:                                               ; preds = %46
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.eth_hdr, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.eth_addr, ptr %80, i32 0, i32 0
  %82 = getelementptr inbounds [6 x i8], ptr %81, i64 0, i64 0
  %83 = call i32 @memcmp(ptr noundef %82, ptr noundef @ethbroadcast, i64 noundef 6) #5
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %92

85:                                               ; preds = %78
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.pbuf, ptr %86, i32 0, i32 5
  %88 = load i8, ptr %87, align 1, !tbaa !23
  %89 = zext i8 %88 to i32
  %90 = or i32 %89, 8
  %91 = trunc i32 %90 to i8
  store i8 %91, ptr %87, align 1, !tbaa !23
  br label %92

92:                                               ; preds = %85, %78
  br label %93

93:                                               ; preds = %92, %77
  br label %94

94:                                               ; preds = %93, %31
  %95 = load i16, ptr %7, align 2, !tbaa !9
  %96 = zext i16 %95 to i32
  switch i32 %96, label %136 [
    i32 8, label %97
    i32 1544, label %117
  ]

97:                                               ; preds = %94
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.netif, ptr %98, i32 0, i32 13
  %100 = load i8, ptr %99, align 1, !tbaa !24
  %101 = zext i8 %100 to i32
  %102 = and i32 %101, 8
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %105, label %104

104:                                              ; preds = %97
  br label %138

105:                                              ; preds = %97
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = load i16, ptr %8, align 2, !tbaa !9
  %108 = zext i16 %107 to i64
  %109 = call zeroext i8 @pbuf_remove_header(ptr noundef %106, i64 noundef %108)
  %110 = icmp ne i8 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %105
  br label %138

112:                                              ; preds = %105
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = call signext i8 @ip4_input(ptr noundef %113, ptr noundef %114)
  br label %116

116:                                              ; preds = %112
  br label %137

117:                                              ; preds = %94
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.netif, ptr %118, i32 0, i32 13
  %120 = load i8, ptr %119, align 1, !tbaa !24
  %121 = zext i8 %120 to i32
  %122 = and i32 %121, 8
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %125, label %124

124:                                              ; preds = %117
  br label %138

125:                                              ; preds = %117
  %126 = load ptr, ptr %4, align 8, !tbaa !5
  %127 = load i16, ptr %8, align 2, !tbaa !9
  %128 = zext i16 %127 to i64
  %129 = call zeroext i8 @pbuf_remove_header(ptr noundef %126, i64 noundef %128)
  %130 = icmp ne i8 %129, 0
  br i1 %130, label %131, label %132

131:                                              ; preds = %125
  br label %138

132:                                              ; preds = %125
  %133 = load ptr, ptr %4, align 8, !tbaa !5
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  call void @etharp_input(ptr noundef %133, ptr noundef %134)
  br label %135

135:                                              ; preds = %132
  br label %137

136:                                              ; preds = %94
  br label %138

137:                                              ; preds = %135, %116
  store i8 0, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %141

138:                                              ; preds = %136, %131, %124, %111, %104, %15
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  %140 = call zeroext i8 @pbuf_free(ptr noundef %139)
  store i8 0, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %141

141:                                              ; preds = %138, %137
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %142 = load i8, ptr %3, align 1
  ret i8 %142
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #2

declare zeroext i8 @pbuf_remove_header(ptr noundef, i64 noundef) #3

declare signext i8 @ip4_input(ptr noundef, ptr noundef) #3

declare void @etharp_input(ptr noundef, ptr noundef) #3

declare zeroext i8 @pbuf_free(ptr noundef) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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, !10, i64 18}
!12 = !{!"pbuf", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 18, !7, i64 20, !7, i64 21, !7, i64 22, !7, i64 23}
!13 = !{!12, !7, i64 23}
!14 = !{!15, !7, i64 84}
!15 = !{!"netif", !6, i64 0, !16, i64 8, !16, i64 12, !16, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !10, i64 72, !7, i64 74, !7, i64 80, !7, i64 81, !7, i64 82, !7, i64 84, !7, i64 85}
!16 = !{!"ip4_addr", !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!12, !6, i64 8}
!19 = !{!20, !10, i64 12}
!20 = !{!"eth_hdr", !21, i64 0, !21, i64 6, !10, i64 12}
!21 = !{!"eth_addr", !7, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!12, !7, i64 21}
!24 = !{!15, !7, i64 81}


; 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.eth_addr = type { [6 x i8] }

@ethbroadcast = external dso_local constant %struct.eth_addr, align 1

; Function Attrs: nounwind uwtable
define dso_local noundef signext i8 @ethernet_input(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 18
  %4 = load i16, ptr %3, align 2, !tbaa !5
  %5 = icmp ult i16 %4, 15
  br i1 %5, label %52, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 23
  %8 = load i8, ptr %7, align 1, !tbaa !11
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %10, label %14

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %1, i64 84
  %12 = load i8, ptr %11, align 4, !tbaa !12
  %13 = add i8 %12, 1
  store i8 %13, ptr %7, align 1, !tbaa !11
  br label %14

14:                                               ; preds = %10, %6
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %16, i64 12
  %18 = load i16, ptr %17, align 1, !tbaa !17
  %19 = load i8, ptr %16, align 1, !tbaa !20
  %20 = and i8 %19, 1
  %.not = icmp eq i8 %20, 0
  br i1 %.not, label %36, label %21

21:                                               ; preds = %14
  %22 = icmp eq i8 %19, 1
  br i1 %22, label %23, label %31

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %16, i64 1
  %25 = load i8, ptr %24, align 1, !tbaa !20
  %26 = icmp eq i8 %25, 0
  br i1 %26, label %27, label %36

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %16, i64 2
  %29 = load i8, ptr %28, align 1, !tbaa !20
  %30 = icmp eq i8 %29, 94
  br i1 %30, label %.sink.split, label %36

31:                                               ; preds = %21
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %16, ptr noundef nonnull dereferenceable(6) @ethbroadcast, i64 6)
  %32 = icmp eq i32 %bcmp, 0
  br i1 %32, label %.sink.split, label %36

.sink.split:                                      ; preds = %31, %27
  %.sink31 = phi i8 [ 16, %27 ], [ 8, %31 ]
  %33 = getelementptr inbounds i8, ptr %0, i64 21
  %34 = load i8, ptr %33, align 1, !tbaa !21
  %35 = or i8 %34, %.sink31
  store i8 %35, ptr %33, align 1, !tbaa !21
  br label %36

36:                                               ; preds = %.sink.split, %27, %23, %31, %14
  switch i16 %18, label %52 [
    i16 8, label %37
    i16 1544, label %45
  ]

37:                                               ; preds = %36
  %38 = getelementptr inbounds i8, ptr %1, i64 81
  %39 = load i8, ptr %38, align 1, !tbaa !22
  %40 = and i8 %39, 8
  %.not27 = icmp eq i8 %40, 0
  br i1 %.not27, label %52, label %41

41:                                               ; preds = %37
  %42 = tail call zeroext i8 @pbuf_remove_header(ptr noundef nonnull %0, i64 noundef 14) #3
  %.not28 = icmp eq i8 %42, 0
  br i1 %.not28, label %43, label %52

43:                                               ; preds = %41
  %44 = tail call signext i8 @ip4_input(ptr noundef nonnull %0, ptr noundef nonnull %1) #3
  br label %54

45:                                               ; preds = %36
  %46 = getelementptr inbounds i8, ptr %1, i64 81
  %47 = load i8, ptr %46, align 1, !tbaa !22
  %48 = and i8 %47, 8
  %.not25 = icmp eq i8 %48, 0
  br i1 %.not25, label %52, label %49

49:                                               ; preds = %45
  %50 = tail call zeroext i8 @pbuf_remove_header(ptr noundef nonnull %0, i64 noundef 14) #3
  %.not26 = icmp eq i8 %50, 0
  br i1 %.not26, label %51, label %52

51:                                               ; preds = %49
  tail call void @etharp_input(ptr noundef nonnull %0, ptr noundef nonnull %1) #3
  br label %54

52:                                               ; preds = %36, %49, %45, %41, %37, %2
  %53 = tail call zeroext i8 @pbuf_free(ptr noundef nonnull %0) #3
  br label %54

54:                                               ; preds = %43, %51, %52
  ret i8 0
}

declare zeroext i8 @pbuf_remove_header(ptr noundef, i64 noundef) local_unnamed_addr #1

declare signext i8 @ip4_input(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @etharp_input(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #2

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 = { "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 = { nofree nounwind willreturn memory(argmem: read) }
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, !10, i64 18}
!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 = !{!6, !8, i64 23}
!12 = !{!13, !8, i64 84}
!13 = !{!"netif", !7, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !8, i64 64, !10, i64 72, !8, i64 74, !8, i64 80, !8, i64 81, !8, i64 82, !8, i64 84, !8, i64 85}
!14 = !{!"ip4_addr", !15, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!6, !7, i64 8}
!17 = !{!18, !10, i64 12}
!18 = !{!"eth_hdr", !19, i64 0, !19, i64 6, !10, i64 12}
!19 = !{!"eth_addr", !8, i64 0}
!20 = !{!8, !8, i64 0}
!21 = !{!6, !8, i64 21}
!22 = !{!13, !8, i64 81}


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