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

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

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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @tcp_rexmit(ptr noundef) #1

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

3:                                                ; preds = %1
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr %4, null
  br i1 %5, label %10, label %6

6:                                                ; preds = %3
  br label %7

7:                                                ; preds = %6
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.34, i32 noundef 1785, ptr noundef @.str.2)
  br label %9

9:                                                ; preds = %7
  br label %10

10:                                               ; preds = %9, %3
  br label %11

11:                                               ; preds = %10
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.tcp_pcb, ptr %12, i32 0, i32 45
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %100

16:                                               ; preds = %11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tcp_pcb, ptr %17, i32 0, i32 12
  %19 = load i16, ptr %18, align 2, !tbaa !14
  %20 = zext i16 %19 to i32
  %21 = and i32 %20, 4
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %100, label %23

23:                                               ; preds = %16
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = call signext i8 @tcp_rexmit(ptr noundef %24)
  %26 = sext i8 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %99

28:                                               ; preds = %23
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tcp_pcb, ptr %29, i32 0, i32 31
  %31 = load i16, ptr %30, align 8, !tbaa !15
  %32 = zext i16 %31 to i32
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.tcp_pcb, ptr %33, i32 0, i32 38
  %35 = load i16, ptr %34, align 8, !tbaa !16
  %36 = zext i16 %35 to i32
  %37 = icmp slt i32 %32, %36
  br i1 %37, label %38, label %43

38:                                               ; preds = %28
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.tcp_pcb, ptr %39, i32 0, i32 31
  %41 = load i16, ptr %40, align 8, !tbaa !15
  %42 = zext i16 %41 to i32
  br label %48

43:                                               ; preds = %28
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.tcp_pcb, ptr %44, i32 0, i32 38
  %46 = load i16, ptr %45, align 8, !tbaa !16
  %47 = zext i16 %46 to i32
  br label %48

48:                                               ; preds = %43, %38
  %49 = phi i32 [ %42, %38 ], [ %47, %43 ]
  %50 = sdiv i32 %49, 2
  %51 = trunc i32 %50 to i16
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.tcp_pcb, ptr %52, i32 0, i32 32
  store i16 %51, ptr %53, align 2, !tbaa !17
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.tcp_pcb, ptr %54, i32 0, i32 32
  %56 = load i16, ptr %55, align 2, !tbaa !17
  %57 = zext i16 %56 to i32
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.tcp_pcb, ptr %58, i32 0, i32 22
  %60 = load i16, ptr %59, align 2, !tbaa !18
  %61 = zext i16 %60 to i32
  %62 = mul i32 2, %61
  %63 = icmp ult i32 %57, %62
  br i1 %63, label %64, label %73

64:                                               ; preds = %48
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.tcp_pcb, ptr %65, i32 0, i32 22
  %67 = load i16, ptr %66, align 2, !tbaa !18
  %68 = zext i16 %67 to i32
  %69 = mul nsw i32 2, %68
  %70 = trunc i32 %69 to i16
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.tcp_pcb, ptr %71, i32 0, i32 32
  store i16 %70, ptr %72, align 2, !tbaa !17
  br label %73

73:                                               ; preds = %64, %48
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.tcp_pcb, ptr %74, i32 0, i32 32
  %76 = load i16, ptr %75, align 2, !tbaa !17
  %77 = zext i16 %76 to i32
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.tcp_pcb, ptr %78, i32 0, i32 22
  %80 = load i16, ptr %79, align 2, !tbaa !18
  %81 = zext i16 %80 to i32
  %82 = mul nsw i32 3, %81
  %83 = add nsw i32 %77, %82
  %84 = trunc i32 %83 to i16
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.tcp_pcb, ptr %85, i32 0, i32 31
  store i16 %84, ptr %86, align 8, !tbaa !15
  br label %87

87:                                               ; preds = %73
  %88 = load ptr, ptr %2, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.tcp_pcb, ptr %88, i32 0, i32 12
  %90 = load i16, ptr %89, align 2, !tbaa !14
  %91 = zext i16 %90 to i32
  %92 = or i32 %91, 4
  %93 = trunc i32 %92 to i16
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.tcp_pcb, ptr %94, i32 0, i32 12
  store i16 %93, ptr %95, align 2, !tbaa !14
  br label %96

96:                                               ; preds = %87
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.tcp_pcb, ptr %97, i32 0, i32 21
  store i16 0, ptr %98, align 8, !tbaa !19
  br label %99

99:                                               ; preds = %96, %23
  br label %100

100:                                              ; preds = %99, %16, %11
  ret void
}

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 = { 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" }

!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 = !{!10, !13, i64 42}
!15 = !{!10, !13, i64 88}
!16 = !{!10, !13, i64 112}
!17 = !{!10, !13, i64 90}
!18 = !{!10, !13, i64 66}
!19 = !{!10, !13, i64 64}


; 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.34 = external hidden unnamed_addr constant [29 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @tcp_rexmit(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @tcp_rexmit_fast(ptr noundef %0) local_unnamed_addr #1 {
  %.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.34, i32 noundef 1785, ptr noundef nonnull @.str.2)
  br label %4

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

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 42
  %9 = load i16, ptr %8, align 2, !tbaa !13
  %10 = and i16 %9, 4
  %.not22 = icmp eq i16 %10, 0
  br i1 %.not22, label %11, label %36

11:                                               ; preds = %7
  %12 = tail call signext i8 @tcp_rexmit(ptr noundef nonnull %0)
  %13 = icmp eq i8 %12, 0
  br i1 %13, label %14, label %36

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  %16 = load i16, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %0, i64 112
  %18 = load i16, ptr %17, align 8, !tbaa !15
  %. = tail call i16 @llvm.umin.i16(i16 %16, i16 %18)
  %19 = lshr i16 %., 1
  %20 = getelementptr inbounds i8, ptr %0, i64 90
  store i16 %19, ptr %20, align 2, !tbaa !16
  %21 = zext nneg i16 %19 to i32
  %22 = getelementptr inbounds i8, ptr %0, i64 66
  %23 = load i16, ptr %22, align 2, !tbaa !17
  %24 = zext i16 %23 to i32
  %25 = shl nuw nsw i32 %24, 1
  %26 = icmp ugt i32 %25, %21
  br i1 %26, label %27, label %29

27:                                               ; preds = %14
  %28 = trunc i32 %25 to i16
  store i16 %28, ptr %20, align 2, !tbaa !16
  br label %29

29:                                               ; preds = %27, %14
  %30 = phi i16 [ %28, %27 ], [ %19, %14 ]
  %31 = mul i16 %23, 3
  %32 = add i16 %30, %31
  store i16 %32, ptr %15, align 8, !tbaa !14
  %33 = load i16, ptr %8, align 2, !tbaa !13
  %34 = or i16 %33, 4
  store i16 %34, ptr %8, align 2, !tbaa !13
  %35 = getelementptr inbounds i8, ptr %0, i64 64
  store i16 0, ptr %35, align 8, !tbaa !18
  br label %36

36:                                               ; preds = %11, %29, %7, %4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.umin.i16(i16, i16) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!6, !12, i64 42}
!14 = !{!6, !12, i64 88}
!15 = !{!6, !12, i64 112}
!16 = !{!6, !12, i64 90}
!17 = !{!6, !12, i64 66}
!18 = !{!6, !12, i64 64}


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