; LLVM IR from yourtion/LearningMasteringAlgorithms-C :: Example/stack (main)

; 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.List_ = type { i32, ptr, ptr, ptr, ptr }
%struct.ListElmt_ = type { ptr, ptr }

@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1

; 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 %struct.List_, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  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 40, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @list_init(ptr noundef %6, ptr noundef @free)
  %10 = load ptr, ptr @stdout, align 8, !tbaa !9
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %28, %2
  %13 = load i32, ptr %8, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 10
  br i1 %14, label %15, label %31

15:                                               ; preds = %12
  %16 = call noalias ptr @malloc(i64 noundef 4) #6
  store ptr %16, ptr %7, align 8, !tbaa !9
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

19:                                               ; preds = %15
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  %22 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %21, ptr %22, align 4, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !9
  %24 = call i32 @stack_push(ptr noundef %6, ptr noundef %23)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %19
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

27:                                               ; preds = %19
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %8, align 4, !tbaa !5
  br label %12, !llvm.loop !11

31:                                               ; preds = %12
  call void @print_stack(ptr noundef %6)
  %32 = load ptr, ptr @stdout, align 8, !tbaa !9
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.1) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %44, %31
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 5
  br i1 %36, label %37, label %47

37:                                               ; preds = %34
  %38 = call i32 @stack_pop(ptr noundef %6, ptr noundef %7)
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %37
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %41) #5
  br label %43

42:                                               ; preds = %37
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

43:                                               ; preds = %40
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %34, !llvm.loop !13

47:                                               ; preds = %34
  call void @print_stack(ptr noundef %6)
  %48 = load ptr, ptr @stdout, align 8, !tbaa !9
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.2) #5
  %50 = call noalias ptr @malloc(i64 noundef 4) #6
  store ptr %50, ptr %7, align 8, !tbaa !9
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

53:                                               ; preds = %47
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 100, ptr %54, align 4, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = call i32 @stack_push(ptr noundef %6, ptr noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

59:                                               ; preds = %53
  %60 = call noalias ptr @malloc(i64 noundef 4) #6
  store ptr %60, ptr %7, align 8, !tbaa !9
  %61 = icmp eq ptr %60, null
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

63:                                               ; preds = %59
  %64 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 200, ptr %64, align 4, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !9
  %66 = call i32 @stack_push(ptr noundef %6, ptr noundef %65)
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %63
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

69:                                               ; preds = %63
  call void @print_stack(ptr noundef %6)
  %70 = getelementptr inbounds %struct.List_, ptr %6, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !14
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %69
  br label %79

74:                                               ; preds = %69
  %75 = getelementptr inbounds %struct.List_, ptr %6, i32 0, i32 3
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  %77 = getelementptr inbounds %struct.ListElmt_, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !16
  br label %79

79:                                               ; preds = %74, %73
  %80 = phi ptr [ null, %73 ], [ %78, %74 ]
  store ptr %80, ptr %7, align 8, !tbaa !9
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %87

82:                                               ; preds = %79
  %83 = load ptr, ptr @stdout, align 8, !tbaa !9
  %84 = load ptr, ptr %7, align 8, !tbaa !9
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.3, i32 noundef %85) #5
  br label %90

87:                                               ; preds = %79
  %88 = load ptr, ptr @stdout, align 8, !tbaa !9
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef @.str.4) #5
  br label %90

90:                                               ; preds = %87, %82
  call void @print_stack(ptr noundef %6)
  %91 = load ptr, ptr @stdout, align 8, !tbaa !9
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %91, ptr noundef @.str.5) #5
  br label %93

93:                                               ; preds = %102, %90
  %94 = getelementptr inbounds %struct.List_, ptr %6, i32 0, i32 0
  %95 = load i32, ptr %94, align 8, !tbaa !18
  %96 = icmp sgt i32 %95, 0
  br i1 %96, label %97, label %103

97:                                               ; preds = %93
  %98 = call i32 @stack_pop(ptr noundef %6, ptr noundef %7)
  %99 = icmp eq i32 %98, 0
  br i1 %99, label %100, label %102

100:                                              ; preds = %97
  %101 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %101) #5
  br label %102

102:                                              ; preds = %100, %97
  br label %93, !llvm.loop !19

103:                                              ; preds = %93
  %104 = getelementptr inbounds %struct.List_, ptr %6, i32 0, i32 3
  %105 = load ptr, ptr %104, align 8, !tbaa !14
  %106 = icmp eq ptr %105, null
  br i1 %106, label %107, label %108

107:                                              ; preds = %103
  br label %113

108:                                              ; preds = %103
  %109 = getelementptr inbounds %struct.List_, ptr %6, i32 0, i32 3
  %110 = load ptr, ptr %109, align 8, !tbaa !14
  %111 = getelementptr inbounds %struct.ListElmt_, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !16
  br label %113

113:                                              ; preds = %108, %107
  %114 = phi ptr [ null, %107 ], [ %112, %108 ]
  store ptr %114, ptr %7, align 8, !tbaa !9
  %115 = icmp ne ptr %114, null
  br i1 %115, label %116, label %121

116:                                              ; preds = %113
  %117 = load ptr, ptr @stdout, align 8, !tbaa !9
  %118 = load ptr, ptr %7, align 8, !tbaa !9
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %117, ptr noundef @.str.6, i32 noundef %119) #5
  br label %124

121:                                              ; preds = %113
  %122 = load ptr, ptr @stdout, align 8, !tbaa !9
  %123 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %122, ptr noundef @.str.7) #5
  br label %124

124:                                              ; preds = %121, %116
  call void @print_stack(ptr noundef %6)
  %125 = load ptr, ptr @stdout, align 8, !tbaa !9
  %126 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %125, ptr noundef @.str.8) #5
  call void @list_destroy(ptr noundef %6)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %127

127:                                              ; preds = %124, %68, %62, %58, %52, %42, %26, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #5
  %128 = load i32, ptr %3, align 4
  ret i32 %128
}

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

declare void @list_init(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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

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

declare i32 @stack_push(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @print_stack(ptr noundef) #0

declare i32 @stack_pop(ptr noundef, ptr noundef) #2

declare void @list_destroy(ptr noundef) #2

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

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 = { "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 "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 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 = { nounwind }
attributes #6 = { 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 = !{!"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"}
!13 = distinct !{!13, !12}
!14 = !{!15, !10, i64 24}
!15 = !{!"List_", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!16 = !{!17, !10, i64 0}
!17 = !{!"ListElmt_", !10, i64 0, !10, i64 8}
!18 = !{!15, !6, i64 0}
!19 = distinct !{!19, !12}


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

%struct.List_ = type { i32, ptr, ptr, ptr, ptr }

@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.List_, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @list_init(ptr noundef nonnull %3, ptr noundef nonnull @free) #6
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str) #6
  %7 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %8 = icmp eq ptr %7, null
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %2
  store i32 1, ptr %7, align 4, !tbaa !9
  %10 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %7) #6
  %.not17 = icmp eq i32 %10, 0
  br i1 %.not17, label %11, label %.loopexit, !llvm.loop !11

11:                                               ; preds = %9
  %12 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %13 = icmp eq ptr %12, null
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %11
  store i32 2, ptr %12, align 4, !tbaa !9
  %15 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %12) #6
  %.not17.1 = icmp eq i32 %15, 0
  br i1 %.not17.1, label %16, label %.loopexit, !llvm.loop !11

16:                                               ; preds = %14
  %17 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %18 = icmp eq ptr %17, null
  br i1 %18, label %.loopexit, label %19

19:                                               ; preds = %16
  store i32 3, ptr %17, align 4, !tbaa !9
  %20 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %17) #6
  %.not17.2 = icmp eq i32 %20, 0
  br i1 %.not17.2, label %21, label %.loopexit, !llvm.loop !11

21:                                               ; preds = %19
  %22 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %23 = icmp eq ptr %22, null
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %21
  store i32 4, ptr %22, align 4, !tbaa !9
  %25 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %22) #6
  %.not17.3 = icmp eq i32 %25, 0
  br i1 %.not17.3, label %26, label %.loopexit, !llvm.loop !11

26:                                               ; preds = %24
  %27 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %.loopexit, label %29

29:                                               ; preds = %26
  store i32 5, ptr %27, align 4, !tbaa !9
  %30 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %27) #6
  %.not17.4 = icmp eq i32 %30, 0
  br i1 %.not17.4, label %31, label %.loopexit, !llvm.loop !11

31:                                               ; preds = %29
  %32 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %33 = icmp eq ptr %32, null
  br i1 %33, label %.loopexit, label %34

34:                                               ; preds = %31
  store i32 6, ptr %32, align 4, !tbaa !9
  %35 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %32) #6
  %.not17.5 = icmp eq i32 %35, 0
  br i1 %.not17.5, label %36, label %.loopexit, !llvm.loop !11

36:                                               ; preds = %34
  %37 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %38 = icmp eq ptr %37, null
  br i1 %38, label %.loopexit, label %39

39:                                               ; preds = %36
  store i32 7, ptr %37, align 4, !tbaa !9
  %40 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %37) #6
  %.not17.6 = icmp eq i32 %40, 0
  br i1 %.not17.6, label %41, label %.loopexit, !llvm.loop !11

41:                                               ; preds = %39
  %42 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %43 = icmp eq ptr %42, null
  br i1 %43, label %.loopexit, label %44

44:                                               ; preds = %41
  store i32 8, ptr %42, align 4, !tbaa !9
  %45 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %42) #6
  %.not17.7 = icmp eq i32 %45, 0
  br i1 %.not17.7, label %46, label %.loopexit, !llvm.loop !11

46:                                               ; preds = %44
  %47 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  %48 = icmp eq ptr %47, null
  br i1 %48, label %.loopexit, label %49

49:                                               ; preds = %46
  store i32 9, ptr %47, align 4, !tbaa !9
  %50 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %47) #6
  %.not17.8 = icmp eq i32 %50, 0
  br i1 %.not17.8, label %51, label %.loopexit, !llvm.loop !11

51:                                               ; preds = %49
  %52 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  store ptr %52, ptr %4, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %.loopexit, label %54

54:                                               ; preds = %51
  store i32 10, ptr %52, align 4, !tbaa !9
  %55 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %52) #6
  %.not17.9 = icmp eq i32 %55, 0
  br i1 %.not17.9, label %56, label %.loopexit, !llvm.loop !11

56:                                               ; preds = %54
  call void @print_stack(ptr noundef nonnull %3)
  %57 = load ptr, ptr @stdout, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.1) #6
  %59 = call i32 @stack_pop(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %.loopexit

61:                                               ; preds = %56
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %62) #6
  %63 = call i32 @stack_pop(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %.loopexit

65:                                               ; preds = %61
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %66) #6
  %67 = call i32 @stack_pop(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %.loopexit

69:                                               ; preds = %65
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %70) #6
  %71 = call i32 @stack_pop(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %.loopexit

73:                                               ; preds = %69
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %74) #6
  %75 = call i32 @stack_pop(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %.loopexit

77:                                               ; preds = %73
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %78) #6
  call void @print_stack(ptr noundef nonnull %3)
  %79 = load ptr, ptr @stdout, align 8, !tbaa !5
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef nonnull @.str.2) #6
  %81 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  store ptr %81, ptr %4, align 8, !tbaa !5
  %82 = icmp eq ptr %81, null
  br i1 %82, label %.loopexit, label %83

83:                                               ; preds = %77
  store i32 100, ptr %81, align 4, !tbaa !9
  %84 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %81) #6
  %.not = icmp eq i32 %84, 0
  br i1 %.not, label %85, label %.loopexit

85:                                               ; preds = %83
  %86 = call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #7
  store ptr %86, ptr %4, align 8, !tbaa !5
  %87 = icmp eq ptr %86, null
  br i1 %87, label %.loopexit, label %88

88:                                               ; preds = %85
  store i32 200, ptr %86, align 4, !tbaa !9
  %89 = call i32 @stack_push(ptr noundef nonnull %3, ptr noundef nonnull %86) #6
  %.not14 = icmp eq i32 %89, 0
  br i1 %.not14, label %90, label %.loopexit

90:                                               ; preds = %88
  call void @print_stack(ptr noundef nonnull %3)
  %91 = getelementptr inbounds i8, ptr %3, i64 24
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  %93 = icmp eq ptr %92, null
  br i1 %93, label %.thread, label %94

.thread:                                          ; preds = %90
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %100

94:                                               ; preds = %90
  %95 = load ptr, ptr %92, align 8, !tbaa !15
  store ptr %95, ptr %4, align 8, !tbaa !5
  %.not15 = icmp eq ptr %95, null
  br i1 %.not15, label %100, label %96

