; LLVM IR from HarshCasper/NeoAlgo :: C/ds (EvaluationOfPostfixExpression)

; 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.stack = type { i32, [50 x float] }

@s = external dso_local global %struct.stack, align 4
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @EvalPostfix(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 -1, ptr @s, align 4, !tbaa !9
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9)
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %11

11:                                               ; preds = %112, %1
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i32, ptr %7, align 4, !tbaa !12
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %12, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !13
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %115

19:                                               ; preds = %11
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !12
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %20, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !13
  %25 = sext i8 %24 to i32
  switch i32 %25, label %111 [
    i32 48, label %26
    i32 49, label %26
    i32 50, label %26
    i32 51, label %26
    i32 52, label %26
    i32 53, label %26
    i32 54, label %26
    i32 55, label %26
    i32 56, label %26
    i32 57, label %26
    i32 43, label %39
    i32 45, label %57
    i32 42, label %75
    i32 47, label %93
  ]

26:                                               ; preds = %19, %19, %19, %19, %19, %19, %19, %19, %19, %19
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !12
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %27, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = sext i8 %31 to i32
  %33 = sub nsw i32 %32, 48
  %34 = sitofp i32 %33 to float
  %35 = load i32, ptr @s, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr @s, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %37
  store float %34, ptr %38, align 4, !tbaa !14
  br label %111

39:                                               ; preds = %19
  %40 = load i32, ptr @s, align 4, !tbaa !9
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr @s, align 4, !tbaa !9
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !14
  store float %44, ptr %4, align 4, !tbaa !14
  %45 = load i32, ptr @s, align 4, !tbaa !9
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr @s, align 4, !tbaa !9
  %47 = sext i32 %45 to i64
  %48 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %47
  %49 = load float, ptr %48, align 4, !tbaa !14
  store float %49, ptr %5, align 4, !tbaa !14
  %50 = load float, ptr %4, align 4, !tbaa !14
  %51 = load float, ptr %5, align 4, !tbaa !14
  %52 = fadd float %50, %51
  %53 = load i32, ptr @s, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr @s, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %55
  store float %52, ptr %56, align 4, !tbaa !14
  br label %111

57:                                               ; preds = %19
  %58 = load i32, ptr @s, align 4, !tbaa !9
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr @s, align 4, !tbaa !9
  %60 = sext i32 %58 to i64
  %61 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %60
  %62 = load float, ptr %61, align 4, !tbaa !14
  store float %62, ptr %5, align 4, !tbaa !14
  %63 = load i32, ptr @s, align 4, !tbaa !9
  %64 = add nsw i32 %63, -1
  store i32 %64, ptr @s, align 4, !tbaa !9
  %65 = sext i32 %63 to i64
  %66 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !14
  store float %67, ptr %4, align 4, !tbaa !14
  %68 = load float, ptr %4, align 4, !tbaa !14
  %69 = load float, ptr %5, align 4, !tbaa !14
  %70 = fsub float %68, %69
  %71 = load i32, ptr @s, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr @s, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %73
  store float %70, ptr %74, align 4, !tbaa !14
  br label %111

75:                                               ; preds = %19
  %76 = load i32, ptr @s, align 4, !tbaa !9
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr @s, align 4, !tbaa !9
  %78 = sext i32 %76 to i64
  %79 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !14
  store float %80, ptr %5, align 4, !tbaa !14
  %81 = load i32, ptr @s, align 4, !tbaa !9
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr @s, align 4, !tbaa !9
  %83 = sext i32 %81 to i64
  %84 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %83
  %85 = load float, ptr %84, align 4, !tbaa !14
  store float %85, ptr %4, align 4, !tbaa !14
  %86 = load float, ptr %4, align 4, !tbaa !14
  %87 = load float, ptr %5, align 4, !tbaa !14
  %88 = fmul float %86, %87
  %89 = load i32, ptr @s, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr @s, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %91
  store float %88, ptr %92, align 4, !tbaa !14
  br label %111

93:                                               ; preds = %19
  %94 = load i32, ptr @s, align 4, !tbaa !9
  %95 = add nsw i32 %94, -1
  store i32 %95, ptr @s, align 4, !tbaa !9
  %96 = sext i32 %94 to i64
  %97 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %96
  %98 = load float, ptr %97, align 4, !tbaa !14
  store float %98, ptr %5, align 4, !tbaa !14
  %99 = load i32, ptr @s, align 4, !tbaa !9
  %100 = add nsw i32 %99, -1
  store i32 %100, ptr @s, align 4, !tbaa !9
  %101 = sext i32 %99 to i64
  %102 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %101
  %103 = load float, ptr %102, align 4, !tbaa !14
  store float %103, ptr %4, align 4, !tbaa !14
  %104 = load float, ptr %4, align 4, !tbaa !14
  %105 = load float, ptr %5, align 4, !tbaa !14
  %106 = fdiv float %104, %105
  %107 = load i32, ptr @s, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr @s, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (%struct.stack, ptr @s, i32 0, i32 1), i64 0, i64 %109
  store float %106, ptr %110, align 4, !tbaa !14
  br label %111

111:                                              ; preds = %93, %75, %57, %39, %26, %19
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %7, align 4, !tbaa !12
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %7, align 4, !tbaa !12
  br label %11, !llvm.loop !16

115:                                              ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %116 = load i32, ptr %2, align 4
  ret i32 %116
}

; 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

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"stack", !11, i64 0, !7, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%struct.stack = type { i32, [50 x float] }

@s = external dso_local local_unnamed_addr global %struct.stack, align 4
@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @EvalPostfix(ptr noundef %0) local_unnamed_addr #0 {
  store i32 -1, ptr @s, align 4, !tbaa !5
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef %0)
  %s.promoted = load i32, ptr @s, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %51, %1
  %indvars.iv = phi i64 [ %indvars.iv.next, %51 ], [ 0, %1 ]
  %5 = phi i32 [ %52, %51 ], [ %s.promoted, %1 ]
  %6 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %7 = load i8, ptr %6, align 1, !tbaa !10
  switch i8 %7, label %51 [
    i8 0, label %53
    i8 48, label %8
    i8 49, label %8
    i8 50, label %8
    i8 51, label %8
    i8 52, label %8
    i8 53, label %8
    i8 54, label %8
    i8 55, label %8
    i8 56, label %8
    i8 57, label %8
    i8 43, label %15
    i8 45, label %24
    i8 42, label %33
    i8 47, label %42
  ]

8:                                                ; preds = %4, %4, %4, %4, %4, %4, %4, %4, %4, %4
  %9 = zext nneg i8 %7 to i32
  %10 = add nsw i32 %9, -48
  %11 = uitofp nneg i32 %10 to float
  %12 = add nsw i32 %5, 1
  store i32 %12, ptr @s, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %13
  store float %11, ptr %14, align 4, !tbaa !11
  br label %51

15:                                               ; preds = %4
  %16 = add nsw i32 %5, -1
  %17 = sext i32 %5 to i64
  %18 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %17
  %19 = load float, ptr %18, align 4, !tbaa !11
  %20 = sext i32 %16 to i64
  %21 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !11
  %23 = fadd float %19, %22
  store i32 %16, ptr @s, align 4, !tbaa !5
  store float %23, ptr %21, align 4, !tbaa !11
  br label %51

24:                                               ; preds = %4
  %25 = add nsw i32 %5, -1
  %26 = sext i32 %5 to i64
  %27 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = sext i32 %25 to i64
  %30 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !11
  %32 = fsub float %31, %28
  store i32 %25, ptr @s, align 4, !tbaa !5
  store float %32, ptr %30, align 4, !tbaa !11
  br label %51

33:                                               ; preds = %4
  %34 = add nsw i32 %5, -1
  %35 = sext i32 %5 to i64
  %36 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !11
  %38 = sext i32 %34 to i64
  %39 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = fmul float %37, %40
  store i32 %34, ptr @s, align 4, !tbaa !5
  store float %41, ptr %39, align 4, !tbaa !11
  br label %51

42:                                               ; preds = %4
  %43 = add nsw i32 %5, -1
  %44 = sext i32 %5 to i64
  %45 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !11
  %47 = sext i32 %43 to i64
  %48 = getelementptr inbounds [50 x float], ptr getelementptr inbounds (i8, ptr @s, i64 4), i64 0, i64 %47
  %49 = load float, ptr %48, align 4, !tbaa !11
  %50 = fdiv float %49, %46
  store i32 %43, ptr @s, align 4, !tbaa !5
  store float %50, ptr %48, align 4, !tbaa !11
  br label %51

51:                                               ; preds = %4, %8, %15, %24, %33, %42
  %52 = phi i32 [ %5, %4 ], [ %12, %8 ], [ %16, %15 ], [ %25, %24 ], [ %34, %33 ], [ %43, %42 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br label %4, !llvm.loop !13

53:                                               ; preds = %4
  ret i32 undef
}

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

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

attributes #0 = { 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 #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" }

!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 = !{!"stack", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass