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

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

; Function Attrs: nounwind uwtable
define dso_local signext i8 @tcp_tcp_get_tcp_addrinfo(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %48

12:                                               ; preds = %4
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %31

15:                                               ; preds = %12
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tcp_pcb, ptr %20, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 8 %21, i64 4, i1 false), !tbaa.struct !11
  br label %22

22:                                               ; preds = %18, %15
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %30

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.tcp_pcb, ptr %26, i32 0, i32 10
  %28 = load i16, ptr %27, align 2, !tbaa !12
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  store i16 %28, ptr %29, align 2, !tbaa !16
  br label %30

30:                                               ; preds = %25, %22
  br label %47

31:                                               ; preds = %12
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %38

34:                                               ; preds = %31
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.tcp_pcb, ptr %36, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %35, ptr align 4 %37, i64 4, i1 false), !tbaa.struct !11
  br label %38

38:                                               ; preds = %34, %31
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %46

41:                                               ; preds = %38
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.tcp_pcb, ptr %42, i32 0, i32 11
  %44 = load i16, ptr %43, align 8, !tbaa !17
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  store i16 %44, ptr %45, align 2, !tbaa !16
  br label %46

46:                                               ; preds = %41, %38
  br label %47

47:                                               ; preds = %46, %30
  store i8 0, ptr %5, align 1
  br label %49

48:                                               ; preds = %4
  store i8 -6, ptr %5, align 1
  br label %49

49:                                               ; preds = %48, %47
  %50 = load i8, ptr %5, align 1
  ret i8 %50
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 4, !9}
!12 = !{!13, !15, i64 38}
!13 = !{!"tcp_pcb", !14, i64 0, !14, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !6, i64 16, !6, i64 24, !10, i64 32, !7, i64 36, !15, i64 38, !15, i64 40, !15, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !10, i64 48, !10, i64 52, !15, i64 56, !15, i64 58, !10, i64 60, !15, i64 64, !15, i64 66, !10, i64 68, !10, i64 72, !15, i64 76, !15, i64 78, !15, i64 80, !7, i64 82, !7, i64 83, !10, i64 84, !15, i64 88, !15, i64 90, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !15, i64 112, !15, i64 114, !15, i64 116, !15, i64 118, !15, i64 120, !15, 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, !10, i64 200, !7, i64 204, !7, i64 205, !7, i64 206, !7, i64 207}
!14 = !{!"ip4_addr", !10, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!13, !15, i64 40}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local signext range(i8 -6, 1) i8 @tcp_tcp_get_tcp_addrinfo(ptr noundef readonly %0, i32 noundef %1, ptr noundef writeonly %2, ptr noundef writeonly %3) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %16, label %5

5:                                                ; preds = %4
  %.not18 = icmp eq i32 %1, 0
  %.not19 = icmp eq ptr %2, null
  br i1 %.not18, label %10, label %6

6:                                                ; preds = %5
  br i1 %.not19, label %9, label %7

7:                                                ; preds = %6
  %8 = load i32, ptr %0, align 8, !tbaa !5
  store i32 %8, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %7, %6
  %.not22 = icmp eq ptr %3, null
  br i1 %.not22, label %16, label %.sink.split

10:                                               ; preds = %5
  br i1 %.not19, label %14, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %13, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %11, %10
  %.not20 = icmp eq ptr %3, null
  br i1 %.not20, label %16, label %.sink.split

.sink.split:                                      ; preds = %14, %9
  %.sink23 = phi i64 [ 38, %9 ], [ 40, %14 ]
  %15 = getelementptr inbounds i8, ptr %0, i64 %.sink23
  %.sink = load i16, ptr %15, align 2, !tbaa !9
  store i16 %.sink, ptr %3, align 2, !tbaa !9
  br label %16

16:                                               ; preds = %.sink.split, %4, %9, %14
  %.0 = phi i8 [ 0, %14 ], [ 0, %9 ], [ -6, %4 ], [ 0, %.sink.split ]
  ret i8 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}


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