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

; 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.pbuf = type { ptr, ptr, i16, i16, i8, i8, i8, i8 }

@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [179 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [30 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

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

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %17, label %12

12:                                               ; preds = %9
  br label %13

13:                                               ; preds = %12
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.10, i32 noundef 587, ptr noundef @.str.2)
  br label %15

15:                                               ; preds = %13
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16, %9
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %25, label %22

22:                                               ; preds = %19
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = icmp ugt i64 %23, 65535
  br i1 %24, label %25, label %26

25:                                               ; preds = %22, %19
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %80

26:                                               ; preds = %22
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %80

30:                                               ; preds = %26
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = trunc i64 %31 to i16
  store i16 %32, ptr %7, align 2, !tbaa !11
  br label %33

33:                                               ; preds = %30
  %34 = load i16, ptr %7, align 2, !tbaa !11
  %35 = zext i16 %34 to i32
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.pbuf, ptr %36, i32 0, i32 3
  %38 = load i16, ptr %37, align 2, !tbaa !13
  %39 = zext i16 %38 to i32
  %40 = icmp sle i32 %35, %39
  br i1 %40, label %46, label %41

41:                                               ; preds = %33
  br label %42

42:                                               ; preds = %41
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.11, i32 noundef 597, ptr noundef @.str.2)
  br label %44

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %80

46:                                               ; preds = %33
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.pbuf, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  store ptr %51, ptr %6, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.pbuf, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.pbuf, ptr %58, i32 0, i32 1
  store ptr %57, ptr %59, align 8, !tbaa !15
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.pbuf, ptr %60, i32 0, i32 3
  %62 = load i16, ptr %61, align 2, !tbaa !13
  %63 = zext i16 %62 to i32
  %64 = load i16, ptr %7, align 2, !tbaa !11
  %65 = zext i16 %64 to i32
  %66 = sub nsw i32 %63, %65
  %67 = trunc i32 %66 to i16
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.pbuf, ptr %68, i32 0, i32 3
  store i16 %67, ptr %69, align 2, !tbaa !13
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.pbuf, ptr %70, i32 0, i32 2
  %72 = load i16, ptr %71, align 8, !tbaa !16
  %73 = zext i16 %72 to i32
  %74 = load i16, ptr %7, align 2, !tbaa !11
  %75 = zext i16 %74 to i32
  %76 = sub nsw i32 %73, %75
  %77 = trunc i32 %76 to i16
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.pbuf, ptr %78, i32 0, i32 2
  store i16 %77, ptr %79, align 8, !tbaa !16
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %80

80:                                               ; preds = %48, %45, %29, %25
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %81 = load i8, ptr %3, align 1
  ret i8 %81
}

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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !12, i64 18}
!14 = !{!"pbuf", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 18, !7, i64 20, !7, i64 21, !7, i64 22, !7, i64 23}
!15 = !{!14, !6, i64 8}
!16 = !{!14, !12, 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 [179 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [30 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @pbuf_remove_header(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.thread, label %4

.thread:                                          ; preds = %2
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.10, i32 noundef 587, ptr noundef nonnull @.str.2)
  br label %23

4:                                                ; preds = %2
  %5 = icmp ugt i64 %1, 65535
  br i1 %5, label %23, label %6

6:                                                ; preds = %4
  %7 = icmp eq i64 %1, 0
  br i1 %7, label %23, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 18
  %10 = load i16, ptr %9, align 2, !tbaa !5
  %11 = zext i16 %10 to i64
  %.not22 = icmp ult i64 %11, %1
  br i1 %.not22, label %12, label %14

12:                                               ; preds = %8
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.11, i32 noundef 597, ptr noundef nonnull @.str.2)
  br label %23

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %16, i64 %1
  store ptr %17, ptr %15, align 8, !tbaa !11
  %18 = trunc nuw i64 %1 to i16
  %19 = sub i16 %10, %18
  store i16 %19, ptr %9, align 2, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load i16, ptr %20, align 8, !tbaa !12
  %22 = sub i16 %21, %18
  store i16 %22, ptr %20, align 8, !tbaa !12
  br label %23

23:                                               ; preds = %.thread, %6, %4, %14, %12
  %.0 = phi i8 [ 0, %14 ], [ 1, %12 ], [ 1, %4 ], [ 0, %6 ], [ 1, %.thread ]
  ret i8 %.0
}

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 = { nofree 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" }

!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, !10, i64 18}
!6 = !{!"pbuf", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 18, !8, i64 20, !8, i64 21, !8, i64 22, !8, i64 23}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !10, i64 16}


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