; LLVM IR from humz2k/sugaryc :: ext/bdwgc/cord/tests (de)

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

@stderr = external global ptr, align 8
@LINES = external global i32, align 4
@arg_file_name = external dso_local global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@stdout = external global ptr, align 8
@stdscr = external global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @do_command(i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @generic_init() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @GC_set_find_leak(i32 noundef 0)
  call void @GC_init()
  call void @GC_enable_incremental()
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = icmp ne i32 %8, 2
  br i1 %9, label %10, label %24

10:                                               ; preds = %2
  %11 = load ptr, ptr @stderr, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = getelementptr inbounds ptr, ptr %12, i64 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str.5, ptr noundef %14) #7
  %16 = load ptr, ptr @stderr, align 8, !tbaa !9
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.6) #7
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.7) #7
  %20 = load ptr, ptr @stderr, align 8, !tbaa !9
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.8) #7
  %22 = load ptr, ptr @stderr, align 8, !tbaa !9
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.9) #7
  call void @exit(i32 noundef 1) #8
  unreachable

24:                                               ; preds = %2
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds ptr, ptr %25, i64 1
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  store ptr %27, ptr @arg_file_name, align 8, !tbaa !9
  %28 = call noalias ptr @GC_malloc_atomic(i64 noundef 8192) #9
  store ptr %28, ptr %7, align 8, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = icmp eq ptr null, %29
  br i1 %30, label %31, label %37

31:                                               ; preds = %24
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr @stderr, align 8, !tbaa !9
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.10) #7
  call void @exit(i32 noundef 3) #8
  unreachable

35:                                               ; No predecessors!
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36, %24
  %38 = load ptr, ptr @stdout, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = call i32 @setvbuf(ptr noundef %38, ptr noundef %39, i32 noundef 0, i64 noundef 8192) #7
  %41 = call ptr @initscr()
  %42 = call i32 @noecho()
  %43 = call i32 @nonl()
  %44 = call i32 @cbreak()
  call void @generic_init()
  br label %45

45:                                               ; preds = %52, %37
  %46 = call i32 @getchar()
  store i32 %46, ptr %6, align 4, !tbaa !5
  %47 = icmp ne i32 %46, 4
  br i1 %47, label %48, label %54

48:                                               ; preds = %45
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = icmp eq i32 %49, -1
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  br label %54

52:                                               ; preds = %48
  %53 = load i32, ptr %6, align 4, !tbaa !5
  call void @do_command(i32 noundef %53)
  br label %45, !llvm.loop !11

54:                                               ; preds = %51, %45
  %55 = load ptr, ptr @stdscr, align 8, !tbaa !9
  %56 = load i32, ptr @LINES, align 4, !tbaa !5
  %57 = sub nsw i32 %56, 1
  %58 = call i32 @wmove(ptr noundef %55, i32 noundef %57, i32 noundef 0)
  %59 = load ptr, ptr @stdscr, align 8, !tbaa !9
  %60 = call i32 @wclrtoeol(ptr noundef %59)
  %61 = load ptr, ptr @stdscr, align 8, !tbaa !9
  %62 = call i32 @wrefresh(ptr noundef %61)
  %63 = call i32 @nl()
  %64 = call i32 @echo()
  %65 = call i32 @endwin()
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  ret i32 0
}

declare void @GC_set_find_leak(i32 noundef) #3

declare void @GC_init() #3

declare void @GC_enable_incremental() #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: allocsize(0)
declare noalias ptr @GC_malloc_atomic(i64 noundef) #5

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

declare ptr @initscr() #3

declare i32 @noecho() #3

declare i32 @nonl() #3

declare i32 @cbreak() #3

; Function Attrs: inlinehint nounwind uwtable
declare i32 @getchar() #6

declare i32 @wmove(ptr noundef, i32 noundef, i32 noundef) #3

declare i32 @wclrtoeol(ptr noundef) #3

declare i32 @wrefresh(ptr noundef) #3

declare i32 @nl() #3

declare i32 @echo() #3

declare i32 @endwin() #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 #5 = { allocsize(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 #6 = { inlinehint 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { allocsize(0) }

!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 = distinct !{!11, !12}
!12 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@LINES = external local_unnamed_addr global i32, align 4
@arg_file_name = external dso_local local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@stdscr = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @do_command(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @generic_init() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  tail call void @GC_set_find_leak(i32 noundef 0) #6
  tail call void @GC_init() #6
  tail call void @GC_enable_incremental() #6
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %15, label %3

3:                                                ; preds = %2
  %4 = load ptr, ptr @stderr, align 8, !tbaa !5
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.5, ptr noundef %5) #7
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.6) #7
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.7) #7
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.8) #7
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.9) #7
  tail call void @exit(i32 noundef 1) #8
  unreachable

15:                                               ; preds = %2
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %17, ptr @arg_file_name, align 8, !tbaa !5
  %18 = tail call noalias dereferenceable_or_null(8192) ptr @GC_malloc_atomic(i64 noundef 8192) #9
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %15
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.10) #7
  tail call void @exit(i32 noundef 3) #8
  unreachable

23:                                               ; preds = %15
  %24 = load ptr, ptr @stdout, align 8, !tbaa !5
  %25 = tail call i32 @setvbuf(ptr noundef %24, ptr noundef nonnull %18, i32 noundef 0, i64 noundef 8192) #6
  %26 = tail call ptr @initscr() #6
  %27 = tail call i32 @noecho() #6
  %28 = tail call i32 @nonl() #6
  %29 = tail call i32 @cbreak() #6
  tail call void @generic_init()
  br label %30

30:                                               ; preds = %32, %23
  %31 = tail call i32 @getchar()
  switch i32 %31, label %32 [
    i32 -1, label %33
    i32 4, label %33
  ]

32:                                               ; preds = %30
  tail call void @do_command(i32 noundef %31)
  br label %30, !llvm.loop !9

33:                                               ; preds = %30, %30
  %34 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %35 = load i32, ptr @LINES, align 4, !tbaa !11
  %36 = add nsw i32 %35, -1
  %37 = tail call i32 @wmove(ptr noundef %34, i32 noundef %36, i32 noundef 0) #6
  %38 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %39 = tail call i32 @wclrtoeol(ptr noundef %38) #6
  %40 = load ptr, ptr @stdscr, align 8, !tbaa !5
  %41 = tail call i32 @wrefresh(ptr noundef %40) #6
  %42 = tail call i32 @nl() #6
  %43 = tail call i32 @echo() #6
  %44 = tail call i32 @endwin() #6
  ret i32 0
}

declare void @GC_set_find_leak(i32 noundef) local_unnamed_addr #2

declare void @GC_init() local_unnamed_addr #2

declare void @GC_enable_incremental() local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

; Function Attrs: allocsize(0)
declare noalias ptr @GC_malloc_atomic(i64 noundef) local_unnamed_addr #4

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

declare ptr @initscr() local_unnamed_addr #2

declare i32 @noecho() local_unnamed_addr #2

declare i32 @nonl() local_unnamed_addr #2

declare i32 @cbreak() local_unnamed_addr #2

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @getchar() local_unnamed_addr #5

declare i32 @wmove(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @wclrtoeol(ptr noundef) local_unnamed_addr #2

declare i32 @wrefresh(ptr noundef) local_unnamed_addr #2

declare i32 @nl() local_unnamed_addr #2

declare i32 @echo() local_unnamed_addr #2

declare i32 @endwin() 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 = { "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 = { allocsize(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 #5 = { inlinehint 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" }
attributes #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(0) }

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


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