; LLVM IR from Ayon-SSP/The-SDE-Prep :: 1]_Data Structures/3]_Stack (Stackusinglinkedlist)

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

@head = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @pop() #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 -1, ptr %2, align 4, !tbaa !5
  call void @create()
  %4 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %5

5:                                                ; preds = %39, %0
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  %7 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2)
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %19

15:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3)
  %18 = load i32, ptr %3, align 4, !tbaa !5
  call void @push(i32 noundef %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %19

19:                                               ; preds = %15, %5
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 2
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = call i32 @pop()
  br label %24

24:                                               ; preds = %22, %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 3
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  call void @isfull()
  br label %28

28:                                               ; preds = %27, %24
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 4
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  call void @isempty()
  br label %32

32:                                               ; preds = %31, %28
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 5
  br i1 %34, label %35, label %37

35:                                               ; preds = %32
  %36 = load ptr, ptr @head, align 8, !tbaa !9
  call void @display(ptr noundef %36)
  br label %37

37:                                               ; preds = %35, %32
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %39

39:                                               ; preds = %37
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %5, label %42, !llvm.loop !11

42:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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 }

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

@head = external dso_local local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @pop() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  store i32 -1, ptr %1, align 4, !tbaa !5
  tail call void @create()
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %4

4:                                                ; preds = %36, %0
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %18

14:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18)
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %17 = load i32, ptr %2, align 4, !tbaa !5
  call void @push(i32 noundef %17)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  %.pr = load i32, ptr %1, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %14, %4
  %19 = phi i32 [ %.pr, %14 ], [ %12, %4 ]
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = call i32 @pop()
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %21, %18
  %24 = phi i32 [ %.pre, %21 ], [ %19, %18 ]
  %25 = icmp eq i32 %24, 3
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  call void @isfull()
  %.pr1 = load i32, ptr %1, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %26, %23
  %28 = phi i32 [ %.pr1, %26 ], [ %24, %23 ]
  %29 = icmp eq i32 %28, 4
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  call void @isempty()
  %.pre2 = load i32, ptr %1, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %30, %27
  %32 = phi i32 [ %.pre2, %30 ], [ %28, %27 ]
  %33 = icmp eq i32 %32, 5
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = load ptr, ptr @head, align 8, !tbaa !9
  call void @display(ptr noundef %35)
  br label %36

36:                                               ; preds = %34, %31
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %38 = load i32, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %38, 0
  br i1 %.not, label %39, label %4, !llvm.loop !11

39:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0
}

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 = { 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 #3 = { 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 = !{!"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"}


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