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

; 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.api_msg = type { ptr, i8, %union.anon }
%union.anon = type { %struct.anon.2 }
%struct.anon.2 = type { ptr, i16, i64, i64, i64, i8, i32 }
%struct.netconn = type { i32, i32, %union.anon.5, i8, ptr, ptr, ptr, i32, i32, i32, i8, ptr, ptr }
%union.anon.5 = type { ptr }
%struct.netbuf = type { ptr, ptr, %struct.ip4_addr, i16 }
%struct.ip4_addr = type { i32 }

; 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

; Function Attrs: nounwind uwtable
define dso_local void @lwip_netconn_do_send(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %5, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.api_msg, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = call signext i8 @netconn_err(ptr noundef %8)
  store i8 %9, ptr %4, align 1, !tbaa !11
  %10 = load i8, ptr %4, align 1, !tbaa !11
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %73

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.api_msg, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.netconn, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %71

20:                                               ; preds = %13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.api_msg, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.netconn, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !12
  %26 = and i32 %25, 240
  switch i32 %26, label %69 [
    i32 32, label %27
  ]

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.api_msg, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.netbuf, ptr %30, i32 0, i32 2
  %32 = getelementptr inbounds %struct.ip4_addr, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !15
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %47

35:                                               ; preds = %27
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.api_msg, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.netconn, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.api_msg, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.netbuf, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  %46 = call signext i8 @udp_send(ptr noundef %40, ptr noundef %45)
  store i8 %46, ptr %4, align 1, !tbaa !11
  br label %68

47:                                               ; preds = %27
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.api_msg, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.netconn, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.api_msg, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.netbuf, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.api_msg, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.netbuf, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.api_msg, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.netbuf, ptr %64, i32 0, i32 3
  %66 = load i16, ptr %65, align 4, !tbaa !20
  %67 = call signext i8 @udp_sendto(ptr noundef %52, ptr noundef %57, ptr noundef %61, i16 noundef zeroext %66)
  store i8 %67, ptr %4, align 1, !tbaa !11
  br label %68

68:                                               ; preds = %47, %35
  br label %70

69:                                               ; preds = %20
  store i8 -11, ptr %4, align 1, !tbaa !11
  br label %70

70:                                               ; preds = %69, %68
  br label %72

71:                                               ; preds = %13
  store i8 -11, ptr %4, align 1, !tbaa !11
  br label %72

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

73:                                               ; preds = %72, %1
  %74 = load i8, ptr %4, align 1, !tbaa !11
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.api_msg, ptr %75, i32 0, i32 1
  store i8 %74, ptr %76, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare signext i8 @netconn_err(ptr noundef) #2

declare signext i8 @udp_send(ptr noundef, ptr noundef) #2

declare signext i8 @udp_sendto(ptr noundef, ptr noundef, ptr noundef, i16 noundef zeroext) #2

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 = { 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, !6, i64 0}
!10 = !{!"api_msg", !6, i64 0, !7, i64 8, !7, i64 16}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"netconn", !14, i64 0, !14, i64 4, !7, i64 8, !7, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !14, i64 48, !14, i64 52, !14, i64 56, !7, i64 60, !6, i64 64, !6, i64 72}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 16}
!16 = !{!"netbuf", !6, i64 0, !6, i64 8, !17, i64 16, !18, i64 20}
!17 = !{!"ip4_addr", !14, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!16, !6, i64 0}
!20 = !{!16, !18, i64 20}
!21 = !{!10, !7, i64 8}


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

; Function Attrs: nounwind uwtable
define dso_local void @lwip_netconn_do_send(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = tail call signext i8 @netconn_err(ptr noundef %2) #2
  %4 = icmp eq i8 %3, 0
  br i1 %4, label %5, label %25

5:                                                ; preds = %1
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !10
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %25, label %9

9:                                                ; preds = %5
  %10 = load i32, ptr %6, align 8, !tbaa !11
  %11 = and i32 %10, 240
  %cond = icmp eq i32 %11, 32
  br i1 %cond, label %12, label %25

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !10
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load i32, ptr %15, align 8, !tbaa !14
  %17 = icmp eq i32 %16, 0
  %18 = load ptr, ptr %14, align 8, !tbaa !18
  br i1 %17, label %19, label %21

19:                                               ; preds = %12
  %20 = tail call signext i8 @udp_send(ptr noundef nonnull %8, ptr noundef %18) #2
  br label %25

21:                                               ; preds = %12
  %22 = getelementptr inbounds i8, ptr %14, i64 20
  %23 = load i16, ptr %22, align 4, !tbaa !19
  %24 = tail call signext i8 @udp_sendto(ptr noundef nonnull %8, ptr noundef %18, ptr noundef nonnull %15, i16 noundef zeroext %23) #2
  br label %25

25:                                               ; preds = %5, %9, %19, %21, %1
  %.0 = phi i8 [ %20, %19 ], [ %24, %21 ], [ %3, %1 ], [ -11, %9 ], [ -11, %5 ]
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %.0, ptr %26, align 8, !tbaa !20
  ret void
}

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

declare signext i8 @udp_send(ptr noundef, ptr noundef) local_unnamed_addr #1

declare signext i8 @udp_sendto(ptr noundef, ptr noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #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 = { "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, !7, i64 0}
!6 = !{!"api_msg", !7, i64 0, !8, i64 8, !8, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"netconn", !13, i64 0, !13, i64 4, !8, i64 8, !8, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !13, i64 48, !13, i64 52, !13, i64 56, !8, i64 60, !7, i64 64, !7, i64 72}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !13, i64 16}
!15 = !{!"netbuf", !7, i64 0, !7, i64 8, !16, i64 16, !17, i64 20}
!16 = !{!"ip4_addr", !13, i64 0}
!17 = !{!"short", !8, i64 0}
!18 = !{!15, !7, i64 0}
!19 = !{!15, !17, i64 20}
!20 = !{!6, !8, i64 8}


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