; 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: nounwind uwtable
define dso_local void @dhcp_coarse_tmr() #0 {
  %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 = %75, %0
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %79

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 %74

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

20:                                               ; preds = %14
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.dhcp, ptr %21, i32 0, i32 11
  %23 = load i16, ptr %22, align 4, !tbaa !14
  %24 = zext i16 %23 to i32
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %41

26:                                               ; preds = %20
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.dhcp, ptr %27, i32 0, i32 10
  %29 = load i16, ptr %28, align 2, !tbaa !15
  %30 = add i16 %29, 1
  store i16 %30, ptr %28, align 2, !tbaa !15
  %31 = zext i16 %30 to i32
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.dhcp, ptr %32, i32 0, i32 11
  %34 = load i16, ptr %33, align 4, !tbaa !14
  %35 = zext i16 %34 to i32
  %36 = icmp eq i32 %31, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %26
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  call void @dhcp_release_and_stop(ptr noundef %38)
  %39 = load ptr, ptr %1, align 8, !tbaa !5
  %40 = call signext i8 @dhcp_start(ptr noundef %39)
  br label %73

41:                                               ; preds = %26, %20
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.dhcp, ptr %42, i32 0, i32 9
  %44 = load i16, ptr %43, align 4, !tbaa !16
  %45 = zext i16 %44 to i32
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %56

47:                                               ; preds = %41
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.dhcp, ptr %48, i32 0, i32 9
  %50 = load i16, ptr %49, align 4, !tbaa !16
  %51 = add i16 %50, -1
  store i16 %51, ptr %49, align 4, !tbaa !16
  %52 = zext i16 %50 to i32
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %56

54:                                               ; preds = %47
  %55 = load ptr, ptr %1, align 8, !tbaa !5
  call void @dhcp_t2_timeout(ptr noundef %55)
  br label %72

56:                                               ; preds = %47, %41
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.dhcp, ptr %57, i32 0, i32 8
  %59 = load i16, ptr %58, align 2, !tbaa !17
  %60 = zext i16 %59 to i32
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %71

62:                                               ; preds = %56
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.dhcp, ptr %63, i32 0, i32 8
  %65 = load i16, ptr %64, align 2, !tbaa !17
  %66 = add i16 %65, -1
  store i16 %66, ptr %64, align 2, !tbaa !17
  %67 = zext i16 %65 to i32
  %68 = icmp eq i32 %67, 1
  br i1 %68, label %69, label %71

69:                                               ; preds = %62
  %70 = load ptr, ptr %1, align 8, !tbaa !5
  call void @dhcp_t1_timeout(ptr noundef %70)
  br label %71

71:                                               ; preds = %69, %62, %56
  br label %72

72:                                               ; preds = %71, %54
  br label %73

73:                                               ; preds = %72, %37
  br label %74

74:                                               ; preds = %73, %14, %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr %1, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.netif, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  store ptr %78, ptr %1, align 8, !tbaa !5
  br label %4, !llvm.loop !20

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

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

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

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

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

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

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 5}
!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 = !{!10, !12, i64 20}
!15 = !{!10, !12, i64 18}
!16 = !{!10, !12, i64 16}
!17 = !{!10, !12, i64 14}
!18 = !{!19, !6, i64 0}
!19 = !{!"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}
!20 = distinct !{!20, !21}
!21 = !{!"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_coarse_tmr() local_unnamed_addr #0 {
  %.024 = load ptr, ptr @netif_list, align 8, !tbaa !5
  %.not25 = icmp eq ptr %.024, null
  br i1 %.not25, label %._crit_edge, label %.lr.ph

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

3:                                                ; preds = %.lr.ph
  %4 = getelementptr inbounds i8, ptr %2, i64 5
  %5 = load i8, ptr %4, align 1, !tbaa !9
  %.not20 = icmp eq i8 %5, 0
  br i1 %.not20, label %30, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %2, i64 20
  %8 = load i16, ptr %7, align 4, !tbaa !14
  %.not21 = icmp eq i16 %8, 0
  br i1 %.not21, label %16, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %2, i64 18
  %11 = load i16, ptr %10, align 2, !tbaa !15
  %12 = add i16 %11, 1
  store i16 %12, ptr %10, align 2, !tbaa !15
  %13 = icmp eq i16 %12, %8
  br i1 %13, label %14, label %16

14:                                               ; preds = %9
  tail call void @dhcp_release_and_stop(ptr noundef nonnull %.026)
  %15 = tail call signext i8 @dhcp_start(ptr noundef nonnull %.026)
  br label %30

16:                                               ; preds = %9, %6
  %17 = getelementptr inbounds i8, ptr %2, i64 16
  %18 = load i16, ptr %17, align 4, !tbaa !16
  %.not22 = icmp eq i16 %18, 0
  br i1 %.not22, label %23, label %19

19:                                               ; preds = %16
  %20 = add i16 %18, -1
  store i16 %20, ptr %17, align 4, !tbaa !16
  %21 = icmp eq i16 %18, 1
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  tail call void @dhcp_t2_timeout(ptr noundef nonnull %.026)
  br label %30

23:                                               ; preds = %19, %16
  %24 = getelementptr inbounds i8, ptr %2, i64 14
  %25 = load i16, ptr %24, align 2, !tbaa !17
  %.not23 = icmp eq i16 %25, 0
  br i1 %.not23, label %30, label %26

26:                                               ; preds = %23
  %27 = add i16 %25, -1
  store i16 %27, ptr %24, align 2, !tbaa !17
  %28 = icmp eq i16 %25, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  tail call void @dhcp_t1_timeout(ptr noundef nonnull %.026)
  br label %30

30:                                               ; preds = %14, %23, %26, %29, %22, %3, %.lr.ph
  %.0 = load ptr, ptr %.026, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @dhcp_t1_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, !7, i64 5}
!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 = !{!10, !12, i64 20}
!15 = !{!10, !12, i64 18}
!16 = !{!10, !12, i64 16}
!17 = !{!10, !12, i64 14}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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