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

; 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_active_pcbs = external dso_local global ptr, align 8
@tcp_active_pcbs_changed = external dso_local global i8, align 1
@tcp_timer_ctr = external hidden global i8, align 1

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

6:                                                ; preds = %92, %0
  %7 = load ptr, ptr @tcp_active_pcbs, align 8, !tbaa !8
  store ptr %7, ptr %1, align 8, !tbaa !8
  br label %8

8:                                                ; preds = %99, %6
  %9 = load ptr, ptr %1, align 8, !tbaa !8
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %100

11:                                               ; preds = %8
  %12 = load ptr, ptr %1, align 8, !tbaa !8
  %13 = getelementptr inbounds %struct.tcp_pcb, ptr %12, i32 0, i32 15
  %14 = load i8, ptr %13, align 2, !tbaa !10
  %15 = zext i8 %14 to i32
  %16 = load i8, ptr @tcp_timer_ctr, align 1, !tbaa !5
  %17 = zext i8 %16 to i32
  %18 = icmp ne i32 %15, %17
  br i1 %18, label %19, label %95

19:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %20 = load i8, ptr @tcp_timer_ctr, align 1, !tbaa !5
  %21 = load ptr, ptr %1, align 8, !tbaa !8
  %22 = getelementptr inbounds %struct.tcp_pcb, ptr %21, i32 0, i32 15
  store i8 %20, ptr %22, align 2, !tbaa !10
  %23 = load ptr, ptr %1, align 8, !tbaa !8
  %24 = getelementptr inbounds %struct.tcp_pcb, ptr %23, i32 0, i32 12
  %25 = load i16, ptr %24, align 2, !tbaa !15
  %26 = zext i16 %25 to i32
  %27 = and i32 %26, 1
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %54

29:                                               ; preds = %19
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %1, align 8, !tbaa !8
  %32 = getelementptr inbounds %struct.tcp_pcb, ptr %31, i32 0, i32 12
  %33 = load i16, ptr %32, align 2, !tbaa !15
  %34 = zext i16 %33 to i32
  %35 = or i32 %34, 2
  %36 = trunc i32 %35 to i16
  %37 = load ptr, ptr %1, align 8, !tbaa !8
  %38 = getelementptr inbounds %struct.tcp_pcb, ptr %37, i32 0, i32 12
  store i16 %36, ptr %38, align 2, !tbaa !15
  br label %39

39:                                               ; preds = %30
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %1, align 8, !tbaa !8
  %42 = call signext i8 @tcp_output(ptr noundef %41)
  br label %43

43:                                               ; preds = %40
  %44 = load ptr, ptr %1, align 8, !tbaa !8
  %45 = getelementptr inbounds %struct.tcp_pcb, ptr %44, i32 0, i32 12
  %46 = load i16, ptr %45, align 2, !tbaa !15
  %47 = zext i16 %46 to i32
  %48 = and i32 %47, 65532
  %49 = trunc i32 %48 to i16
  %50 = load ptr, ptr %1, align 8, !tbaa !8
  %51 = getelementptr inbounds %struct.tcp_pcb, ptr %50, i32 0, i32 12
  store i16 %49, ptr %51, align 2, !tbaa !15
  br label %52

52:                                               ; preds = %43
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53, %19
  %55 = load ptr, ptr %1, align 8, !tbaa !8
  %56 = getelementptr inbounds %struct.tcp_pcb, ptr %55, i32 0, i32 12
  %57 = load i16, ptr %56, align 2, !tbaa !15
  %58 = zext i16 %57 to i32
  %59 = and i32 %58, 8
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %75

61:                                               ; preds = %54
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %1, align 8, !tbaa !8
  %64 = getelementptr inbounds %struct.tcp_pcb, ptr %63, i32 0, i32 12
  %65 = load i16, ptr %64, align 2, !tbaa !15
  %66 = zext i16 %65 to i32
  %67 = and i32 %66, 65527
  %68 = trunc i32 %67 to i16
  %69 = load ptr, ptr %1, align 8, !tbaa !8
  %70 = getelementptr inbounds %struct.tcp_pcb, ptr %69, i32 0, i32 12
  store i16 %68, ptr %70, align 2, !tbaa !15
  br label %71

71:                                               ; preds = %62
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %1, align 8, !tbaa !8
  %74 = call signext i8 @tcp_close_shutdown_fin(ptr noundef %73)
  br label %75

75:                                               ; preds = %72, %54
  %76 = load ptr, ptr %1, align 8, !tbaa !8
  %77 = getelementptr inbounds %struct.tcp_pcb, ptr %76, i32 0, i32 6
  %78 = load ptr, ptr %77, align 8, !tbaa !16
  store ptr %78, ptr %2, align 8, !tbaa !8
  %79 = load ptr, ptr %1, align 8, !tbaa !8
  %80 = getelementptr inbounds %struct.tcp_pcb, ptr %79, i32 0, i32 46
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %90

83:                                               ; preds = %75
  store i8 0, ptr @tcp_active_pcbs_changed, align 1, !tbaa !5
  %84 = load ptr, ptr %1, align 8, !tbaa !8
  %85 = call signext i8 @tcp_process_refused_data(ptr noundef %84)
  %86 = load i8, ptr @tcp_active_pcbs_changed, align 1, !tbaa !5
  %87 = icmp ne i8 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %83
  store i32 2, ptr %3, align 4
  br label %92

89:                                               ; preds = %83
  br label %90

90:                                               ; preds = %89, %75
  %91 = load ptr, ptr %2, align 8, !tbaa !8
  store ptr %91, ptr %1, align 8, !tbaa !8
  store i32 0, ptr %3, align 4
  br label %92

92:                                               ; preds = %90, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %93 = load i32, ptr %3, align 4
  switch i32 %93, label %101 [
    i32 0, label %94
    i32 2, label %6
  ]

94:                                               ; preds = %92
  br label %99

95:                                               ; preds = %11
  %96 = load ptr, ptr %1, align 8, !tbaa !8
  %97 = getelementptr inbounds %struct.tcp_pcb, ptr %96, i32 0, i32 6
  %98 = load ptr, ptr %97, align 8, !tbaa !16
  store ptr %98, ptr %1, align 8, !tbaa !8
  br label %99

99:                                               ; preds = %95, %94
  br label %8, !llvm.loop !18

100:                                              ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void

101:                                              ; preds = %92
  unreachable
}

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

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

declare signext i8 @tcp_output(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @tcp_process_refused_data(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 46}
!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 42}
!16 = !{!11, !9, i64 16}
!17 = !{!11, !9, i64 144}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@tcp_active_pcbs = external dso_local local_unnamed_addr global ptr, align 8
@tcp_active_pcbs_changed = external dso_local local_unnamed_addr global i8, align 1
@tcp_timer_ctr = external hidden local_unnamed_addr global i8, align 1

; Function Attrs: nounwind uwtable
define dso_local void @tcp_fasttmr() local_unnamed_addr #0 {
  %1 = load i8, ptr @tcp_timer_ctr, align 1, !tbaa !5
  %2 = add i8 %1, 1
  store i8 %2, ptr @tcp_timer_ctr, align 1, !tbaa !5
  %3 = load ptr, ptr @tcp_active_pcbs, align 8, !tbaa !8
  %.not2730 = icmp eq ptr %3, null
  br i1 %.not2730, label %._crit_edge, label %.lr.ph

.loopexit:                                        ; preds = %28
  %4 = load ptr, ptr @tcp_active_pcbs, align 8, !tbaa !8
  %.not27 = icmp eq ptr %4, null
  br i1 %.not27, label %._crit_edge, label %.lr.ph.backedge

.lr.ph:                                           ; preds = %0, %.lr.ph.backedge
  %.01828 = phi ptr [ %.01828.be, %.lr.ph.backedge ], [ %3, %0 ]
  %5 = getelementptr inbounds i8, ptr %.01828, i64 46
  %6 = load i8, ptr %5, align 2, !tbaa !10
  %7 = load i8, ptr @tcp_timer_ctr, align 1, !tbaa !5
  %.not19 = icmp eq i8 %6, %7
  br i1 %.not19, label %31, label %8

8:                                                ; preds = %.lr.ph
  store i8 %7, ptr %5, align 2, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %.01828, i64 42
  %10 = load i16, ptr %9, align 2, !tbaa !15
  %11 = and i16 %10, 1
  %.not20 = icmp eq i16 %11, 0
  br i1 %.not20, label %17, label %12

12:                                               ; preds = %8
  %13 = or i16 %10, 2
  store i16 %13, ptr %9, align 2, !tbaa !15
  %14 = tail call signext i8 @tcp_output(ptr noundef nonnull %.01828) #2
  %15 = load i16, ptr %9, align 2, !tbaa !15
  %16 = and i16 %15, -4
  store i16 %16, ptr %9, align 2, !tbaa !15
  br label %17

17:                                               ; preds = %12, %8
  %18 = phi i16 [ %16, %12 ], [ %10, %8 ]
  %19 = and i16 %18, 8
  %.not21 = icmp eq i16 %19, 0
  br i1 %.not21, label %23, label %20

20:                                               ; preds = %17
  %21 = and i16 %18, -9
  store i16 %21, ptr %9, align 2, !tbaa !15
  %22 = tail call signext i8 @tcp_close_shutdown_fin(ptr noundef nonnull %.01828)
  br label %23

23:                                               ; preds = %20, %17
  %24 = getelementptr inbounds i8, ptr %.01828, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %.01828, i64 144
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %.not22 = icmp eq ptr %27, null
  br i1 %.not22, label %.thread, label %28

28:                                               ; preds = %23
  store i8 0, ptr @tcp_active_pcbs_changed, align 1, !tbaa !5
  %29 = tail call signext i8 @tcp_process_refused_data(ptr noundef nonnull %.01828)
  %30 = load i8, ptr @tcp_active_pcbs_changed, align 1, !tbaa !5
  %.not23 = icmp eq i8 %30, 0
  br i1 %.not23, label %.thread, label %.loopexit

31:                                               ; preds = %.lr.ph
  %32 = getelementptr inbounds i8, ptr %.01828, i64 16
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  br label %.thread

.thread:                                          ; preds = %28, %23, %31
  %.2 = phi ptr [ %33, %31 ], [ %25, %23 ], [ %25, %28 ]
  %.not = icmp eq ptr %.2, null
  br i1 %.not, label %._crit_edge, label %.lr.ph.backedge

.lr.ph.backedge:                                  ; preds = %.thread, %.loopexit
  %.01828.be = phi ptr [ %.2, %.thread ], [ %4, %.loopexit ]
  br label %.lr.ph, !llvm.loop !18

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

declare signext i8 @tcp_output(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @tcp_process_refused_data(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 = { "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 = !{!"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 46}
!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 42}
!16 = !{!11, !9, i64 16}
!17 = !{!11, !9, i64 144}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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