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

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

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [181 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 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 i32 @sys_mbox_valid(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
define dso_local signext i8 @netconn_accept(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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 1, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #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.14, i32 noundef 481, 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 %9, align 4
  br label %103

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.15, i32 noundef 483, 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 %9, align 4
  br label %103

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 = call signext i8 @netconn_err(ptr noundef %33)
  store i8 %34, ptr %6, align 1, !tbaa !9
  %35 = load i8, ptr %6, align 1, !tbaa !9
  %36 = sext i8 %35 to i32
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %32
  %39 = load i8, ptr %6, align 1, !tbaa !9
  store i8 %39, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

40:                                               ; preds = %32
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.netconn, ptr %41, i32 0, i32 6
  %43 = call i32 @sys_mbox_valid(ptr noundef %42)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %52

45:                                               ; preds = %40
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.netconn, ptr %46, i32 0, i32 10
  %48 = load i8, ptr %47, align 4, !tbaa !10
  %49 = zext i8 %48 to i32
  %50 = and i32 %49, 1
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %53, label %52

52:                                               ; preds = %45, %40
  store i8 -15, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

53:                                               ; preds = %45
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.netconn, ptr %54, i32 0, i32 10
  %56 = load i8, ptr %55, align 4, !tbaa !10
  %57 = zext i8 %56 to i32
  %58 = and i32 %57, 2
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %68

60:                                               ; preds = %53
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.netconn, ptr %61, i32 0, i32 6
  %63 = call i32 @sys_arch_mbox_tryfetch(ptr noundef %62, ptr noundef %7)
  %64 = zext i32 %63 to i64
  %65 = icmp eq i64 %64, 4294967295
  br i1 %65, label %66, label %67

66:                                               ; preds = %60
  store i8 -7, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

67:                                               ; preds = %60
  br label %79

68:                                               ; preds = %53
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.netconn, ptr %69, i32 0, i32 6
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.netconn, ptr %71, i32 0, i32 9
  %73 = load i32, ptr %72, align 8, !tbaa !13
  %74 = call i32 @sys_arch_mbox_fetch(ptr noundef %70, ptr noundef %7, i32 noundef %73)
  %75 = zext i32 %74 to i64
  %76 = icmp eq i64 %75, 4294967295
  br i1 %76, label %77, label %78

77:                                               ; preds = %68
  store i8 -3, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

78:                                               ; preds = %68
  br label %79

79:                                               ; preds = %78, %67
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.netconn, ptr %80, i32 0, i32 12
  %82 = load ptr, ptr %81, align 8, !tbaa !14
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %89

84:                                               ; preds = %79
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.netconn, ptr %85, i32 0, i32 12
  %87 = load ptr, ptr %86, align 8, !tbaa !14
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  call void %87(ptr noundef %88, i32 noundef 1, i16 noundef zeroext 0)
  br label %89

89:                                               ; preds = %84, %79
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = call i32 @lwip_netconn_is_err_msg(ptr noundef %90, ptr noundef %6)
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %95

93:                                               ; preds = %89
  %94 = load i8, ptr %6, align 1, !tbaa !9
  store i8 %94, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

95:                                               ; preds = %89
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = icmp eq ptr %96, null
  br i1 %97, label %98, label %99

98:                                               ; preds = %95
  store i8 -15, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

99:                                               ; preds = %95
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %100, ptr %8, align 8, !tbaa !5
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %101, ptr %102, align 8, !tbaa !5
  store i8 0, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %103

103:                                              ; preds = %99, %98, %93, %77, %66, %52, %38, %29, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %104 = load i8, ptr %3, align 1
  ret i8 %104
}

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @netconn_err(ptr noundef) #2

declare i32 @sys_arch_mbox_tryfetch(ptr noundef, ptr noundef) #1

declare i32 @sys_arch_mbox_fetch(ptr noundef, ptr noundef, i32 noundef) #1

declare i32 @lwip_netconn_is_err_msg(ptr noundef, ptr 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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 60}
!11 = !{!"netconn", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !7, i64 60, !6, i64 64, !6, i64 72}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !12, i64 56}
!14 = !{!11, !6, i64 72}


; 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.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 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 i32 @sys_mbox_valid(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
define dso_local signext i8 @netconn_accept(ptr noundef %0, ptr noundef writeonly %1) local_unnamed_addr #3 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %5, label %7

5:                                                ; preds = %2
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.14, i32 noundef 481, ptr noundef nonnull @.str.2)
  br label %44

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

8:                                                ; preds = %7
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.15, i32 noundef 483, ptr noundef nonnull @.str.2)
  br label %44

10:                                               ; preds = %7
  %11 = tail call signext i8 @netconn_err(ptr noundef nonnull %0)
  store i8 %11, ptr %3, align 1, !tbaa !9
  %.not20 = icmp eq i8 %11, 0
  br i1 %.not20, label %12, label %44

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = tail call i32 @sys_mbox_valid(ptr noundef nonnull %13) #4
  %.not21 = icmp eq i32 %14, 0
  br i1 %.not21, label %44, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 60
  %17 = load i8, ptr %16, align 4, !tbaa !10
  %18 = zext i8 %17 to i32
  %19 = and i32 %18, 1
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %44

21:                                               ; preds = %15
  %22 = and i32 %18, 2
  %.not22 = icmp eq i32 %22, 0
  br i1 %.not22, label %26, label %23

23:                                               ; preds = %21
  %24 = call i32 @sys_arch_mbox_tryfetch(ptr noundef nonnull %13, ptr noundef nonnull %4) #4
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %44, label %31

26:                                               ; preds = %21
  %27 = getelementptr inbounds i8, ptr %0, i64 56
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = call i32 @sys_arch_mbox_fetch(ptr noundef nonnull %13, ptr noundef nonnull %4, i32 noundef %28) #4
  %30 = icmp eq i32 %29, -1
  br i1 %30, label %44, label %31

31:                                               ; preds = %26, %23
  %32 = getelementptr inbounds i8, ptr %0, i64 72
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %.not23 = icmp eq ptr %33, null
  br i1 %.not23, label %35, label %34

34:                                               ; preds = %31
  call void %33(ptr noundef nonnull %0, i32 noundef 1, i16 noundef zeroext 0) #4
  br label %35

35:                                               ; preds = %34, %31
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call i32 @lwip_netconn_is_err_msg(ptr noundef %36, ptr noundef nonnull %3) #4
  %.not24 = icmp eq i32 %37, 0
  br i1 %.not24, label %40, label %38

38:                                               ; preds = %35
  %39 = load i8, ptr %3, align 1, !tbaa !9
  br label %44

40:                                               ; preds = %35
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = icmp eq ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store ptr %41, ptr %1, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %40, %26, %23, %12, %15, %10, %43, %38, %8, %5
  %.0 = phi i8 [ %39, %38 ], [ 0, %43 ], [ -16, %8 ], [ -16, %5 ], [ %11, %10 ], [ -15, %15 ], [ -15, %12 ], [ -7, %23 ], [ -3, %26 ], [ -15, %40 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  ret i8 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @netconn_err(ptr noundef) local_unnamed_addr #3

declare i32 @sys_arch_mbox_tryfetch(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @sys_arch_mbox_fetch(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @lwip_netconn_is_err_msg(ptr noundef, ptr 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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 60}
!11 = !{!"netconn", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !7, i64 60, !6, i64 64, !6, i64 72}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !12, i64 56}
!14 = !{!11, !6, i64 72}


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