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

; 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.tcp_pcb = type { %struct.ip4_addr, %struct.ip4_addr, i8, i8, i8, i8, ptr, ptr, i32, i8, i16, i16, i16, i8, i8, i8, i32, i32, i16, i16, i32, i16, i16, i32, i32, i16, i16, i16, i8, i8, i32, i16, i16, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i8, i8, i8, i8 }
%struct.ip4_addr = type { i32 }

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [178 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @tcp_pcb_remove(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %13, label %9

9:                                                ; preds = %6
  br label %10

10:                                               ; preds = %9
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.37, i32 noundef 2179, ptr noundef @.str.2)
  br label %12

12:                                               ; preds = %10
  br label %13

13:                                               ; preds = %12, %6
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %22, label %18

18:                                               ; preds = %15
  br label %19

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

21:                                               ; preds = %19
  br label %22

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

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %35

29:                                               ; preds = %24
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.tcp_pcb, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %33, ptr %34, align 8, !tbaa !5
  br label %59

35:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  store ptr %37, ptr %5, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %54, %35
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %58

41:                                               ; preds = %38
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.tcp_pcb, ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = icmp eq ptr %44, %45
  br i1 %46, label %47, label %53

47:                                               ; preds = %41
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.tcp_pcb, ptr %48, i32 0, i32 6
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.tcp_pcb, ptr %51, i32 0, i32 6
  store ptr %50, ptr %52, align 8, !tbaa !9
  br label %58

53:                                               ; preds = %41
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.tcp_pcb, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  store ptr %57, ptr %5, align 8, !tbaa !5
  br label %38, !llvm.loop !14

58:                                               ; preds = %47, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %59

59:                                               ; preds = %58, %29
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.tcp_pcb, ptr %60, i32 0, i32 6
  store ptr null, ptr %61, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %59
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  call void @tcp_pcb_purge(ptr noundef %63)
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.tcp_pcb, ptr %64, i32 0, i32 8
  %66 = load i32, ptr %65, align 8, !tbaa !16
  %67 = icmp ne i32 %66, 10
  br i1 %67, label %68, label %93

68:                                               ; preds = %62
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.tcp_pcb, ptr %69, i32 0, i32 8
  %71 = load i32, ptr %70, align 8, !tbaa !16
  %72 = icmp ne i32 %71, 1
  br i1 %72, label %73, label %93

73:                                               ; preds = %68
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.tcp_pcb, ptr %74, i32 0, i32 12
  %76 = load i16, ptr %75, align 2, !tbaa !17
  %77 = zext i16 %76 to i32
  %78 = and i32 %77, 1
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %93

80:                                               ; preds = %73
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.tcp_pcb, ptr %82, i32 0, i32 12
  %84 = load i16, ptr %83, align 2, !tbaa !17
  %85 = zext i16 %84 to i32
  %86 = or i32 %85, 2
  %87 = trunc i32 %86 to i16
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.tcp_pcb, ptr %88, i32 0, i32 12
  store i16 %87, ptr %89, align 2, !tbaa !17
  br label %90

90:                                               ; preds = %81
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = call signext i8 @tcp_output(ptr noundef %91)
  br label %93

93:                                               ; preds = %90, %73, %68, %62
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.tcp_pcb, ptr %94, i32 0, i32 8
  %96 = load i32, ptr %95, align 8, !tbaa !16
  %97 = icmp ne i32 %96, 1
  br i1 %97, label %98, label %121

98:                                               ; preds = %93
  br label %99

99:                                               ; preds = %98
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.tcp_pcb, ptr %100, i32 0, i32 44
  %102 = load ptr, ptr %101, align 8, !tbaa !18
  %103 = icmp eq ptr %102, null
  br i1 %103, label %108, label %104

104:                                              ; preds = %99
  br label %105

105:                                              ; preds = %104
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.39, i32 noundef 2195, ptr noundef @.str.2)
  br label %107

107:                                              ; preds = %105
  br label %108

108:                                              ; preds = %107, %99
  br label %109

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.tcp_pcb, ptr %111, i32 0, i32 45
  %113 = load ptr, ptr %112, align 8, !tbaa !19
  %114 = icmp eq ptr %113, null
  br i1 %114, label %119, label %115

115:                                              ; preds = %110
  br label %116

116:                                              ; preds = %115
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.40, i32 noundef 2196, ptr noundef @.str.2)
  br label %118

118:                                              ; preds = %116
  br label %119

119:                                              ; preds = %118, %110
  br label %120

120:                                              ; preds = %119
  br label %121

121:                                              ; preds = %120, %93
  %122 = load ptr, ptr %4, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.tcp_pcb, ptr %122, i32 0, i32 8
  store i32 0, ptr %123, align 8, !tbaa !16
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.tcp_pcb, ptr %124, i32 0, i32 10
  store i16 0, ptr %125, align 2, !tbaa !20
  br label %126

126:                                              ; preds = %121
  br label %127

127:                                              ; preds = %126
  ret void
}

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

