; LLVM IR from devantler/software-engineering-f22-shared :: IOT/BudgetManagementExcercise-03-28/ESP-Project/components/components/nghttp (eof)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @llhttp_message_needs_eof(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.llhttp__internal_s, ptr %4, i32 0, i32 9
  %6 = load i8, ptr %5, align 8, !tbaa !9
  %7 = zext i8 %6 to i32
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i32 0, ptr %2, align 4
  br label %61

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.llhttp__internal_s, ptr %11, i32 0, i32 16
  %13 = load i16, ptr %12, align 2, !tbaa !14
  %14 = zext i16 %13 to i32
  %15 = sdiv i32 %14, 100
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %36, label %17

17:                                               ; preds = %10
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.llhttp__internal_s, ptr %18, i32 0, i32 16
  %20 = load i16, ptr %19, align 2, !tbaa !14
  %21 = zext i16 %20 to i32
  %22 = icmp eq i32 %21, 204
  br i1 %22, label %36, label %23

23:                                               ; preds = %17
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.llhttp__internal_s, ptr %24, i32 0, i32 16
  %26 = load i16, ptr %25, align 2, !tbaa !14
  %27 = zext i16 %26 to i32
  %28 = icmp eq i32 %27, 304
  br i1 %28, label %36, label %29

29:                                               ; preds = %23
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.llhttp__internal_s, ptr %30, i32 0, i32 14
  %32 = load i16, ptr %31, align 2, !tbaa !15
  %33 = zext i16 %32 to i32
  %34 = and i32 %33, 64
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %29, %23, %17, %10
  store i32 0, ptr %2, align 4
  br label %61

37:                                               ; preds = %29
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.llhttp__internal_s, ptr %38, i32 0, i32 14
  %40 = load i16, ptr %39, align 2, !tbaa !15
  %41 = zext i16 %40 to i32
  %42 = and i32 %41, 512
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %52

44:                                               ; preds = %37
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.llhttp__internal_s, ptr %45, i32 0, i32 14
  %47 = load i16, ptr %46, align 2, !tbaa !15
  %48 = zext i16 %47 to i32
  %49 = and i32 %48, 8
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %44
  store i32 1, ptr %2, align 4
  br label %61

52:                                               ; preds = %44, %37
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.llhttp__internal_s, ptr %53, i32 0, i32 14
  %55 = load i16, ptr %54, align 2, !tbaa !15
  %56 = zext i16 %55 to i32
  %57 = and i32 %56, 40
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %52
  store i32 0, ptr %2, align 4
  br label %61

60:                                               ; preds = %52
  store i32 1, ptr %2, align 4
  br label %61

61:                                               ; preds = %60, %59, %51, %36, %9
  %62 = load i32, ptr %2, align 4
  ret i32 %62
}

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

!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, !7, i64 72}
!10 = !{!"llhttp__internal_s", !11, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !12, i64 64, !7, i64 72, !7, i64 73, !7, i64 74, !7, i64 75, !7, i64 76, !13, i64 78, !7, i64 80, !13, i64 82, !7, i64 84, !6, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !13, i64 82}
!15 = !{!10, !13, i64 78}


; 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(argmem: read) uwtable
define dso_local range(i32 0, 2) i32 @llhttp_message_needs_eof(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load i8, ptr %2, align 8, !tbaa !5
  %4 = icmp eq i8 %3, 1
  br i1 %4, label %19, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 82
  %7 = load i16, ptr %6, align 2, !tbaa !13
  %.fr14 = freeze i16 %7
  %8 = zext i16 %.fr14 to i32
  %.off = add nsw i32 %8, -100
  %9 = icmp ult i32 %.off, 100
  br i1 %9, label %19, label %switch.early.test

switch.early.test:                                ; preds = %5
  switch i16 %.fr14, label %10 [
    i16 304, label %19
    i16 204, label %19
  ]

10:                                               ; preds = %switch.early.test
  %11 = getelementptr inbounds i8, ptr %0, i64 78
  %12 = load i16, ptr %11, align 2, !tbaa !14
  %13 = zext i16 %12 to i32
  %14 = and i32 %13, 64
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %19

15:                                               ; preds = %10
  %16 = and i32 %13, 520
  %or.cond13 = icmp eq i32 %16, 512
  br i1 %or.cond13, label %19, label %17

17:                                               ; preds = %15
  %18 = and i16 %12, 40
  %.not10 = icmp eq i16 %18, 0
  %. = zext i1 %.not10 to i32
  br label %19

19:                                               ; preds = %switch.early.test, %switch.early.test, %5, %17, %15, %10, %1
  %.0 = phi i32 [ 0, %1 ], [ 0, %10 ], [ 0, %switch.early.test ], [ 1, %15 ], [ %., %17 ], [ 0, %5 ], [ 0, %switch.early.test ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !8, i64 72}
!6 = !{!"llhttp__internal_s", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !11, i64 64, !8, i64 72, !8, i64 73, !8, i64 74, !8, i64 75, !8, i64 76, !12, i64 78, !8, i64 80, !12, i64 82, !8, i64 84, !10, i64 88}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !12, i64 82}
!14 = !{!6, !12, i64 78}


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