; LLVM IR from vul337/PrIntFuzz :: config/linux/firmware/carl9170fw/config (expr)

; 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.expr = type { i32, %union.expr_data, %union.expr_data }
%union.expr_data = type { ptr }

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

; 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
declare dso_local ptr @expr_alloc_and(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @expr_copy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @expr_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @expr_eq(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @expr_eliminate_dups(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @expr_simplify_unmet_dep(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  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 8, ptr %6) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.expr, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  switch i32 %11, label %42 [
    i32 1, label %12
    i32 2, label %24
  ]

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.expr, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call ptr @expr_simplify_unmet_dep(ptr noundef %15, ptr noundef %16)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.expr, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call ptr @expr_simplify_unmet_dep(ptr noundef %20, ptr noundef %21)
  %23 = call ptr @expr_alloc_and(ptr noundef %17, ptr noundef %22)
  store ptr %23, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %47

24:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = call ptr @expr_copy(ptr noundef %25)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call ptr @expr_copy(ptr noundef %27)
  %29 = call ptr @expr_alloc_and(ptr noundef %26, ptr noundef %28)
  store ptr %29, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call ptr @expr_eliminate_dups(ptr noundef %30)
  store ptr %31, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @expr_eq(ptr noundef %32, ptr noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %38, label %36

36:                                               ; preds = %24
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  br label %39

38:                                               ; preds = %24
  br label %39

39:                                               ; preds = %38, %36
  %40 = phi ptr [ %37, %36 ], [ null, %38 ]
  store ptr %40, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  call void @expr_free(ptr noundef %41)
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %44

42:                                               ; preds = %2
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %43, ptr %6, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %42, %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call ptr @expr_get_leftmost_symbol(ptr noundef %45)
  store ptr %46, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %47

47:                                               ; preds = %44, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %48 = load ptr, ptr %3, align 8
  ret ptr %48
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @expr_get_leftmost_symbol(ptr noundef) #2

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


; 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 ptr @expr_alloc_and(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @expr_copy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @expr_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @expr_eq(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @expr_eliminate_dups(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @expr_simplify_unmet_dep(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  switch i32 %3, label %common.ret [
    i32 1, label %4
    i32 2, label %12
  ]

common.ret16:                                     ; preds = %4, %common.ret
  %common.ret16.op = phi ptr [ %19, %common.ret ], [ %11, %4 ]
  ret ptr %common.ret16.op

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !10
  %7 = tail call ptr @expr_simplify_unmet_dep(ptr noundef %6, ptr noundef %1)
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !10
  %10 = tail call ptr @expr_simplify_unmet_dep(ptr noundef %9, ptr noundef %1)
  %11 = tail call ptr @expr_alloc_and(ptr noundef %7, ptr noundef %10)
  br label %common.ret16

12:                                               ; preds = %2
  %13 = tail call ptr @expr_copy(ptr noundef nonnull %0)
  %14 = tail call ptr @expr_copy(ptr noundef %1)
  %15 = tail call ptr @expr_alloc_and(ptr noundef %13, ptr noundef %14)
  %16 = tail call ptr @expr_eliminate_dups(ptr noundef %15)
  %17 = tail call i32 @expr_eq(ptr noundef %16, ptr noundef nonnull %0)
  %.not = icmp eq i32 %17, 0
  %18 = select i1 %.not, ptr %0, ptr null
  tail call void @expr_free(ptr noundef %16)
  br label %common.ret

common.ret:                                       ; preds = %2, %12
  %.015 = phi ptr [ %18, %12 ], [ %0, %2 ]
  %19 = tail call ptr @expr_get_leftmost_symbol(ptr noundef %.015)
  br label %common.ret16
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @expr_get_leftmost_symbol(ptr 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 = { inlinehint 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, !7, i64 0}
!6 = !{!"expr", !7, i64 0, !8, i64 8, !8, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}


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