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

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

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [182 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [32 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

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

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

declare i32 @lwip_htonl(i32 noundef) #1

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

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %18, label %13

13:                                               ; preds = %10
  br label %14

14:                                               ; preds = %13
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.37, i32 noundef 2026, ptr noundef @.str.2)
  br label %16

16:                                               ; preds = %14
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17, %10
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = load i8, ptr %7, align 1, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = and i32 %22, 1
  %24 = icmp ne i32 %23, 0
  %25 = zext i1 %24 to i64
  %26 = select i1 %24, i32 4, i32 0
  %27 = load i8, ptr %7, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = and i32 %28, 2
  %30 = icmp ne i32 %29, 0
  %31 = zext i1 %30 to i64
  %32 = select i1 %30, i32 0, i32 0
  %33 = add nsw i32 %26, %32
  %34 = load i8, ptr %7, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = and i32 %35, 8
  %37 = icmp ne i32 %36, 0
  %38 = zext i1 %37 to i64
  %39 = select i1 %37, i32 0, i32 0
  %40 = add nsw i32 %33, %39
  %41 = load i8, ptr %7, align 1, !tbaa !9
  %42 = zext i8 %41 to i32
  %43 = and i32 %42, 16
  %44 = icmp ne i32 %43, 0
  %45 = zext i1 %44 to i64
  %46 = select i1 %44, i32 0, i32 0
  %47 = add nsw i32 %40, %46
  %48 = trunc i32 %47 to i8
  store i8 %48, ptr %6, align 1, !tbaa !9
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load i8, ptr %6, align 1, !tbaa !9
  %51 = zext i8 %50 to i16
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.tcp_pcb, ptr %52, i32 0, i32 34
  %54 = load i32, ptr %53, align 8, !tbaa !10
  %55 = call i32 @lwip_htonl(i32 noundef %54)
  %56 = call ptr @tcp_output_alloc_header(ptr noundef %49, i16 noundef zeroext %51, i16 noundef zeroext 0, i32 noundef %55)
  store ptr %56, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %71

59:                                               ; preds = %20
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.tcp_pcb, ptr %61, i32 0, i32 12
  %63 = load i16, ptr %62, align 2, !tbaa !15
  %64 = zext i16 %63 to i32
  %65 = or i32 %64, 3
  %66 = trunc i32 %65 to i16
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.tcp_pcb, ptr %67, i32 0, i32 12
  store i16 %66, ptr %68, align 2, !tbaa !15
  br label %69

69:                                               ; preds = %60
  br label %70

70:                                               ; preds = %69
  store i8 -2, ptr %2, align 1
  store i32 1, ptr %9, align 4
  br label %112

71:                                               ; preds = %20
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i8, ptr %7, align 1, !tbaa !9
  %75 = load i8, ptr %8, align 1, !tbaa !9
  call void @tcp_output_fill_options(ptr noundef %72, ptr noundef %73, i8 noundef zeroext %74, i8 noundef zeroext %75)
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.tcp_pcb, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.tcp_pcb, ptr %80, i32 0, i32 1
  %82 = call signext i8 @tcp_output_control_segment(ptr noundef %76, ptr noundef %77, ptr noundef %79, ptr noundef %81)
  store i8 %82, ptr %4, align 1, !tbaa !9
  %83 = load i8, ptr %4, align 1, !tbaa !9
  %84 = sext i8 %83 to i32
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %98

86:                                               ; preds = %71
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.tcp_pcb, ptr %88, i32 0, i32 12
  %90 = load i16, ptr %89, align 2, !tbaa !15
  %91 = zext i16 %90 to i32
  %92 = or i32 %91, 3
  %93 = trunc i32 %92 to i16
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.tcp_pcb, ptr %94, i32 0, i32 12
  store i16 %93, ptr %95, align 2, !tbaa !15
  br label %96

96:                                               ; preds = %87
  br label %97

97:                                               ; preds = %96
  br label %110

98:                                               ; preds = %71
  br label %99

99:                                               ; preds = %98
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.tcp_pcb, ptr %100, i32 0, i32 12
  %102 = load i16, ptr %101, align 2, !tbaa !15
  %103 = zext i16 %102 to i32
  %104 = and i32 %103, 65532
  %105 = trunc i32 %104 to i16
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.tcp_pcb, ptr %106, i32 0, i32 12
  store i16 %105, ptr %107, align 2, !tbaa !15
  br label %108

108:                                              ; preds = %99
  br label %109

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109, %97
  %111 = load i8, ptr %4, align 1, !tbaa !9
  store i8 %111, ptr %2, align 1
  store i32 1, ptr %9, align 4
  br label %112

112:                                              ; preds = %110, %70
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %113 = load i8, ptr %2, align 1
  ret i8 %113
}

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @tcp_output_alloc_header(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i32 noundef) #2

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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !13, i64 96}
!11 = !{!"tcp_pcb", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !6, i64 16, !6, i64 24, !13, i64 32, !7, i64 36, !14, i64 38, !14, i64 40, !14, i64 42, !7, i64 44, !7, i64 45, !7, 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, !7, i64 82, !7, 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, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !13, i64 200, !7, i64 204, !7, i64 205, !7, i64 206, !7, i64 207}
!12 = !{!"ip4_addr", !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!11, !14, i64 42}


; 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.2 = external hidden unnamed_addr constant [182 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [32 x i8], align 1

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

declare i32 @lwip_htonl(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local signext i8 @tcp_send_empty_ack(ptr noundef %0) local_unnamed_addr #2 {
  %.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.37, i32 noundef 2026, ptr noundef nonnull @.str.2)
  br label %4

4:                                                ; preds = %2, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = tail call i32 @lwip_htonl(i32 noundef %6) #3
  %8 = tail call ptr @tcp_output_alloc_header(ptr noundef %0, i16 noundef zeroext 0, i16 noundef zeroext 0, i32 noundef %7)
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %14

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 42
  %12 = load i16, ptr %11, align 2, !tbaa !13
  %13 = or i16 %12, 3
  store i16 %13, ptr %11, align 2, !tbaa !13
  br label %23

14:                                               ; preds = %4
  tail call void @tcp_output_fill_options(ptr noundef nonnull %0, ptr noundef nonnull %8, i8 noundef zeroext 0, i8 noundef zeroext 0)
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = tail call signext i8 @tcp_output_control_segment(ptr noundef nonnull %0, ptr noundef nonnull %8, ptr noundef nonnull %0, ptr noundef nonnull %15)
  %.not26 = icmp eq i8 %16, 0
  %17 = getelementptr inbounds i8, ptr %0, i64 42
  %18 = load i16, ptr %17, align 2, !tbaa !13
  br i1 %.not26, label %21, label %19

19:                                               ; preds = %14
  %20 = or i16 %18, 3
  store i16 %20, ptr %17, align 2, !tbaa !13
  br label %23

21:                                               ; preds = %14
  %22 = and i16 %18, -4
  store i16 %22, ptr %17, align 2, !tbaa !13
  br label %23

23:                                               ; preds = %19, %21, %10
  %.0 = phi i8 [ -2, %10 ], [ 0, %21 ], [ %16, %19 ]
  ret i8 %.0
}

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @tcp_output_control_segment(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden ptr @tcp_output_alloc_header(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i32 noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { 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 96}
!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 42}


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