declare signext i8 @tcp_output(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @tcp_pcb_purge(ptr noundef) #2

attributes #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 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 = { 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 16}
!10 = !{!"tcp_pcb", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !6, i64 16, !6, i64 24, !12, i64 32, !7, i64 36, !13, i64 38, !13, i64 40, !13, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !12, i64 48, !12, i64 52, !13, i64 56, !13, i64 58, !12, i64 60, !13, i64 64, !13, i64 66, !12, i64 68, !12, i64 72, !13, i64 76, !13, i64 78, !13, i64 80, !7, i64 82, !7, i64 83, !12, i64 84, !13, i64 88, !13, i64 90, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !13, i64 112, !13, i64 114, !13, i64 116, !13, i64 118, !13, i64 120, !13, i64 122, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !12, i64 200, !7, i64 204, !7, i64 205, !7, i64 206, !7, i64 207}
!11 = !{!"ip4_addr", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !12, i64 32}
!17 = !{!10, !13, i64 42}
!18 = !{!10, !6, i64 128}
!19 = !{!10, !6, i64 136}
!20 = !{!10, !13, i64 38}


; 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"

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [178 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @tcp_pcb_remove(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %3, label %5

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

5:                                                ; preds = %3, %2
  %.not30 = icmp eq ptr %0, null
  br i1 %.not30, label %6, label %8

6:                                                ; preds = %5
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.38, i32 noundef 2180, ptr noundef nonnull @.str.2)
  br label %8

8:                                                ; preds = %6, %5
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = icmp eq ptr %9, %1
  br i1 %10, label %.loopexit.sink.split, label %.preheader

.preheader:                                       ; preds = %8, %11
  %.0 = phi ptr [ %13, %11 ], [ %9, %8 ]
  %.not31 = icmp eq ptr %.0, null
  br i1 %.not31, label %.loopexit, label %11

11:                                               ; preds = %.preheader
  %12 = getelementptr inbounds i8, ptr %.0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp eq ptr %13, %1
  br i1 %14, label %15, label %.preheader, !llvm.loop !14

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %.0, i64 16
  br label %.loopexit.sink.split

.loopexit.sink.split:                             ; preds = %8, %15
  %.sink = phi ptr [ %1, %15 ], [ %9, %8 ]
  %.sink39 = phi ptr [ %16, %15 ], [ %0, %8 ]
  %17 = getelementptr inbounds i8, ptr %.sink, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %.sink39, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.sink.split
  %19 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr null, ptr %19, align 8, !tbaa !9
  tail call void @tcp_pcb_purge(ptr noundef %1)
  %20 = getelementptr inbounds i8, ptr %1, i64 32
  %21 = load i32, ptr %20, align 8, !tbaa !16
  switch i32 %21, label %22 [
    i32 10, label %thread-pre-split
    i32 1, label %thread-pre-split
  ]

22:                                               ; preds = %.loopexit
  %23 = getelementptr inbounds i8, ptr %1, i64 42
  %24 = load i16, ptr %23, align 2, !tbaa !17
  %25 = and i16 %24, 1
  %.not34 = icmp eq i16 %25, 0
  br i1 %.not34, label %thread-pre-split.thread, label %26

26:                                               ; preds = %22
  %27 = or i16 %24, 2
  store i16 %27, ptr %23, align 2, !tbaa !17
  %28 = tail call signext i8 @tcp_output(ptr noundef nonnull %1) #3
  %.pr.pre = load i32, ptr %20, align 8, !tbaa !16
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %26, %.loopexit, %.loopexit
  %29 = phi i32 [ %21, %.loopexit ], [ %21, %.loopexit ], [ %.pr.pre, %26 ]
  %.not35 = icmp eq i32 %29, 1
  br i1 %.not35, label %41, label %thread-pre-split.thread

thread-pre-split.thread:                          ; preds = %22, %thread-pre-split
  %30 = getelementptr inbounds i8, ptr %1, i64 128
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = icmp eq ptr %31, null
  br i1 %32, label %35, label %33

33:                                               ; preds = %thread-pre-split.thread
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.39, i32 noundef 2195, ptr noundef nonnull @.str.2)
  br label %35

35:                                               ; preds = %33, %thread-pre-split.thread
  %36 = getelementptr inbounds i8, ptr %1, i64 136
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = icmp eq ptr %37, null
  br i1 %38, label %41, label %39

39:                                               ; preds = %35
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.40, i32 noundef 2196, ptr noundef nonnull @.str.2)
  br label %41

41:                                               ; preds = %39, %35, %thread-pre-split
  store i32 0, ptr %20, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %1, i64 38
  store i16 0, ptr %42, align 2, !tbaa !20
  ret void
}

declare signext i8 @tcp_output(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @tcp_pcb_purge(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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, !6, i64 16}
!10 = !{!"tcp_pcb", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !6, i64 16, !6, i64 24, !12, i64 32, !7, i64 36, !13, i64 38, !13, i64 40, !13, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !12, i64 48, !12, i64 52, !13, i64 56, !13, i64 58, !12, i64 60, !13, i64 64, !13, i64 66, !12, i64 68, !12, i64 72, !13, i64 76, !13, i64 78, !13, i64 80, !7, i64 82, !7, i64 83, !12, i64 84, !13, i64 88, !13, i64 90, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !13, i64 112, !13, i64 114, !13, i64 116, !13, i64 118, !13, i64 120, !13, i64 122, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !12, i64 200, !7, i64 204, !7, i64 205, !7, i64 206, !7, i64 207}
!11 = !{!"ip4_addr", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !12, i64 32}
!17 = !{!10, !13, i64 42}
!18 = !{!10, !6, i64 128}
!19 = !{!10, !6, i64 136}
!20 = !{!10, !13, i64 38}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass