#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ isEmptyStack(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ showSucess(int /*<<< orphan*/);
void push(int *stack, int *bottom, int *top) {
  if (isEmptyStack(*bottom, *top)) {
    *bottom = *bottom + 1;
    *top = *top + 1;
  } else {
    *top = *top + 1;
  }
  int value;
  printf("\ninsert value to stack: ");
  scanf("%d", &value);
  stack[*top] = value;
  printf("\nbottom: %d | top: %d\n", *bottom, *top);
  showSucess(0);
  return;
}


x86 assembly (clang, -O0):
<push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <isEmptyStack@plt>
cmp    $0x0,%rax
je     1192 <push+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11a1 <push+0x61>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <showSucess@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%edi
mov    (%rdx),%esi
call   1030 <isEmptyStack@plt>
test   %rax,%rax
je     1164 <push+0x24>
addl   $0x1,(%r14)
addl   $0x1,(%rbx)
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
movslq (%rbx),%rcx
mov    %eax,(%r15,%rcx,4)
mov    (%r14),%esi
mov    (%rbx),%edx
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <showSucess@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0Ainsert value to stack: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"\0Abottom: %d | top: %d\0A\00"
define void @push(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
%12 = call i64 @isEmptyStack(i32 %9, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
%22 = load i32*, i32** %6
store i32 %21, i32* %22
br label %28
23: ; preds = %3
%24 = load i32*, i32** %6
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1
%27 = load i32*, i32** %6
store i32 %26, i32* %27
br label %28
28: ; preds = %23, %14
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%31 = load i32, i32* %7
%32 = load i32*, i32** %4
%33 = load i32*, i32** %6
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %32, i64 %35
store i32 %31, i32* %36
%37 = load i32*, i32** %5
%38 = load i32, i32* %37
%39 = load i32*, i32** %6
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %38, i32 %40)
%42 = call i32 @showSucess(i32 0)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0Ainsert value to stack: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"\0Abottom: %d | top: %d\0A\00"
define void @push(i32* nocapture writeonly %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca i32
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = tail call i64 @isEmptyStack(i32 %5, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
br label %12
12: ; preds = %3, %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = bitcast i32* %4 to i8*
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %0, i64 %20
store i32 %18, i32* %21
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 @showSucess(i32 0)
ret void
}