; LLVM IR from sysprog21/shecc :: tools (inliner)

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

@SOURCE = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; 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 zeroext i1 @source_push(ptr noundef, i8 noundef signext) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @source_push_str(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @write_line(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %5 = call zeroext i1 @source_push_str(ptr noundef %4, ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %45, %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i8, ptr %7, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = icmp ne i8 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %48

14:                                               ; preds = %6
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i8, ptr %15, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = sext i8 %19 to i32
  %21 = icmp eq i32 %20, 34
  br i1 %21, label %22, label %27

22:                                               ; preds = %14
  %23 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %24 = call zeroext i1 @source_push(ptr noundef %23, i8 noundef signext 92)
  %25 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %26 = call zeroext i1 @source_push(ptr noundef %25, i8 noundef signext 34)
  br label %44

27:                                               ; preds = %14
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !11
  %33 = sext i8 %32 to i32
  %34 = icmp ne i32 %33, 10
  br i1 %34, label %35, label %43

35:                                               ; preds = %27
  %36 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = call zeroext i1 @source_push(ptr noundef %36, i8 noundef signext %41)
  br label %43

43:                                               ; preds = %35, %27
  br label %44

44:                                               ; preds = %43, %22
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !12

48:                                               ; preds = %13
  %49 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %50 = call zeroext i1 @source_push(ptr noundef %49, i8 noundef signext 92)
  %51 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %52 = call zeroext i1 @source_push(ptr noundef %51, i8 noundef signext 110)
  %53 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %54 = call zeroext i1 @source_push_str(ptr noundef %53, ptr noundef @.str.1)
  ret void
}

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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@SOURCE = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @source_push(ptr noundef, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @source_push_str(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @write_line(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %3 = tail call zeroext i1 @source_push_str(ptr noundef %2, ptr noundef nonnull @.str)
  br label %4

4:                                                ; preds = %19, %1
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ 0, %1 ]
  %5 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %6 = load i8, ptr %5, align 1, !tbaa !9
  switch i8 %6, label %.sink.split [
    i8 0, label %7
    i8 34, label %14
    i8 10, label %19
  ]

7:                                                ; preds = %4
  %8 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %9 = tail call zeroext i1 @source_push(ptr noundef %8, i8 noundef signext 92)
  %10 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %11 = tail call zeroext i1 @source_push(ptr noundef %10, i8 noundef signext 110)
  %12 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %13 = tail call zeroext i1 @source_push_str(ptr noundef %12, ptr noundef nonnull @.str.1)
  ret void

14:                                               ; preds = %4
  %15 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %16 = tail call zeroext i1 @source_push(ptr noundef %15, i8 noundef signext 92)
  br label %.sink.split

.sink.split:                                      ; preds = %4, %14
  %.sink12 = phi i8 [ 34, %14 ], [ %6, %4 ]
  %17 = load ptr, ptr @SOURCE, align 8, !tbaa !5
  %18 = tail call zeroext i1 @source_push(ptr noundef %17, i8 noundef signext %.sink12)
  br label %19

19:                                               ; preds = %.sink.split, %4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br label %4, !llvm.loop !10
}

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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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