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

@netif_list = external dso_local global ptr, align 8
@netif_default = 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 @netif_remove(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  br label %71

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

14:                                               ; preds = %8
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.netif, ptr %15, i32 0, i32 1
  call void @netif_do_ip_addr_changed(ptr noundef %16, ptr noundef null)
  br label %17

17:                                               ; preds = %14, %8
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.netif, ptr %18, i32 0, i32 13
  %20 = load i8, ptr %19, align 1, !tbaa !12
  %21 = zext i8 %20 to i32
  %22 = and i32 %21, 1
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %17
  br i1 true, label %26, label %28

25:                                               ; preds = %17
  br i1 false, label %26, label %28

26:                                               ; preds = %25, %24
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  call void @netif_set_down(ptr noundef %27)
  br label %28

28:                                               ; preds = %26, %25, %24
  %29 = load ptr, ptr @netif_default, align 8, !tbaa !5
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = icmp eq ptr %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  call void @netif_set_default(ptr noundef null)
  br label %33

33:                                               ; preds = %32, %28
  %34 = load ptr, ptr @netif_list, align 8, !tbaa !5
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = icmp eq ptr %34, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %33
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.netif, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  store ptr %40, ptr @netif_list, align 8, !tbaa !5
  br label %71

41:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %42 = load ptr, ptr @netif_list, align 8, !tbaa !5
  store ptr %42, ptr %3, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %59, %41
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %63

46:                                               ; preds = %43
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.netif, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = icmp eq ptr %49, %50
  br i1 %51, label %52, label %58

52:                                               ; preds = %46
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.netif, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.netif, ptr %56, i32 0, i32 0
  store ptr %55, ptr %57, align 8, !tbaa !15
  br label %63

58:                                               ; preds = %46
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.netif, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  store ptr %62, ptr %3, align 8, !tbaa !5
  br label %43, !llvm.loop !16

63:                                               ; preds = %52, %43
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = icmp eq ptr %64, null
  br i1 %65, label %66, label %67

66:                                               ; preds = %63
  store i32 1, ptr %4, align 4
  br label %68

67:                                               ; preds = %63
  store i32 0, ptr %4, align 4
  br label %68

68:                                               ; preds = %67, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  %69 = load i32, ptr %4, align 4
  switch i32 %69, label %72 [
    i32 0, label %70
    i32 1, label %71
  ]

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70, %68, %37, %7
  ret void

72:                                               ; preds = %68
  unreachable
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @netif_set_default(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 = !{!13, !7, i64 81}
!13 = !{!"netif", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !14, i64 72, !7, i64 74, !7, i64 80, !7, i64 81, !7, i64 82, !7, i64 84, !7, i64 85}
!14 = !{!"short", !7, i64 0}
!15 = !{!13, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@netif_list = external dso_local local_unnamed_addr global ptr, align 8
@netif_default = external dso_local local_unnamed_addr global ptr, align 8

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

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

7:                                                ; preds = %3
  tail call void @netif_do_ip_addr_changed(ptr noundef nonnull %4, ptr noundef null)
  br label %8

8:                                                ; preds = %7, %3
  %9 = getelementptr inbounds i8, ptr %0, i64 81
  %10 = load i8, ptr %9, align 1, !tbaa !10
  %11 = and i8 %10, 1
  %.not = icmp eq i8 %11, 0
  br i1 %.not, label %13, label %12

12:                                               ; preds = %8
  tail call void @netif_set_down(ptr noundef nonnull %0)
  br label %13

13:                                               ; preds = %8, %12
  %14 = load ptr, ptr @netif_default, align 8, !tbaa !14
  %15 = icmp eq ptr %14, %0
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  tail call void @netif_set_default(ptr noundef null)
  br label %17

17:                                               ; preds = %16, %13
  %18 = load ptr, ptr @netif_list, align 8, !tbaa !14
  %19 = icmp eq ptr %18, %0
  br i1 %19, label %.loopexit.sink.split, label %.preheader

.preheader:                                       ; preds = %17, %20
  %.0 = phi ptr [ %21, %20 ], [ %18, %17 ]
  %cond = icmp eq ptr %.0, null
  br i1 %cond, label %.loopexit, label %20

20:                                               ; preds = %.preheader
  %21 = load ptr, ptr %.0, align 8, !tbaa !15
  %22 = icmp eq ptr %21, %0
  br i1 %22, label %.loopexit.sink.split, label %.preheader, !llvm.loop !16

.loopexit.sink.split:                             ; preds = %20, %17
  %.0.lcssa21.sink = phi ptr [ @netif_list, %17 ], [ %.0, %20 ]
  %23 = load ptr, ptr %0, align 8, !tbaa !15
  store ptr %23, ptr %.0.lcssa21.sink, align 8, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.sink.split, %1
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @netif_set_default(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, !8, i64 81}
!11 = !{!"netif", !12, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !8, i64 64, !13, i64 72, !8, i64 74, !8, i64 80, !8, i64 81, !8, i64 82, !8, i64 84, !8, i64 85}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!11, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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