; LLVM IR from Gottox/sqsh-tools :: libsqsh/src/utils (error)

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

@err_str = external hidden thread_local global [512 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @sqsh_error_str(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
  %5 = call i32 @llvm.abs.i32(i32 %4, i1 true)
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 256
  br i1 %7, label %8, label %15

8:                                                ; preds = %1
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = call align 16 ptr @llvm.threadlocal.address.p0(ptr align 16 @err_str)
  %11 = getelementptr inbounds [512 x i8], ptr %10, i64 0, i64 0
  %12 = call i32 @__xpg_strerror_r(i32 noundef %9, ptr noundef %11, i64 noundef 512) #3
  %13 = call align 16 ptr @llvm.threadlocal.address.p0(ptr align 16 @err_str)
  %14 = getelementptr inbounds [512 x i8], ptr %13, i64 0, i64 0
  store ptr %14, ptr %2, align 8
  br label %69

15:                                               ; preds = %1
  %16 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %16, label %62 [
    i32 256, label %62
    i32 0, label %17
    i32 279, label %18
    i32 257, label %19
    i32 258, label %20
    i32 259, label %21
    i32 260, label %22
    i32 261, label %23
    i32 263, label %24
    i32 264, label %25
    i32 265, label %26
    i32 266, label %27
    i32 267, label %28
    i32 268, label %29
    i32 269, label %30
    i32 270, label %31
    i32 271, label %32
    i32 272, label %33
    i32 273, label %34
    i32 274, label %35
    i32 276, label %36
    i32 275, label %37
    i32 277, label %38
    i32 278, label %39
    i32 280, label %40
    i32 281, label %41
    i32 262, label %42
    i32 282, label %43
    i32 283, label %44
    i32 284, label %45
    i32 285, label %46
    i32 286, label %47
    i32 287, label %48
    i32 288, label %49
    i32 289, label %50
    i32 290, label %51
    i32 291, label %52
    i32 292, label %53
    i32 293, label %54
    i32 294, label %55
    i32 295, label %56
    i32 296, label %57
    i32 297, label %58
    i32 298, label %59
    i32 300, label %60
    i32 299, label %61
  ]

17:                                               ; preds = %15
  store ptr @.str.1, ptr %2, align 8
  br label %69

18:                                               ; preds = %15
  store ptr @.str.2, ptr %2, align 8
  br label %69

19:                                               ; preds = %15
  store ptr @.str.3, ptr %2, align 8
  br label %69

20:                                               ; preds = %15
  store ptr @.str.4, ptr %2, align 8
  br label %69

21:                                               ; preds = %15
  store ptr @.str.5, ptr %2, align 8
  br label %69

22:                                               ; preds = %15
  store ptr @.str.6, ptr %2, align 8
  br label %69

23:                                               ; preds = %15
  store ptr @.str.7, ptr %2, align 8
  br label %69

24:                                               ; preds = %15
  store ptr @.str.8, ptr %2, align 8
  br label %69

25:                                               ; preds = %15
  store ptr @.str.9, ptr %2, align 8
  br label %69

26:                                               ; preds = %15
  store ptr @.str.10, ptr %2, align 8
  br label %69

27:                                               ; preds = %15
  store ptr @.str.11, ptr %2, align 8
  br label %69

28:                                               ; preds = %15
  store ptr @.str.12, ptr %2, align 8
  br label %69

29:                                               ; preds = %15
  store ptr @.str.13, ptr %2, align 8
  br label %69

30:                                               ; preds = %15
  store ptr @.str.14, ptr %2, align 8
  br label %69

31:                                               ; preds = %15
  store ptr @.str.15, ptr %2, align 8
  br label %69

32:                                               ; preds = %15
  store ptr @.str.16, ptr %2, align 8
  br label %69

33:                                               ; preds = %15
  store ptr @.str.17, ptr %2, align 8
  br label %69

34:                                               ; preds = %15
  store ptr @.str.18, ptr %2, align 8
  br label %69

35:                                               ; preds = %15
  store ptr @.str.19, ptr %2, align 8
  br label %69

36:                                               ; preds = %15
  store ptr @.str.20, ptr %2, align 8
  br label %69

37:                                               ; preds = %15
  store ptr @.str.21, ptr %2, align 8
  br label %69

38:                                               ; preds = %15
  store ptr @.str.22, ptr %2, align 8
  br label %69

39:                                               ; preds = %15
  store ptr @.str.23, ptr %2, align 8
  br label %69

40:                                               ; preds = %15
  store ptr @.str.24, ptr %2, align 8
  br label %69

41:                                               ; preds = %15
  store ptr @.str.25, ptr %2, align 8
  br label %69

42:                                               ; preds = %15
  store ptr @.str.26, ptr %2, align 8
  br label %69

43:                                               ; preds = %15
  store ptr @.str.27, ptr %2, align 8
  br label %69

44:                                               ; preds = %15
  store ptr @.str.28, ptr %2, align 8
  br label %69

45:                                               ; preds = %15
  store ptr @.str.29, ptr %2, align 8
  br label %69

46:                                               ; preds = %15
  store ptr @.str.30, ptr %2, align 8
  br label %69

47:                                               ; preds = %15
  store ptr @.str.31, ptr %2, align 8
  br label %69

48:                                               ; preds = %15
  store ptr @.str.32, ptr %2, align 8
  br label %69

49:                                               ; preds = %15
  store ptr @.str.33, ptr %2, align 8
  br label %69

50:                                               ; preds = %15
  store ptr @.str.34, ptr %2, align 8
  br label %69

51:                                               ; preds = %15
  store ptr @.str.35, ptr %2, align 8
  br label %69

52:                                               ; preds = %15
  store ptr @.str.36, ptr %2, align 8
  br label %69

53:                                               ; preds = %15
  store ptr @.str.37, ptr %2, align 8
  br label %69

54:                                               ; preds = %15
  store ptr @.str.38, ptr %2, align 8
  br label %69

55:                                               ; preds = %15
  store ptr @.str.39, ptr %2, align 8
  br label %69

56:                                               ; preds = %15
  store ptr @.str.40, ptr %2, align 8
  br label %69

57:                                               ; preds = %15
  store ptr @.str.41, ptr %2, align 8
  br label %69

58:                                               ; preds = %15
  store ptr @.str.42, ptr %2, align 8
  br label %69

59:                                               ; preds = %15
  store ptr @.str.43, ptr %2, align 8
  br label %69

60:                                               ; preds = %15
  store ptr @.str.44, ptr %2, align 8
  br label %69

61:                                               ; preds = %15
  store ptr @.str.45, ptr %2, align 8
  br label %69

62:                                               ; preds = %15, %15
  %63 = call align 16 ptr @llvm.threadlocal.address.p0(ptr align 16 @err_str)
  %64 = getelementptr inbounds [512 x i8], ptr %63, i64 0, i64 0
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %64, i64 noundef 512, ptr noundef @.str.46, i32 noundef %65) #3
  %67 = call align 16 ptr @llvm.threadlocal.address.p0(ptr align 16 @err_str)
  %68 = getelementptr inbounds [512 x i8], ptr %67, i64 0, i64 0
  store ptr %68, ptr %2, align 8
  br label %69

69:                                               ; preds = %62, %61, %60, %59, %58, %57, %56, %55, %54, %53, %52, %51, %50, %49, %48, %47, %46, %45, %44, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %8
  %70 = load ptr, ptr %2, align 8
  ret ptr %70
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

; Function Attrs: nounwind
declare i32 @__xpg_strerror_r(i32 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 }

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


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

@err_str = external hidden thread_local global [512 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [17 x i8], align 1
@switch.table.sqsh_error_str = private unnamed_addr constant [44 x ptr] [ptr @.str.3, ptr @.str.4, ptr @.str.5, ptr @.str.6, ptr @.str.7, ptr @.str.26, ptr @.str.8, ptr @.str.9, ptr @.str.10, ptr @.str.11, ptr @.str.12, ptr @.str.13, ptr @.str.14, ptr @.str.15, ptr @.str.16, ptr @.str.17, ptr @.str.18, ptr @.str.19, ptr @.str.21, ptr @.str.20, ptr @.str.22, ptr @.str.23, ptr @.str.2, ptr @.str.24, ptr @.str.25, ptr @.str.27, ptr @.str.28, ptr @.str.29, ptr @.str.30, ptr @.str.31, ptr @.str.32, ptr @.str.33, ptr @.str.34, ptr @.str.35, ptr @.str.36, ptr @.str.37, ptr @.str.38, ptr @.str.39, ptr @.str.40, ptr @.str.41, ptr @.str.42, ptr @.str.43, ptr @.str.45, ptr @.str.44], align 8

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @sqsh_error_str(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
  %3 = icmp ult i32 %2, 256
  br i1 %3, label %4, label %7

4:                                                ; preds = %1
  %5 = tail call align 16 ptr @llvm.threadlocal.address.p0(ptr align 16 @err_str)
  %6 = tail call i32 @__xpg_strerror_r(i32 noundef %2, ptr noundef nonnull %5, i64 noundef 512) #4
  br label %13

7:                                                ; preds = %1
  %switch.tableidx = add nsw i32 %2, -257
  %8 = icmp ult i32 %switch.tableidx, 44
  br i1 %8, label %switch.lookup, label %9

9:                                                ; preds = %7
  %10 = tail call align 16 ptr @llvm.threadlocal.address.p0(ptr align 16 @err_str)
  %11 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %10, i64 noundef 512, ptr noundef nonnull @.str.46, i32 noundef %2) #4
  br label %13

switch.lookup:                                    ; preds = %7
  %12 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [44 x ptr], ptr @switch.table.sqsh_error_str, i64 0, i64 %12
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %13

13:                                               ; preds = %switch.lookup, %9, %4
  %.0 = phi ptr [ %5, %4 ], [ %10, %9 ], [ %switch.load, %switch.lookup ]
  ret ptr %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

; Function Attrs: nounwind
declare i32 @__xpg_strerror_r(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 #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)"}


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