96:                                               ; preds = %94
  %97 = load ptr, ptr @stdout, align 8, !tbaa !5
  %98 = load i32, ptr %95, align 4, !tbaa !9
  %99 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %97, ptr noundef nonnull @.str.3, i32 noundef %98) #6
  br label %103

100:                                              ; preds = %.thread, %94
  %101 = load ptr, ptr @stdout, align 8, !tbaa !5
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef nonnull @.str.4) #6
  br label %103

103:                                              ; preds = %100, %96
  call void @print_stack(ptr noundef nonnull %3)
  %104 = load ptr, ptr @stdout, align 8, !tbaa !5
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %104, ptr noundef nonnull @.str.5) #6
  %106 = load i32, ptr %3, align 8, !tbaa !17
  %107 = icmp sgt i32 %106, 0
  br i1 %107, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %103, %112
  %108 = call i32 @stack_pop(ptr noundef nonnull %3, ptr noundef nonnull %4) #6
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %110, label %112

110:                                              ; preds = %.lr.ph
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %111) #6
  br label %112

112:                                              ; preds = %110, %.lr.ph
  %113 = load i32, ptr %3, align 8, !tbaa !17
  %114 = icmp sgt i32 %113, 0
  br i1 %114, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %112, %103
  %115 = load ptr, ptr %91, align 8, !tbaa !13
  %116 = icmp eq ptr %115, null
  br i1 %116, label %.thread19, label %117

.thread19:                                        ; preds = %._crit_edge
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %123

117:                                              ; preds = %._crit_edge
  %118 = load ptr, ptr %115, align 8, !tbaa !15
  store ptr %118, ptr %4, align 8, !tbaa !5
  %.not16 = icmp eq ptr %118, null
  br i1 %.not16, label %123, label %119

119:                                              ; preds = %117
  %120 = load ptr, ptr @stdout, align 8, !tbaa !5
  %121 = load i32, ptr %118, align 4, !tbaa !9
  %122 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %120, ptr noundef nonnull @.str.6, i32 noundef %121) #6
  br label %126

123:                                              ; preds = %.thread19, %117
  %124 = load ptr, ptr @stdout, align 8, !tbaa !5
  %125 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %124, ptr noundef nonnull @.str.7) #6
  br label %126

126:                                              ; preds = %123, %119
  call void @print_stack(ptr noundef nonnull %3)
  %127 = load ptr, ptr @stdout, align 8, !tbaa !5
  %128 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %127, ptr noundef nonnull @.str.8) #6
  call void @list_destroy(ptr noundef nonnull %3) #6
  br label %.loopexit

.loopexit:                                        ; preds = %9, %2, %11, %14, %16, %19, %21, %24, %26, %29, %31, %34, %36, %39, %41, %44, %46, %49, %51, %54, %56, %61, %65, %69, %73, %88, %85, %83, %77, %126
  %.06 = phi i32 [ 0, %126 ], [ 1, %77 ], [ 1, %83 ], [ 1, %85 ], [ 1, %88 ], [ 1, %73 ], [ 1, %69 ], [ 1, %65 ], [ 1, %61 ], [ 1, %56 ], [ 1, %54 ], [ 1, %51 ], [ 1, %49 ], [ 1, %46 ], [ 1, %44 ], [ 1, %41 ], [ 1, %39 ], [ 1, %36 ], [ 1, %34 ], [ 1, %31 ], [ 1, %29 ], [ 1, %26 ], [ 1, %24 ], [ 1, %21 ], [ 1, %19 ], [ 1, %16 ], [ 1, %14 ], [ 1, %11 ], [ 1, %2 ], [ 1, %9 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #6
  ret i32 %.06
}

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

declare void @list_init(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) #3

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

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

; Function Attrs: nounwind uwtable
declare hidden void @print_stack(ptr noundef) local_unnamed_addr #0

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

declare void @list_destroy(ptr noundef) local_unnamed_addr #2

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

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 willreturn memory(argmem: readwrite) }
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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 24}
!14 = !{!"List_", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!16, !6, i64 0}
!16 = !{!"ListElmt_", !6, i64 0, !6, i64 8}
!17 = !{!14, !10, i64 0}
!18 = distinct !{!18, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass