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

; 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.mrb_value = type { %union.anon, i32 }
%union.anon = type { double }

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @mrb_obj_eq(ptr noundef, i64, i32, i64, i32) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @mrb_equal(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4) #0 {
  %6 = alloca i8, align 1
  %7 = alloca %struct.mrb_value, align 8
  %8 = alloca %struct.mrb_value, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.mrb_value, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.mrb_value, align 8
  %13 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  store i64 %1, ptr %13, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  store i32 %2, ptr %14, align 8
  %15 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  store i64 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  store i32 %4, ptr %16, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %21 = load i32, ptr %20, align 8
  %22 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %25 = load i32, ptr %24, align 8
  %26 = call zeroext i8 @mrb_obj_eq(ptr noundef %17, i64 %19, i32 %21, i64 %23, i32 %25)
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %5
  store i8 1, ptr %6, align 1
  store i32 1, ptr %11, align 4
  br label %45

29:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  %32 = load i64, ptr %31, align 8
  %33 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  %34 = load i32, ptr %33, align 8
  %35 = call { i64, i32 } (ptr, i64, i32, ptr, i64, ...) @mrb_funcall(ptr noundef %30, i64 %32, i32 %34, ptr noundef @.str, i64 noundef 1, ptr noundef byval(%struct.mrb_value) align 8 %8)
  %36 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %37 = extractvalue { i64, i32 } %35, 0
  store i64 %37, ptr %36, align 8
  %38 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %39 = extractvalue { i64, i32 } %35, 1
  store i32 %39, ptr %38, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %12, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  %40 = getelementptr inbounds %struct.mrb_value, ptr %10, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %29
  store i8 1, ptr %6, align 1
  store i32 1, ptr %11, align 4
  br label %45

44:                                               ; preds = %29
  store i8 0, ptr %6, align 1
  store i32 1, ptr %11, align 4
  br label %45

45:                                               ; preds = %44, %43, %28
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  %46 = load i8, ptr %6, align 1
  ret i8 %46
}

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

declare { i64, i32 } @mrb_funcall(ptr noundef, i64, i32, ptr noundef, i64 noundef, ...) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 8, !10, i64 8, i64 4, !11}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"mrb_value", !7, i64 0, !12, i64 8}


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

%struct.mrb_value = type { %union.anon, i32 }
%union.anon = type { double }

@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @mrb_obj_eq(ptr noundef, i64, i32, i64, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @mrb_equal(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4) local_unnamed_addr #0 {
  %6 = alloca %struct.mrb_value, align 8
  store i64 %3, ptr %6, align 8
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %4, ptr %7, align 8
  %8 = tail call zeroext i8 @mrb_obj_eq(ptr noundef %0, i64 %1, i32 %2, i64 %3, i32 %4)
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %9, label %12

9:                                                ; preds = %5
  %10 = tail call { i64, i32 } (ptr, i64, i32, ptr, i64, ...) @mrb_funcall(ptr noundef %0, i64 %1, i32 %2, ptr noundef nonnull @.str, i64 noundef 1, ptr noundef nonnull byval(%struct.mrb_value) align 8 %6) #2
  %11 = extractvalue { i64, i32 } %10, 1
  %.not8 = icmp ne i32 %11, 0
  %. = zext i1 %.not8 to i8
  br label %12

12:                                               ; preds = %9, %5
  %.0 = phi i8 [ 1, %5 ], [ %., %9 ]
  ret i8 %.0
}

declare { i64, i32 } @mrb_funcall(ptr noundef, i64, i32, ptr noundef, i64 noundef, ...) local_unnamed_addr #1

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

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


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