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

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

%union.tcp_listen_pcbs_t = type { ptr }
%struct.ip4_addr = type { i32 }
%struct.tcp_pcb_listen = type { %struct.ip4_addr, %struct.ip4_addr, i8, i8, i8, i8, ptr, ptr, i32, i8, i16, ptr }

@tcp_listen_pcbs = external dso_local global %union.tcp_listen_pcbs_t, align 8
@tcp_bound_pcbs = external dso_local global ptr, align 8
@tcp_active_pcbs = external dso_local global ptr, align 8

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

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

; Function Attrs: nounwind uwtable
define dso_local void @tcp_netif_ip_addr_changed(ptr noundef %0, ptr noundef %1) #1 {
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %53, label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.ip4_addr, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %53, label %13

13:                                               ; preds = %8
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load ptr, ptr @tcp_active_pcbs, align 8, !tbaa !5
  call void @tcp_netif_ip_addr_changed_pcblist(ptr noundef %14, ptr noundef %15)
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr @tcp_bound_pcbs, align 8, !tbaa !5
  call void @tcp_netif_ip_addr_changed_pcblist(ptr noundef %16, ptr noundef %17)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %52, label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ip4_addr, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %52, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr @tcp_listen_pcbs, align 8, !tbaa !12
  store ptr %26, ptr %5, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %47, %25
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %51

30:                                               ; preds = %27
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.tcp_pcb_listen, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.ip4_addr, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ip4_addr, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = icmp eq i32 %34, %37
  br i1 %38, label %39, label %46

39:                                               ; preds = %30
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ip4_addr, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tcp_pcb_listen, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.ip4_addr, ptr %44, i32 0, i32 0
  store i32 %42, ptr %45, align 8, !tbaa !13
  br label %46

46:                                               ; preds = %39, %30
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.tcp_pcb_listen, ptr %48, i32 0, i32 6
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  store ptr %50, ptr %5, align 8, !tbaa !5
  br label %27, !llvm.loop !17

51:                                               ; preds = %27
  br label %52

52:                                               ; preds = %51, %20, %13
  br label %53

53:                                               ; preds = %52, %8, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @tcp_netif_ip_addr_changed_pcblist(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !11, i64 0}
!10 = !{!"ip4_addr", !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"tcp_pcb_listen", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !6, i64 16, !6, i64 24, !11, i64 32, !7, i64 36, !15, i64 38, !6, i64 40}
!15 = !{!"short", !7, i64 0}
!16 = !{!14, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

%union.tcp_listen_pcbs_t = type { ptr }

@tcp_listen_pcbs = external dso_local local_unnamed_addr global %union.tcp_listen_pcbs_t, align 8
@tcp_bound_pcbs = external dso_local local_unnamed_addr global ptr, align 8
@tcp_active_pcbs = external dso_local local_unnamed_addr global ptr, align 8

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

4:                                                ; preds = %2
  %5 = load i32, ptr %0, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %4
  %8 = load ptr, ptr @tcp_active_pcbs, align 8, !tbaa !10
  tail call void @tcp_netif_ip_addr_changed_pcblist(ptr noundef nonnull %0, ptr noundef %8)
  %9 = load ptr, ptr @tcp_bound_pcbs, align 8, !tbaa !10
  tail call void @tcp_netif_ip_addr_changed_pcblist(ptr noundef nonnull %0, ptr noundef %9)
  %10 = icmp eq ptr %1, null
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %7
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 0
  %.014 = load ptr, ptr @tcp_listen_pcbs, align 8
  %.not15 = icmp eq ptr %.014, null
  %or.cond = select i1 %13, i1 true, i1 %.not15
  br i1 %or.cond, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %11, %18
  %.016 = phi ptr [ %.0, %18 ], [ %.014, %11 ]
  %14 = load i32, ptr %.016, align 8, !tbaa !12
  %15 = load i32, ptr %0, align 4, !tbaa !5
  %16 = icmp eq i32 %14, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %.lr.ph
  store i32 %12, ptr %.016, align 8, !tbaa !12
  br label %18

18:                                               ; preds = %.lr.ph, %17
  %19 = getelementptr inbounds i8, ptr %.016, i64 16
  %.0 = load ptr, ptr %19, align 8, !tbaa !15
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !16

.loopexit:                                        ; preds = %18, %7, %11, %4, %2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @tcp_netif_ip_addr_changed_pcblist(ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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, !7, i64 0}
!6 = !{!"ip4_addr", !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"tcp_pcb_listen", !6, i64 0, !6, i64 4, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !11, i64 16, !11, i64 24, !7, i64 32, !8, i64 36, !14, i64 38, !11, i64 40}
!14 = !{!"short", !8, i64 0}
!15 = !{!8, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass