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

@trans_count = external hidden global i32, align 4

; 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_eliminate_yn(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @expr_eliminate_dups(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %10, label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %9, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %35

10:                                               ; preds = %1
  %11 = load i32, ptr @trans_count, align 4, !tbaa !9
  store i32 %11, ptr %4, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %29, %10
  br label %13

13:                                               ; preds = %12
  store i32 0, ptr @trans_count, align 4, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.expr, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !11
  switch i32 %16, label %24 [
    i32 1, label %17
    i32 2, label %17
  ]

17:                                               ; preds = %13, %13
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.expr, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !11
  call void @expr_eliminate_dups1(i32 noundef %20, ptr noundef %3, ptr noundef %3)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.expr, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !11
  call void @expr_eliminate_dups2(i32 noundef %23, ptr noundef %3, ptr noundef %3)
  br label %24

24:                                               ; preds = %17, %13
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr @trans_count, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  br label %32

29:                                               ; preds = %25
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call ptr @expr_eliminate_yn(ptr noundef %30)
  store ptr %31, ptr %3, align 8, !tbaa !5
  br label %12

32:                                               ; preds = %28
  %33 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %33, ptr @trans_count, align 4, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %34, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %35

35:                                               ; preds = %32, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %36 = load ptr, ptr %2, align 8
  ret ptr %36
}

; Function Attrs: nounwind uwtable
declare hidden void @expr_eliminate_dups1(i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @expr_eliminate_dups2(i32 noundef, ptr noundef, ptr noundef) #1

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"expr", !10, i64 0, !7, i64 8, !7, 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"

@trans_count = external hidden local_unnamed_addr global i32, align 4

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

; Function Attrs: nounwind uwtable
define dso_local ptr @expr_eliminate_dups(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %13, label %3

3:                                                ; preds = %1
  %4 = load i32, ptr @trans_count, align 4, !tbaa !9
  store i32 0, ptr @trans_count, align 4, !tbaa !9
  %5 = load i32, ptr %0, align 8, !tbaa !11
  %.off4 = add i32 %5, -1
  %switch5 = icmp ult i32 %.off4, 2
  br i1 %switch5, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %3, %9
  %6 = phi i32 [ %11, %9 ], [ %5, %3 ]
  call void @expr_eliminate_dups1(i32 noundef %6, ptr noundef nonnull %2, ptr noundef nonnull %2)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = load i32, ptr %7, align 8, !tbaa !11
  call void @expr_eliminate_dups2(i32 noundef %8, ptr noundef nonnull %2, ptr noundef nonnull %2)
  %.pr = load i32, ptr @trans_count, align 4, !tbaa !9
  %.not2 = icmp eq i32 %.pr, 0
  %.pre.pre = load ptr, ptr %2, align 8, !tbaa !5
  br i1 %.not2, label %.thread, label %9

9:                                                ; preds = %.lr.ph
  %10 = call ptr @expr_eliminate_yn(ptr noundef %.pre.pre)
  store ptr %10, ptr %2, align 8, !tbaa !5
  store i32 0, ptr @trans_count, align 4, !tbaa !9
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %.off = add i32 %11, -1
  %switch = icmp ult i32 %.off, 2
  br i1 %switch, label %.lr.ph, label %.thread

.thread:                                          ; preds = %.lr.ph, %9, %3
  %12 = phi ptr [ %0, %3 ], [ %.pre.pre, %.lr.ph ], [ %10, %9 ]
  store i32 %4, ptr @trans_count, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %1, %.thread
  %.0 = phi ptr [ %12, %.thread ], [ null, %1 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden void @expr_eliminate_dups1(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @expr_eliminate_dups2(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"expr", !10, i64 0, !7, i64 8, !7, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass