; LLVM IR from hit9/bitproto :: lib/c (bitproto)

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

@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @BpJsonFormatString(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local void @BpJsonFormatBaseType(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %9 = load i32, ptr %5, align 4, !tbaa !5
  switch i32 %9, label %82 [
    i32 1, label %10
    i32 2, label %17
    i32 3, label %47
    i32 5, label %47
    i32 4, label %77
  ]

10:                                               ; preds = %4
  %11 = load ptr, ptr %7, align 8, !tbaa !9
  %12 = load ptr, ptr %8, align 8, !tbaa !9
  %13 = load i8, ptr %12, align 1, !tbaa !11, !range !13, !noundef !14
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i64
  %16 = select i1 %14, ptr @.str.5, ptr @.str.6
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %11, ptr noundef @.str.4, ptr noundef %16)
  br label %82

17:                                               ; preds = %4
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = icmp sle i32 %18, 8
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !9
  %23 = load i8, ptr %22, align 1, !tbaa !15
  %24 = sext i8 %23 to i32
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %21, ptr noundef @.str.7, i32 noundef %24)
  br label %46

25:                                               ; preds = %17
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp sle i32 %26, 16
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = load i16, ptr %30, align 2, !tbaa !16
  %32 = sext i16 %31 to i32
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %29, ptr noundef @.str.7, i32 noundef %32)
  br label %45

33:                                               ; preds = %25
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = icmp sle i32 %34, 32
  br i1 %35, label %36, label %40

36:                                               ; preds = %33
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !9
  %39 = load i32, ptr %38, align 4, !tbaa !5
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %37, ptr noundef @.str.7, i32 noundef %39)
  br label %44

40:                                               ; preds = %33
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !9
  %43 = load i64, ptr %42, align 8, !tbaa !18
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %41, ptr noundef @.str.8, i64 noundef %43)
  br label %44

44:                                               ; preds = %40, %36
  br label %45

45:                                               ; preds = %44, %28
  br label %46

46:                                               ; preds = %45, %20
  br label %82

47:                                               ; preds = %4, %4
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = icmp sle i32 %48, 8
  br i1 %49, label %50, label %55

50:                                               ; preds = %47
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = load i8, ptr %52, align 1, !tbaa !15
  %54 = zext i8 %53 to i32
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %51, ptr noundef @.str.9, i32 noundef %54)
  br label %76

55:                                               ; preds = %47
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = icmp sle i32 %56, 16
  br i1 %57, label %58, label %63

58:                                               ; preds = %55
  %59 = load ptr, ptr %7, align 8, !tbaa !9
  %60 = load ptr, ptr %8, align 8, !tbaa !9
  %61 = load i16, ptr %60, align 2, !tbaa !16
  %62 = zext i16 %61 to i32
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %59, ptr noundef @.str.9, i32 noundef %62)
  br label %75

63:                                               ; preds = %55
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = icmp sle i32 %64, 32
  br i1 %65, label %66, label %70

66:                                               ; preds = %63
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = load ptr, ptr %8, align 8, !tbaa !9
  %69 = load i32, ptr %68, align 4, !tbaa !5
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %67, ptr noundef @.str.10, i32 noundef %69)
  br label %74

70:                                               ; preds = %63
  %71 = load ptr, ptr %7, align 8, !tbaa !9
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  %73 = load i64, ptr %72, align 8, !tbaa !18
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %71, ptr noundef @.str.11, i64 noundef %73)
  br label %74

74:                                               ; preds = %70, %66
  br label %75

75:                                               ; preds = %74, %58
  br label %76

76:                                               ; preds = %75, %50
  br label %82

77:                                               ; preds = %4
  %78 = load ptr, ptr %7, align 8, !tbaa !9
  %79 = load ptr, ptr %8, align 8, !tbaa !9
  %80 = load i8, ptr %79, align 1, !tbaa !15
  %81 = zext i8 %80 to i32
  call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %78, ptr noundef @.str.9, i32 noundef %81)
  br label %82

82:                                               ; preds = %77, %76, %46, %10, %4
  ret void
}

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 = !{!"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 = !{}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !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"

@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @BpJsonFormatBaseType(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  switch i32 %0, label %44 [
    i32 1, label %5
    i32 2, label %9
    i32 3, label %25
    i32 5, label %25
    i32 4, label %41
  ]

5:                                                ; preds = %4
  %6 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %7 = trunc nuw i8 %6 to i1
  %8 = select i1 %7, ptr @.str.5, ptr @.str.6
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.4, ptr noundef nonnull %8)
  br label %44

9:                                                ; preds = %4
  %10 = icmp slt i32 %1, 9
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = load i8, ptr %3, align 1, !tbaa !11
  %13 = sext i8 %12 to i32
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.7, i32 noundef %13)
  br label %44

14:                                               ; preds = %9
  %15 = icmp ult i32 %1, 17
  br i1 %15, label %16, label %19

16:                                               ; preds = %14
  %17 = load i16, ptr %3, align 2, !tbaa !12
  %18 = sext i16 %17 to i32
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.7, i32 noundef %18)
  br label %44

19:                                               ; preds = %14
  %20 = icmp ult i32 %1, 33
  br i1 %20, label %21, label %23

21:                                               ; preds = %19
  %22 = load i32, ptr %3, align 4, !tbaa !14
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.7, i32 noundef %22)
  br label %44

23:                                               ; preds = %19
  %24 = load i64, ptr %3, align 8, !tbaa !16
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.8, i64 noundef %24)
  br label %44

25:                                               ; preds = %4, %4
  %26 = icmp slt i32 %1, 9
  br i1 %26, label %27, label %30

27:                                               ; preds = %25
  %28 = load i8, ptr %3, align 1, !tbaa !11
  %29 = zext i8 %28 to i32
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.9, i32 noundef %29)
  br label %44

30:                                               ; preds = %25
  %31 = icmp ult i32 %1, 17
  br i1 %31, label %32, label %35

32:                                               ; preds = %30
  %33 = load i16, ptr %3, align 2, !tbaa !12
  %34 = zext i16 %33 to i32
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.9, i32 noundef %34)
  br label %44

35:                                               ; preds = %30
  %36 = icmp ult i32 %1, 33
  br i1 %36, label %37, label %39

37:                                               ; preds = %35
  %38 = load i32, ptr %3, align 4, !tbaa !14
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.10, i32 noundef %38)
  br label %44

39:                                               ; preds = %35
  %40 = load i64, ptr %3, align 8, !tbaa !16
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.11, i64 noundef %40)
  br label %44

41:                                               ; preds = %4
  %42 = load i8, ptr %3, align 1, !tbaa !11
  %43 = zext i8 %42 to i32
  tail call void (ptr, ptr, ...) @BpJsonFormatString(ptr noundef %2, ptr noundef nonnull @.str.9, i32 noundef %43)
  br label %44

44:                                               ; preds = %27, %37, %39, %32, %11, %21, %23, %16, %41, %5, %4
  ret void
}

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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}


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