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

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

@tcp_ticks = external dso_local global i32, align 4
@tcp_timer_ctr = external hidden global 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @memp_malloc(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @tcp_recv_null(ptr noundef, ptr noundef, ptr noundef, i8 noundef signext) #2

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

7:                                                ; preds = %1
  call void @tcp_handle_closepend()
  call void @tcp_kill_timewait()
  %8 = call ptr @memp_malloc(i32 noundef 1)
  store ptr %8, ptr %3, align 8, !tbaa !8
  %9 = load ptr, ptr %3, align 8, !tbaa !8
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %36

11:                                               ; preds = %7
  call void @tcp_kill_state(i32 noundef 9)
  %12 = call ptr @memp_malloc(i32 noundef 1)
  store ptr %12, ptr %3, align 8, !tbaa !8
  %13 = load ptr, ptr %3, align 8, !tbaa !8
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %31

15:                                               ; preds = %11
  call void @tcp_kill_state(i32 noundef 8)
  %16 = call ptr @memp_malloc(i32 noundef 1)
  store ptr %16, ptr %3, align 8, !tbaa !8
  %17 = load ptr, ptr %3, align 8, !tbaa !8
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %26

19:                                               ; preds = %15
  %20 = load i8, ptr %2, align 1, !tbaa !5
  call void @tcp_kill_prio(i8 noundef zeroext %20)
  %21 = call ptr @memp_malloc(i32 noundef 1)
  store ptr %21, ptr %3, align 8, !tbaa !8
  %22 = load ptr, ptr %3, align 8, !tbaa !8
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  br label %25

25:                                               ; preds = %24, %19
  br label %26

26:                                               ; preds = %25, %15
  %27 = load ptr, ptr %3, align 8, !tbaa !8
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %30

30:                                               ; preds = %29, %26
  br label %31

31:                                               ; preds = %30, %11
  %32 = load ptr, ptr %3, align 8, !tbaa !8
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %35

35:                                               ; preds = %34, %31
  br label %36

36:                                               ; preds = %35, %7
  %37 = load ptr, ptr %3, align 8, !tbaa !8
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  br label %40

40:                                               ; preds = %39, %36
  br label %41

41:                                               ; preds = %40, %1
  %42 = load ptr, ptr %3, align 8, !tbaa !8
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %79

44:                                               ; preds = %41
  %45 = load ptr, ptr %3, align 8, !tbaa !8
  call void @llvm.memset.p0.i64(ptr align 8 %45, i8 0, i64 208, i1 false)
  %46 = load i8, ptr %2, align 1, !tbaa !5
  %47 = load ptr, ptr %3, align 8, !tbaa !8
  %48 = getelementptr inbounds %struct.tcp_pcb, ptr %47, i32 0, i32 9
  store i8 %46, ptr %48, align 4, !tbaa !10
  %49 = load ptr, ptr %3, align 8, !tbaa !8
  %50 = getelementptr inbounds %struct.tcp_pcb, ptr %49, i32 0, i32 40
  store i16 5840, ptr %50, align 4, !tbaa !15
  %51 = load ptr, ptr %3, align 8, !tbaa !8
  %52 = getelementptr inbounds %struct.tcp_pcb, ptr %51, i32 0, i32 19
  store i16 2920, ptr %52, align 2, !tbaa !16
  %53 = load ptr, ptr %3, align 8, !tbaa !8
  %54 = getelementptr inbounds %struct.tcp_pcb, ptr %53, i32 0, i32 18
  store i16 2920, ptr %54, align 8, !tbaa !17
  %55 = load ptr, ptr %3, align 8, !tbaa !8
  %56 = getelementptr inbounds %struct.tcp_pcb, ptr %55, i32 0, i32 5
  store i8 -1, ptr %56, align 1, !tbaa !18
  %57 = load ptr, ptr %3, align 8, !tbaa !8
  %58 = getelementptr inbounds %struct.tcp_pcb, ptr %57, i32 0, i32 22
  store i16 536, ptr %58, align 2, !tbaa !19
  %59 = load ptr, ptr %3, align 8, !tbaa !8
  %60 = getelementptr inbounds %struct.tcp_pcb, ptr %59, i32 0, i32 27
  store i16 6, ptr %60, align 8, !tbaa !20
  %61 = load ptr, ptr %3, align 8, !tbaa !8
  %62 = getelementptr inbounds %struct.tcp_pcb, ptr %61, i32 0, i32 26
  store i16 6, ptr %62, align 2, !tbaa !21
  %63 = load ptr, ptr %3, align 8, !tbaa !8
  %64 = getelementptr inbounds %struct.tcp_pcb, ptr %63, i32 0, i32 21
  store i16 -1, ptr %64, align 8, !tbaa !22
  %65 = load ptr, ptr %3, align 8, !tbaa !8
  %66 = getelementptr inbounds %struct.tcp_pcb, ptr %65, i32 0, i32 31
  store i16 1, ptr %66, align 8, !tbaa !23
  %67 = load i32, ptr @tcp_ticks, align 4, !tbaa !24
  %68 = load ptr, ptr %3, align 8, !tbaa !8
  %69 = getelementptr inbounds %struct.tcp_pcb, ptr %68, i32 0, i32 16
  store i32 %67, ptr %69, align 8, !tbaa !25
  %70 = load i8, ptr @tcp_timer_ctr, align 1, !tbaa !5
  %71 = load ptr, ptr %3, align 8, !tbaa !8
  %72 = getelementptr inbounds %struct.tcp_pcb, ptr %71, i32 0, i32 15
  store i8 %70, ptr %72, align 2, !tbaa !26
  %73 = load ptr, ptr %3, align 8, !tbaa !8
  %74 = getelementptr inbounds %struct.tcp_pcb, ptr %73, i32 0, i32 32
  store i16 5840, ptr %74, align 2, !tbaa !27
  %75 = load ptr, ptr %3, align 8, !tbaa !8
  %76 = getelementptr inbounds %struct.tcp_pcb, ptr %75, i32 0, i32 49
  store ptr @tcp_recv_null, ptr %76, align 8, !tbaa !28
  %77 = load ptr, ptr %3, align 8, !tbaa !8
  %78 = getelementptr inbounds %struct.tcp_pcb, ptr %77, i32 0, i32 53
  store i32 7200000, ptr %78, align 8, !tbaa !29
  br label %79

79:                                               ; preds = %44, %41
  %80 = load ptr, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %80
}

