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

; 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.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 }

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [178 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [39 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %21, label %16

16:                                               ; preds = %13
  br label %17

17:                                               ; preds = %16
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.42, i32 noundef 2245, ptr noundef @.str.2)
  br label %19

19:                                               ; preds = %17
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20, %13
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = load i16, ptr %5, align 2, !tbaa !5
  store i16 %27, ptr %4, align 2
  store i32 1, ptr %10, align 4
  br label %69

28:                                               ; preds = %23
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.netif, ptr %29, i32 0, i32 10
  %31 = load i16, ptr %30, align 8, !tbaa !11
  store i16 %31, ptr %9, align 2, !tbaa !5
  %32 = load i16, ptr %9, align 2, !tbaa !5
  %33 = zext i16 %32 to i32
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %67

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #3
  store i16 40, ptr %11, align 2, !tbaa !5
  %36 = load i16, ptr %9, align 2, !tbaa !5
  %37 = zext i16 %36 to i32
  %38 = load i16, ptr %11, align 2, !tbaa !5
  %39 = zext i16 %38 to i32
  %40 = icmp sgt i32 %37, %39
  br i1 %40, label %41, label %49

41:                                               ; preds = %35
  %42 = load i16, ptr %9, align 2, !tbaa !5
  %43 = zext i16 %42 to i32
  %44 = load i16, ptr %11, align 2, !tbaa !5
  %45 = zext i16 %44 to i32
  %46 = sub nsw i32 %43, %45
  %47 = trunc i32 %46 to i16
  %48 = zext i16 %47 to i32
  br label %50

49:                                               ; preds = %35
  br label %50

50:                                               ; preds = %49, %41
  %51 = phi i32 [ %48, %41 ], [ 0, %49 ]
  %52 = trunc i32 %51 to i16
  store i16 %52, ptr %8, align 2, !tbaa !5
  %53 = load i16, ptr %5, align 2, !tbaa !5
  %54 = zext i16 %53 to i32
  %55 = load i16, ptr %8, align 2, !tbaa !5
  %56 = zext i16 %55 to i32
  %57 = icmp slt i32 %54, %56
  br i1 %57, label %58, label %61

58:                                               ; preds = %50
  %59 = load i16, ptr %5, align 2, !tbaa !5
  %60 = zext i16 %59 to i32
  br label %64

61:                                               ; preds = %50
  %62 = load i16, ptr %8, align 2, !tbaa !5
  %63 = zext i16 %62 to i32
  br label %64

64:                                               ; preds = %61, %58
  %65 = phi i32 [ %60, %58 ], [ %63, %61 ]
  %66 = trunc i32 %65 to i16
  store i16 %66, ptr %5, align 2, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #3
  br label %67

67:                                               ; preds = %64, %28
  %68 = load i16, ptr %5, align 2, !tbaa !5
  store i16 %68, ptr %4, align 2
  store i32 1, ptr %10, align 4
  br label %69

69:                                               ; preds = %67, %26
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #3
  %70 = load i16, ptr %4, align 2
  ret i16 %70
}

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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 72}
!12 = !{!"netif", !10, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !6, i64 72, !7, i64 74, !7, i64 80, !7, i64 81, !7, i64 82, !7, i64 84, !7, i64 85}
!13 = !{!"ip4_addr", !14, i64 0}
!14 = !{!"int", !7, i64 0}


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

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

; Function Attrs: nofree nounwind uwtable
define dso_local zeroext i16 @tcp_eff_send_mss_netif(i16 noundef zeroext %0, ptr noundef readonly %1, ptr noundef readnone %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %4, label %6

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

6:                                                ; preds = %4, %3
  %7 = icmp eq ptr %1, null
  br i1 %7, label %13, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %1, i64 72
  %10 = load i16, ptr %9, align 8, !tbaa !5
  %.not18 = icmp eq i16 %10, 0
  br i1 %.not18, label %13, label %11

11:                                               ; preds = %8
  %narrow = tail call i16 @llvm.usub.sat.i16(i16 %10, i16 40)
  %12 = tail call i16 @llvm.umin.i16(i16 %0, i16 %narrow)
  br label %13

13:                                               ; preds = %8, %11, %6
  %.0 = phi i16 [ %0, %6 ], [ %12, %11 ], [ %0, %8 ]
  ret i16 %.0
}

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

; 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 = { nofree 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, !12, i64 72}
!6 = !{!"netif", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !8, i64 64, !12, i64 72, !8, i64 74, !8, i64 80, !8, i64 81, !8, i64 82, !8, i64 84, !8, i64 85}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"ip4_addr", !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}


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