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

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

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [184 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local signext i8 @dhcp_start(ptr noundef %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  br label %7

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %15, label %10

10:                                               ; preds = %7
  br label %11

11:                                               ; preds = %10
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 743, ptr noundef @.str.2)
  br label %13

13:                                               ; preds = %11
  br label %14

14:                                               ; preds = %13
  store i8 -16, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

15:                                               ; preds = %7
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  br label %18

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

25:                                               ; preds = %18
  br i1 true, label %32, label %27

26:                                               ; preds = %18
  br i1 false, label %32, label %27

27:                                               ; preds = %26, %25
  br label %28

28:                                               ; preds = %27
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.5, i32 noundef 744, ptr noundef @.str.2)
  br label %30

30:                                               ; preds = %28
  br label %31

31:                                               ; preds = %30
  store i8 -16, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

32:                                               ; preds = %26, %25
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.netif, ptr %35, i32 0, i32 9
  %37 = getelementptr inbounds [1 x ptr], ptr %36, i64 0, i64 0
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  store ptr %38, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.netif, ptr %39, i32 0, i32 10
  %41 = load i16, ptr %40, align 8, !tbaa !14
  %42 = zext i16 %41 to i32
  %43 = icmp slt i32 %42, 576
  br i1 %43, label %44, label %45

44:                                               ; preds = %34
  store i8 -1, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

45:                                               ; preds = %34
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %58

48:                                               ; preds = %45
  %49 = call ptr @mem_malloc(i16 noundef zeroext 52)
  store ptr %49, ptr %4, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %53

52:                                               ; preds = %48
  store i8 -1, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

53:                                               ; preds = %48
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.netif, ptr %55, i32 0, i32 9
  %57 = getelementptr inbounds [1 x ptr], ptr %56, i64 0, i64 0
  store ptr %54, ptr %57, align 8, !tbaa !5
  br label %66

58:                                               ; preds = %45
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.dhcp, ptr %59, i32 0, i32 1
  %61 = load i8, ptr %60, align 4, !tbaa !15
  %62 = zext i8 %61 to i32
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %58
  call void @dhcp_dec_pcb_refcount()
  br label %65

65:                                               ; preds = %64, %58
  br label %66

66:                                               ; preds = %65, %53
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 4 %67, i8 0, i64 52, i1 false)
  %68 = call signext i8 @dhcp_inc_pcb_refcount()
  %69 = sext i8 %68 to i32
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %66
  store i8 -1, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

72:                                               ; preds = %66
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.dhcp, ptr %73, i32 0, i32 1
  store i8 1, ptr %74, align 4, !tbaa !15
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.netif, ptr %75, i32 0, i32 13
  %77 = load i8, ptr %76, align 1, !tbaa !9
  %78 = zext i8 %77 to i32
  %79 = and i32 %78, 4
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %72
  br i1 true, label %85, label %83

82:                                               ; preds = %72
  br i1 false, label %85, label %83

83:                                               ; preds = %82, %81
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  call void @dhcp_set_state(ptr noundef %84, i8 noundef zeroext 2)
  store i8 0, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

85:                                               ; preds = %82, %81
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = call signext i8 @dhcp_discover(ptr noundef %86)
  store i8 %87, ptr %5, align 1, !tbaa !17
  %88 = load i8, ptr %5, align 1, !tbaa !17
  %89 = sext i8 %88 to i32
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %93

91:                                               ; preds = %85
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  call void @dhcp_release_and_stop(ptr noundef %92)
  store i8 -1, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

93:                                               ; preds = %85
  %94 = load i8, ptr %5, align 1, !tbaa !17
  store i8 %94, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %95

95:                                               ; preds = %93, %91, %83, %71, %52, %44, %31, %14
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %96 = load i8, ptr %2, align 1
  ret i8 %96
}

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare ptr @mem_malloc(i16 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare hidden void @dhcp_dec_pcb_refcount() #1

; Function Attrs: nounwind uwtable
declare hidden signext i8 @dhcp_inc_pcb_refcount() #1

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @dhcp_discover(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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 81}
!10 = !{!"netif", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !13, i64 72, !7, i64 74, !7, i64 80, !7, i64 81, !7, i64 82, !7, i64 84, !7, i64 85}
!11 = !{!"ip4_addr", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !13, i64 72}
!15 = !{!16, !7, i64 4}
!16 = !{!"dhcp", !12, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !13, i64 18, !13, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 44, !12, i64 48}
!17 = !{!7, !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.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [184 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local noundef signext i8 @dhcp_start(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %4

2:                                                ; preds = %1
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.1, i32 noundef 743, ptr noundef nonnull @.str.2)
  br label %36

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 81
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = and i8 %6, 1
  %.not21 = icmp eq i8 %7, 0
  br i1 %.not21, label %8, label %10

8:                                                ; preds = %4
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.5, i32 noundef 744, ptr noundef nonnull @.str.2)
  br label %36

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  %14 = load i16, ptr %13, align 8, !tbaa !14
  %15 = icmp ult i16 %14, 576
  br i1 %15, label %36, label %16

16:                                               ; preds = %10
  %17 = icmp eq ptr %12, null
  br i1 %17, label %18, label %22

18:                                               ; preds = %16
  %19 = tail call ptr @mem_malloc(i16 noundef zeroext 52) #4
  %20 = icmp eq ptr %19, null
  br i1 %20, label %36, label %21

21:                                               ; preds = %18
  store ptr %19, ptr %11, align 8, !tbaa !13
  br label %26

22:                                               ; preds = %16
  %23 = getelementptr inbounds i8, ptr %12, i64 4
  %24 = load i8, ptr %23, align 4, !tbaa !15
  %.not22 = icmp eq i8 %24, 0
  br i1 %.not22, label %26, label %25

25:                                               ; preds = %22
  tail call void @dhcp_dec_pcb_refcount()
  br label %26

26:                                               ; preds = %22, %25, %21
  %.017 = phi ptr [ %19, %21 ], [ %12, %25 ], [ %12, %22 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(52) %.017, i8 0, i64 52, i1 false)
  %27 = tail call signext i8 @dhcp_inc_pcb_refcount()
  %.not23 = icmp eq i8 %27, 0
  br i1 %.not23, label %28, label %36

28:                                               ; preds = %26
  %29 = getelementptr inbounds i8, ptr %.017, i64 4
  store i8 1, ptr %29, align 4, !tbaa !15
  %30 = load i8, ptr %5, align 1, !tbaa !5
  %31 = and i8 %30, 4
  %.not24 = icmp eq i8 %31, 0
  br i1 %.not24, label %32, label %33

32:                                               ; preds = %28
  tail call void @dhcp_set_state(ptr noundef nonnull %.017, i8 noundef zeroext 2)
  br label %36

33:                                               ; preds = %28
  %34 = tail call signext i8 @dhcp_discover(ptr noundef nonnull %0)
  %.not25 = icmp eq i8 %34, 0
  br i1 %.not25, label %36, label %35

35:                                               ; preds = %33
  tail call void @dhcp_release_and_stop(ptr noundef nonnull %0)
  br label %36

36:                                               ; preds = %33, %26, %18, %10, %35, %32, %8, %2
  %.0 = phi i8 [ -1, %35 ], [ 0, %32 ], [ -16, %8 ], [ -16, %2 ], [ -1, %10 ], [ -1, %18 ], [ -1, %26 ], [ 0, %33 ]
  ret i8 %.0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare ptr @mem_malloc(i16 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @dhcp_dec_pcb_refcount() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden signext i8 @dhcp_inc_pcb_refcount() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @dhcp_discover(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" }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 #4 = { 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, !8, i64 81}
!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}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !12, i64 72}
!15 = !{!16, !8, i64 4}
!16 = !{!"dhcp", !11, i64 0, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !12, i64 8, !12, i64 10, !12, i64 12, !12, i64 14, !12, i64 16, !12, i64 18, !12, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !11, i64 40, !11, i64 44, !11, i64 48}


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