; Function Attrs: nounwind uwtable
declare hidden void @tcp_handle_closepend() #2

; Function Attrs: nounwind uwtable
declare hidden void @tcp_kill_timewait() #2

; Function Attrs: nounwind uwtable
declare hidden void @tcp_kill_state(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @tcp_kill_prio(i8 noundef zeroext) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !6, i64 36}
!11 = !{!"tcp_pcb", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 9, !6, i64 10, !6, i64 11, !9, i64 16, !9, i64 24, !13, i64 32, !6, i64 36, !14, i64 38, !14, i64 40, !14, i64 42, !6, i64 44, !6, i64 45, !6, i64 46, !13, i64 48, !13, i64 52, !14, i64 56, !14, i64 58, !13, i64 60, !14, i64 64, !14, i64 66, !13, i64 68, !13, i64 72, !14, i64 76, !14, i64 78, !14, i64 80, !6, i64 82, !6, i64 83, !13, i64 84, !14, i64 88, !14, i64 90, !13, i64 92, !13, i64 96, !13, i64 100, !13, i64 104, !13, i64 108, !14, i64 112, !14, i64 114, !14, i64 116, !14, i64 118, !14, i64 120, !14, i64 122, !9, i64 128, !9, i64 136, !9, i64 144, !9, i64 152, !9, i64 160, !9, i64 168, !9, i64 176, !9, i64 184, !9, i64 192, !13, i64 200, !6, i64 204, !6, i64 205, !6, i64 206, !6, i64 207}
!12 = !{!"ip4_addr", !13, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = !{!"short", !6, i64 0}
!15 = !{!11, !14, i64 116}
!16 = !{!11, !14, i64 58}
!17 = !{!11, !14, i64 56}
!18 = !{!11, !6, i64 11}
!19 = !{!11, !14, i64 66}
!20 = !{!11, !14, i64 80}
!21 = !{!11, !14, i64 78}
!22 = !{!11, !14, i64 64}
!23 = !{!11, !14, i64 88}
!24 = !{!13, !13, i64 0}
!25 = !{!11, !13, i64 48}
!26 = !{!11, !6, i64 46}
!27 = !{!11, !14, i64 90}
!28 = !{!11, !9, i64 168}
!29 = !{!11, !13, i64 200}


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

@tcp_ticks = external dso_local local_unnamed_addr global i32, align 4
@tcp_timer_ctr = external hidden local_unnamed_addr global i8, align 1

declare ptr @memp_malloc(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @tcp_recv_null(ptr noundef, ptr noundef, ptr noundef, i8 noundef signext) #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @tcp_alloc(i8 noundef zeroext %0) local_unnamed_addr #1 {
  %2 = tail call ptr @memp_malloc(i32 noundef 1) #3
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %.thread

4:                                                ; preds = %1
  tail call void @tcp_handle_closepend()
  tail call void @tcp_kill_timewait()
  %5 = tail call ptr @memp_malloc(i32 noundef 1) #3
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %.thread

7:                                                ; preds = %4
  tail call void @tcp_kill_state(i32 noundef 9)
  %8 = tail call ptr @memp_malloc(i32 noundef 1) #3
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %.thread

10:                                               ; preds = %7
  tail call void @tcp_kill_state(i32 noundef 8)
  %11 = tail call ptr @memp_malloc(i32 noundef 1) #3
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %.thread

13:                                               ; preds = %10
  tail call void @tcp_kill_prio(i8 noundef zeroext %0)
  %14 = tail call ptr @memp_malloc(i32 noundef 1) #3
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %32, label %.thread

.thread:                                          ; preds = %10, %7, %4, %1, %13
  %.333 = phi ptr [ %14, %13 ], [ %11, %10 ], [ %8, %7 ], [ %5, %4 ], [ %2, %1 ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(208) %.333, i8 0, i64 208, i1 false)
  %15 = getelementptr inbounds i8, ptr %.333, i64 36
  store i8 %0, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.333, i64 116
  store i16 5840, ptr %16, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %.333, i64 58
  store i16 2920, ptr %17, align 2, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %.333, i64 56
  store i16 2920, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %.333, i64 11
  store i8 -1, ptr %19, align 1, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %.333, i64 66
  store i16 536, ptr %20, align 2, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %.333, i64 80
  store i16 6, ptr %21, align 8, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %.333, i64 78
  store i16 6, ptr %22, align 2, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %.333, i64 64
  store i16 -1, ptr %23, align 8, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %.333, i64 88
  store i16 1, ptr %24, align 8, !tbaa !21
  %25 = load i32, ptr @tcp_ticks, align 4, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %.333, i64 48
  store i32 %25, ptr %26, align 8, !tbaa !23
  %27 = load i8, ptr @tcp_timer_ctr, align 1, !tbaa !24
  %28 = getelementptr inbounds i8, ptr %.333, i64 46
  store i8 %27, ptr %28, align 2, !tbaa !25
  %29 = getelementptr inbounds i8, ptr %.333, i64 90
  store i16 5840, ptr %29, align 2, !tbaa !26
  %30 = getelementptr inbounds i8, ptr %.333, i64 168
  store ptr @tcp_recv_null, ptr %30, align 8, !tbaa !27
  %31 = getelementptr inbounds i8, ptr %.333, i64 200
  store i32 7200000, ptr %31, align 8, !tbaa !28
  br label %32

32:                                               ; preds = %.thread, %13
  %.334 = phi ptr [ %.333, %.thread ], [ null, %13 ]
  ret ptr %.334
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @tcp_kill_state(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @tcp_kill_prio(i8 noundef zeroext) 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

attributes #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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, !9, i64 36}
!6 = !{!"tcp_pcb", !7, i64 0, !7, i64 4, !9, i64 8, !9, i64 9, !9, i64 10, !9, i64 11, !11, i64 16, !11, i64 24, !8, i64 32, !9, i64 36, !12, i64 38, !12, i64 40, !12, i64 42, !9, i64 44, !9, i64 45, !9, i64 46, !8, i64 48, !8, i64 52, !12, i64 56, !12, i64 58, !8, i64 60, !12, i64 64, !12, i64 66, !8, i64 68, !8, i64 72, !12, i64 76, !12, i64 78, !12, i64 80, !9, i64 82, !9, i64 83, !8, i64 84, !12, i64 88, !12, i64 90, !8, i64 92, !8, i64 96, !8, i64 100, !8, i64 104, !8, i64 108, !12, i64 112, !12, i64 114, !12, i64 116, !12, i64 118, !12, i64 120, !12, i64 122, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !8, i64 200, !9, i64 204, !9, i64 205, !9, i64 206, !9, i64 207}
!7 = !{!"ip4_addr", !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"short", !9, i64 0}
!13 = !{!6, !12, i64 116}
!14 = !{!6, !12, i64 58}
!15 = !{!6, !12, i64 56}
!16 = !{!6, !9, i64 11}
!17 = !{!6, !12, i64 66}
!18 = !{!6, !12, i64 80}
!19 = !{!6, !12, i64 78}
!20 = !{!6, !12, i64 64}
!21 = !{!6, !12, i64 88}
!22 = !{!8, !8, i64 0}
!23 = !{!6, !8, i64 48}
!24 = !{!9, !9, i64 0}
!25 = !{!6, !9, i64 46}
!26 = !{!6, !12, i64 90}
!27 = !{!6, !11, i64 168}
!28 = !{!6, !8, i64 200}


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