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

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

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

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

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

declare i32 @lwip_htonl(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @tcp_output_segment_busy(ptr noundef) #2

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

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %15, label %10

10:                                               ; preds = %7
  br label %11

11:                                               ; preds = %10
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.33, i32 noundef 1729, ptr noundef @.str.2)
  br label %13

13:                                               ; preds = %11
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14, %7
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.tcp_pcb, ptr %18, i32 0, i32 45
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  store i8 -6, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %93

23:                                               ; preds = %17
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.tcp_pcb, ptr %24, i32 0, i32 45
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call i32 @tcp_output_segment_busy(ptr noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %23
  store i8 -6, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %93

31:                                               ; preds = %23
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tcp_seg, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tcp_pcb, ptr %35, i32 0, i32 45
  store ptr %34, ptr %36, align 8, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.tcp_pcb, ptr %37, i32 0, i32 44
  store ptr %38, ptr %5, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %61, %31
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %59

43:                                               ; preds = %39
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.tcp_seg, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = getelementptr inbounds %struct.tcp_hdr, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 1, !tbaa !17
  %50 = call i32 @lwip_htonl(i32 noundef %49)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.tcp_seg, ptr %51, i32 0, i32 4
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds %struct.tcp_hdr, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 1, !tbaa !17
  %56 = call i32 @lwip_htonl(i32 noundef %55)
  %57 = sub i32 %50, %56
  %58 = icmp slt i32 %57, 0
  br label %59

59:                                               ; preds = %43, %39
  %60 = phi i1 [ false, %39 ], [ %58, %43 ]
  br i1 %60, label %61, label %65

61:                                               ; preds = %59
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.tcp_seg, ptr %63, i32 0, i32 0
  store ptr %64, ptr %5, align 8, !tbaa !5
  br label %39, !llvm.loop !19

65:                                               ; preds = %59
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.tcp_seg, ptr %68, i32 0, i32 0
  store ptr %67, ptr %69, align 8, !tbaa !14
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %70, ptr %71, align 8, !tbaa !5
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.tcp_seg, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !14
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %79

76:                                               ; preds = %65
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.tcp_pcb, ptr %77, i32 0, i32 42
  store i16 0, ptr %78, align 8, !tbaa !21
  br label %79

79:                                               ; preds = %76, %65
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.tcp_pcb, ptr %80, i32 0, i32 28
  %82 = load i8, ptr %81, align 2, !tbaa !22
  %83 = zext i8 %82 to i32
  %84 = icmp slt i32 %83, 255
  br i1 %84, label %85, label %90

85:                                               ; preds = %79
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.tcp_pcb, ptr %86, i32 0, i32 28
  %88 = load i8, ptr %87, align 2, !tbaa !22
  %89 = add i8 %88, 1
  store i8 %89, ptr %87, align 2, !tbaa !22
  br label %90

90:                                               ; preds = %85, %79
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.tcp_pcb, ptr %91, i32 0, i32 23
  store i32 0, ptr %92, align 4, !tbaa !23
  store i8 0, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %93

93:                                               ; preds = %90, %30, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %94 = load i8, ptr %2, align 1
  ret i8 %94
}

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 = { 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 136}
!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 = !{!15, !6, i64 0}
!15 = !{!"tcp_seg", !6, i64 0, !6, i64 8, !13, i64 16, !7, i64 18, !6, i64 24}
!16 = !{!15, !6, i64 24}
!17 = !{!18, !12, i64 4}
!18 = !{!"tcp_hdr", !13, i64 0, !13, i64 2, !12, i64 4, !12, i64 8, !13, i64 12, !13, i64 14, !13, i64 16, !13, i64 18}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !13, i64 120}
!22 = !{!10, !7, i64 82}
!23 = !{!10, !12, i64 68}


; 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 [182 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [24 x i8], align 1

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

declare i32 @lwip_htonl(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @tcp_output_segment_busy(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local signext range(i8 -6, 1) i8 @tcp_rexmit(ptr noundef %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %4

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

4:                                                ; preds = %2, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %43, label %8

8:                                                ; preds = %4
  %9 = tail call i32 @tcp_output_segment_busy(ptr noundef nonnull %6)
  %.not23 = icmp eq i32 %9, 0
  br i1 %.not23, label %10, label %43

10:                                               ; preds = %8
  %11 = load ptr, ptr %6, align 8, !tbaa !13
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 128
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %.not2426 = icmp eq ptr %13, null
  br i1 %.not2426, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %14 = getelementptr inbounds i8, ptr %6, i64 24
  br label %15

15:                                               ; preds = %.lr.ph, %29
  %16 = phi ptr [ %13, %.lr.ph ], [ %30, %29 ]
  %.027 = phi ptr [ %12, %.lr.ph ], [ %28, %29 ]
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = load i32, ptr %19, align 1, !tbaa !17
  %21 = tail call i32 @lwip_htonl(i32 noundef %20) #3
  %22 = load ptr, ptr %14, align 8, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  %24 = load i32, ptr %23, align 1, !tbaa !17
  %25 = tail call i32 @lwip_htonl(i32 noundef %24) #3
  %26 = sub i32 %21, %25
  %27 = icmp slt i32 %26, 0
  %28 = load ptr, ptr %.027, align 8, !tbaa !15
  br i1 %27, label %29, label %.critedge

29:                                               ; preds = %15
  %30 = load ptr, ptr %28, align 8, !tbaa !15
  %.not24 = icmp eq ptr %30, null
  br i1 %.not24, label %.critedge, label %15, !llvm.loop !19

.critedge:                                        ; preds = %29, %15, %10
  %31 = phi ptr [ null, %10 ], [ null, %29 ], [ %28, %15 ]
  %.0.lcssa = phi ptr [ %12, %10 ], [ %28, %29 ], [ %.027, %15 ]
  store ptr %31, ptr %6, align 8, !tbaa !13
  store ptr %6, ptr %.0.lcssa, align 8, !tbaa !15
  %32 = load ptr, ptr %6, align 8, !tbaa !13
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %36

34:                                               ; preds = %.critedge
  %35 = getelementptr inbounds i8, ptr %0, i64 120
  store i16 0, ptr %35, align 8, !tbaa !21
  br label %36

36:                                               ; preds = %34, %.critedge
  %37 = getelementptr inbounds i8, ptr %0, i64 82
  %38 = load i8, ptr %37, align 2, !tbaa !22
  %.not25 = icmp eq i8 %38, -1
  br i1 %.not25, label %41, label %39

39:                                               ; preds = %36
  %40 = add nuw i8 %38, 1
  store i8 %40, ptr %37, align 2, !tbaa !22
  br label %41

41:                                               ; preds = %39, %36
  %42 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 0, ptr %42, align 4, !tbaa !23
  br label %43

43:                                               ; preds = %8, %4, %41
  %.020 = phi i8 [ 0, %41 ], [ -6, %4 ], [ -6, %8 ]
  ret i8 %.020
}

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


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