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

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

@netif_list = external 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 @dhcp_fine_tmr() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  %3 = load ptr, ptr @netif_list, align 8, !tbaa !5
  store ptr %3, ptr %1, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %40, %0
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %44

7:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.netif, ptr %8, i32 0, i32 9
  %10 = getelementptr inbounds [1 x ptr], ptr %9, i64 0, i64 0
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %11, ptr %2, align 8, !tbaa !5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %39

14:                                               ; preds = %7
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.dhcp, ptr %15, i32 0, i32 5
  %17 = load i16, ptr %16, align 4, !tbaa !9
  %18 = zext i16 %17 to i32
  %19 = icmp sgt i32 %18, 1
  br i1 %19, label %20, label %25

20:                                               ; preds = %14
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.dhcp, ptr %21, i32 0, i32 5
  %23 = load i16, ptr %22, align 4, !tbaa !9
  %24 = add i16 %23, -1
  store i16 %24, ptr %22, align 4, !tbaa !9
  br label %38

25:                                               ; preds = %14
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.dhcp, ptr %26, i32 0, i32 5
  %28 = load i16, ptr %27, align 4, !tbaa !9
  %29 = zext i16 %28 to i32
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %37

31:                                               ; preds = %25
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.dhcp, ptr %32, i32 0, i32 5
  %34 = load i16, ptr %33, align 4, !tbaa !9
  %35 = add i16 %34, -1
  store i16 %35, ptr %33, align 4, !tbaa !9
  %36 = load ptr, ptr %1, align 8, !tbaa !5
  call void @dhcp_timeout(ptr noundef %36)
  br label %37

37:                                               ; preds = %31, %25
  br label %38

38:                                               ; preds = %37, %20
  br label %39

39:                                               ; preds = %38, %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %1, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.netif, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  store ptr %43, ptr %1, align 8, !tbaa !5
  br label %4, !llvm.loop !16

44:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @dhcp_timeout(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, !12, i64 8}
!10 = !{!"dhcp", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !12, i64 8, !12, i64 10, !12, i64 12, !12, i64 14, !12, i64 16, !12, i64 18, !12, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !11, i64 40, !11, i64 44, !11, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"ip4_addr", !11, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"netif", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !12, i64 72, !7, i64 74, !7, i64 80, !7, i64 81, !7, i64 82, !7, i64 84, !7, i64 85}
!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 local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @dhcp_fine_tmr() local_unnamed_addr #0 {
  %.012 = load ptr, ptr @netif_list, align 8, !tbaa !5
  %.not13 = icmp eq ptr %.012, null
  br i1 %.not13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %12
  %.014 = phi ptr [ %.0, %12 ], [ %.012, %0 ]
  %1 = getelementptr inbounds i8, ptr %.014, i64 64
  %2 = load ptr, ptr %1, align 8, !tbaa !5
  %.not11 = icmp eq ptr %2, null
  br i1 %.not11, label %12, label %3

3:                                                ; preds = %.lr.ph
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %5 = load i16, ptr %4, align 4, !tbaa !9
  %6 = icmp ugt i16 %5, 1
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = add i16 %5, -1
  store i16 %8, ptr %4, align 4, !tbaa !9
  br label %12

9:                                                ; preds = %3
  %10 = icmp eq i16 %5, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  store i16 0, ptr %4, align 4, !tbaa !9
  tail call void @dhcp_timeout(ptr noundef nonnull %.014)
  br label %12

12:                                               ; preds = %7, %11, %9, %.lr.ph
  %.0 = load ptr, ptr %.014, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %12, %0
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @dhcp_timeout(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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"dhcp", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !12, i64 8, !12, i64 10, !12, i64 12, !12, i64 14, !12, i64 16, !12, i64 18, !12, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !11, i64 40, !11, i64 44, !11, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"ip4_addr", !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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