; LLVM IR from vul337/PrIntFuzz :: config/linux/firmware/carl9170fw/tools/carlu/src (debug)

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

@debug_level = external dso_local global i32, align 4
@print_message_debug_level = external dso_local global i8, align 1
@_stdout = external dso_local global ptr, align 8
@_stddbg = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@_stderr = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@__func__.dbg_lvl_to_fh = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @dbg_lvl_to_fh(i32 noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %4 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %4, label %11 [
    i32 1, label %5
    i32 2, label %5
    i32 3, label %7
    i32 4, label %9
  ]

5:                                                ; preds = %1, %1
  %6 = load ptr, ptr @_stderr, align 8, !tbaa !9
  store ptr %6, ptr %2, align 8
  br label %31

7:                                                ; preds = %1
  %8 = load ptr, ptr @_stdout, align 8, !tbaa !9
  store ptr %8, ptr %2, align 8
  br label %31

9:                                                ; preds = %1
  %10 = load ptr, ptr @_stddbg, align 8, !tbaa !9
  store ptr %10, ptr %2, align 8
  br label %31

11:                                               ; preds = %1
  br label %12

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12
  %14 = load i32, ptr @debug_level, align 4, !tbaa !5
  %15 = icmp ule i32 1, %14
  br i1 %15, label %16, label %26

16:                                               ; preds = %13
  %17 = load i8, ptr @print_message_debug_level, align 1, !tbaa !11, !range !13, !noundef !14
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = call ptr @dbg_lvl_to_fh(i32 noundef 1)
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str, i32 noundef 1, ptr noundef @__func__.dbg_lvl_to_fh, i32 noundef 65, ptr noundef @.str.1) #4
  br label %25

22:                                               ; preds = %16
  %23 = call ptr @dbg_lvl_to_fh(i32 noundef 1)
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.2, ptr noundef @__func__.dbg_lvl_to_fh, i32 noundef 65, ptr noundef @.str.1) #4
  br label %25

25:                                               ; preds = %22, %19
  br label %26

26:                                               ; preds = %25, %13
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr @stderr, align 8, !tbaa !9
  %29 = call i32 @fflush(ptr noundef %28)
  call void @abort() #5
  unreachable

30:                                               ; No predecessors!
  br label %31

31:                                               ; preds = %30, %9, %7, %5
  %32 = load ptr, ptr %2, align 8
  ret ptr %32
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare i32 @fflush(ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @abort() #3

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 = { nounwind "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 = { "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 = { noreturn nounwind "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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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

@debug_level = external dso_local local_unnamed_addr global i32, align 4
@print_message_debug_level = external dso_local local_unnamed_addr global i8, align 1
@_stdout = external dso_local local_unnamed_addr global ptr, align 8
@_stddbg = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@_stderr = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@__func__.dbg_lvl_to_fh = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [46 x i8], align 1
@switch.table.dbg_lvl_to_fh = private unnamed_addr constant [4 x ptr] [ptr @_stderr, ptr @_stderr, ptr @_stdout, ptr @_stddbg], align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @dbg_lvl_to_fh(i32 noundef %0) local_unnamed_addr #0 {
  %switch.tableidx = add i32 %0, -1
  %2 = icmp ult i32 %switch.tableidx, 4
  br i1 %2, label %switch.lookup, label %3

3:                                                ; preds = %1
  %4 = load i32, ptr @debug_level, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %12, label %5

5:                                                ; preds = %3
  %6 = load i8, ptr @print_message_debug_level, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  %.0.i = load ptr, ptr @_stderr, align 8, !tbaa !13
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %.0.i, ptr noundef nonnull @.str, i32 noundef 1, ptr noundef nonnull @__func__.dbg_lvl_to_fh, i32 noundef 65, ptr noundef nonnull @.str.1) #3
  br label %12

10:                                               ; preds = %5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %.0.i, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.dbg_lvl_to_fh, i32 noundef 65, ptr noundef nonnull @.str.1) #3
  br label %12

12:                                               ; preds = %3, %10, %8
  %13 = load ptr, ptr @stderr, align 8, !tbaa !13
  %14 = tail call i32 @fflush(ptr noundef %13)
  tail call void @abort() #4
  unreachable

switch.lookup:                                    ; preds = %1
  %15 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [4 x ptr], ptr @switch.table.dbg_lvl_to_fh, i64 0, i64 %15
  %switch.load = load ptr, ptr %switch.gep, align 8
  %.0 = load ptr, ptr %switch.load, align 8, !tbaa !13
  ret ptr %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #2

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 = { nofree nounwind "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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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