; LLVM IR from introlab/odas :: src/general (format)

; 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.format_obj = type { i32 }

@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local void @format_printf(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp ne ptr %3, null
  br i1 %4, label %5, label %22

5:                                                ; preds = %1
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.format_obj, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %8, label %21 [
    i32 8, label %9
    i32 16, label %11
    i32 24, label %13
    i32 32, label %15
    i32 1, label %17
    i32 2, label %19
  ]

9:                                                ; preds = %5
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %21

11:                                               ; preds = %5
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %21

13:                                               ; preds = %5
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %21

15:                                               ; preds = %5
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %21

17:                                               ; preds = %5
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %21

19:                                               ; preds = %5
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %21

21:                                               ; preds = %19, %17, %15, %13, %11, %9, %5
  br label %24

22:                                               ; preds = %1
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %24

24:                                               ; preds = %22, %21
  ret void
}

attributes #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 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, !11, i64 0}
!10 = !{!"format_obj", !11, i64 0}
!11 = !{!"int", !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.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @format_printf(ptr noundef readonly %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.sink.split, label %2

2:                                                ; preds = %1
  %3 = load i32, ptr %0, align 4, !tbaa !5
  switch i32 %3, label %10 [
    i32 8, label %.sink.split
    i32 16, label %4
    i32 24, label %5
    i32 32, label %6
    i32 1, label %7
    i32 2, label %8
  ]

4:                                                ; preds = %2
  br label %.sink.split

5:                                                ; preds = %2
  br label %.sink.split

6:                                                ; preds = %2
  br label %.sink.split

7:                                                ; preds = %2
  br label %.sink.split

8:                                                ; preds = %2
  br label %.sink.split

.sink.split:                                      ; preds = %1, %2, %8, %7, %6, %5, %4
  %.str.1.sink = phi ptr [ @.str.2, %4 ], [ @.str.3, %5 ], [ @.str.4, %6 ], [ @.str.5, %7 ], [ @.str.6, %8 ], [ @.str.1, %2 ], [ @.str.7, %1 ]
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1.sink)
  br label %10

10:                                               ; preds = %.sink.split, %2
  ret void
}

attributes #0 = { 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 #1 = { nofree 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 = !{!"format_obj", !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


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