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

; 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
declare dso_local i32 @llhttp_message_needs_eof(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @llhttp_should_keep_alive(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 11
  %6 = load i8, ptr %5, align 2, !tbaa !9
  %7 = zext i8 %6 to i32
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %9, label %24

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.llhttp__internal_s, ptr %10, i32 0, i32 12
  %12 = load i8, ptr %11, align 1, !tbaa !14
  %13 = zext i8 %12 to i32
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %15, label %24

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

22:                                               ; preds = %15
  store i32 0, ptr %2, align 4
  br label %39

23:                                               ; preds = %15
  br label %33

24:                                               ; preds = %9, %1
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.llhttp__internal_s, ptr %25, i32 0, i32 14
  %27 = load i16, ptr %26, align 2, !tbaa !15
  %28 = zext i16 %27 to i32
  %29 = and i32 %28, 1
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %24
  store i32 0, ptr %2, align 4
  br label %39

32:                                               ; preds = %24
  br label %33

33:                                               ; preds = %32, %23
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = call i32 @llhttp_message_needs_eof(ptr noundef %34)
  %36 = icmp ne i32 %35, 0
  %37 = xor i1 %36, true
  %38 = zext i1 %37 to i32
  store i32 %38, ptr %2, align 4
  br label %39

39:                                               ; preds = %33, %31, %22
  %40 = load i32, ptr %2, align 4
  ret i32 %40
}

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 74}
!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, !7, i64 75}
!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: nounwind uwtable
declare dso_local i32 @llhttp_message_needs_eof(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @llhttp_should_keep_alive(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 74
  %3 = load i8, ptr %2, align 2, !tbaa !5
  %.not = icmp eq i8 %3, 0
  br i1 %.not, label %11, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 75
  %6 = load i8, ptr %5, align 1, !tbaa !13
  %.not5 = icmp eq i8 %6, 0
  br i1 %.not5, label %11, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 78
  %9 = load i16, ptr %8, align 2, !tbaa !14
  %10 = and i16 %9, 2
  %.not7 = icmp eq i16 %10, 0
  br i1 %.not7, label %15, label %18

11:                                               ; preds = %4, %1
  %12 = getelementptr inbounds i8, ptr %0, i64 78
  %13 = load i16, ptr %12, align 2, !tbaa !14
  %14 = and i16 %13, 1
  %.not6 = icmp eq i16 %14, 0
  br i1 %.not6, label %18, label %15

15:                                               ; preds = %11, %7
  %16 = tail call i32 @llhttp_message_needs_eof(ptr noundef nonnull %0)
  %.not8 = icmp eq i32 %16, 0
  %17 = zext i1 %.not8 to i32
  br label %18

18:                                               ; preds = %11, %7, %15
  %.0 = phi i32 [ %17, %15 ], [ 0, %7 ], [ 0, %11 ]
  ret i32 %.0
}

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, !8, i64 74}
!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, !8, i64 75}
!14 = !{!6, !12, i64 78}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass