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

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

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [181 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [10 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

declare void @memp_free(i32 noundef, ptr noundef) #1

; 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
declare hidden signext i8 @netconn_recv_data_tcp(ptr noundef, ptr noundef, i8 noundef zeroext) #2

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

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

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, 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.18, i32 noundef 867, ptr noundef @.str.2)
  br label %16

16:                                               ; preds = %14
  br label %17

17:                                               ; preds = %16
  store i8 -16, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %82

18:                                               ; preds = %10
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %21, align 8, !tbaa !5
  br label %22

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

25:                                               ; preds = %22
  br label %26

26:                                               ; preds = %25
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.19, i32 noundef 869, ptr noundef @.str.2)
  br label %28

28:                                               ; preds = %26
  br label %29

29:                                               ; preds = %28
  store i8 -16, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %82

30:                                               ; preds = %22
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.netconn, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !9
  %36 = and i32 %35, 240
  %37 = icmp eq i32 %36, 16
  br i1 %37, label %38, label %78

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  %39 = call ptr @memp_malloc(i32 noundef 6)
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %43

42:                                               ; preds = %38
  store i8 -1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %77

43:                                               ; preds = %38
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = call signext i8 @netconn_recv_data_tcp(ptr noundef %44, ptr noundef %9, i8 noundef zeroext 0)
  store i8 %45, ptr %7, align 1, !tbaa !12
  %46 = load i8, ptr %7, align 1, !tbaa !12
  %47 = sext i8 %46 to i32
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %43
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  call void @memp_free(i32 noundef 6, ptr noundef %50)
  %51 = load i8, ptr %7, align 1, !tbaa !12
  store i8 %51, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %77

52:                                               ; preds = %43
  br label %53

53:                                               ; preds = %52
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %61, label %56

56:                                               ; preds = %53
  br label %57

57:                                               ; preds = %56
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.20, i32 noundef 889, ptr noundef @.str.2)
  br label %59

59:                                               ; preds = %57
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60, %53
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.netbuf, ptr %65, i32 0, i32 0
  store ptr %64, ptr %66, align 8, !tbaa !13
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.netbuf, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !17
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.netbuf, ptr %70, i32 0, i32 3
  store i16 0, ptr %71, align 4, !tbaa !18
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.netbuf, ptr %72, i32 0, i32 2
  %74 = getelementptr inbounds %struct.ip4_addr, ptr %73, i32 0, i32 0
  store i32 0, ptr %74, align 8, !tbaa !19
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %75, ptr %76, align 8, !tbaa !5
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %77

77:                                               ; preds = %63, %49, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %82

78:                                               ; preds = %32
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = call signext i8 @netconn_recv_data(ptr noundef %79, ptr noundef %80, i8 noundef zeroext 0)
  store i8 %81, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %82

82:                                               ; preds = %78, %77, %29, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %83 = load i8, ptr %3, align 1
  ret i8 %83
}

declare ptr @memp_malloc(i32 noundef) #1

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


; 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 [181 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [10 x i8], align 1

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

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

declare void @memp_free(i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden signext i8 @netconn_recv_data_tcp(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden signext i8 @netconn_recv_data(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local signext i8 @netconn_recv(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca ptr, align 8
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.18, i32 noundef 867, ptr noundef nonnull @.str.2)
  br label %31

6:                                                ; preds = %2
  store ptr null, ptr %1, align 8, !tbaa !5
  %.not20 = icmp eq ptr %0, null
  br i1 %.not20, label %7, label %9

7:                                                ; preds = %6
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.19, i32 noundef 869, ptr noundef nonnull @.str.2)
  br label %31

9:                                                ; preds = %6
  %10 = load i32, ptr %0, align 8, !tbaa !9
  %11 = and i32 %10, 240
  %12 = icmp eq i32 %11, 16
  br i1 %12, label %13, label %29

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store ptr null, ptr %3, align 8, !tbaa !5
  %14 = tail call ptr @memp_malloc(i32 noundef 6) #4
  %15 = icmp eq ptr %14, null
  br i1 %15, label %28, label %16

16:                                               ; preds = %13
  %17 = call signext i8 @netconn_recv_data_tcp(ptr noundef nonnull %0, ptr noundef nonnull %3, i8 noundef zeroext 0)
  %.not21 = icmp eq i8 %17, 0
  br i1 %.not21, label %19, label %18

18:                                               ; preds = %16
  call void @memp_free(i32 noundef 6, ptr noundef nonnull %14) #4
  br label %28

19:                                               ; preds = %16
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %.not22 = icmp eq ptr %20, null
  br i1 %.not22, label %21, label %23

21:                                               ; preds = %19
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.20, i32 noundef 889, ptr noundef nonnull @.str.2)
  %.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %21, %19
  %24 = phi ptr [ %.pre, %21 ], [ %20, %19 ]
  store ptr %24, ptr %14, align 8, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %14, i64 8
  store ptr %24, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %14, i64 20
  store i16 0, ptr %26, align 4, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %14, i64 16
  store i32 0, ptr %27, align 8, !tbaa !18
  store ptr %14, ptr %1, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %13, %23, %18
  %.0 = phi i8 [ %17, %18 ], [ 0, %23 ], [ -1, %13 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %31

29:                                               ; preds = %9
  %30 = tail call signext i8 @netconn_recv_data(ptr noundef nonnull %0, ptr noundef nonnull %1, i8 noundef zeroext 0)
  br label %31

31:                                               ; preds = %29, %28, %7, %4
  %.1 = phi i8 [ %.0, %28 ], [ %30, %29 ], [ -16, %7 ], [ -16, %4 ]
  ret i8 %.1
}

declare ptr @memp_malloc(i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"netconn", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !7, i64 60, !6, i64 64, !6, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"netbuf", !6, i64 0, !6, i64 8, !14, i64 16, !15, i64 20}
!14 = !{!"ip4_addr", !11, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!13, !6, i64 8}
!17 = !{!13, !15, i64 20}
!18 = !{!13, !11, i64 16}


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