#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 */
char pop(char *, int *);
int /*<<< orphan*/ print_stack(char *, int *);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ push(char *, char, int *, int);
int main(void) {
  char s[25];
  int s_top = -1;
  push(s, 'A', &s_top, 25);
  push(s, '+', &s_top, 25);
  push(s, 'Z', &s_top, 25);
  print_stack(s, &s_top);
  char item = pop(s, &s_top);
  printf(" item = %c \n", item);
  print_stack(s, &s_top);
  push(s, '@', &s_top, 25);
  print_stack(s, &s_top);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x41,%esi
lea    -0x24(%rbp),%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
lea    -0x20(%rbp),%rdi
mov    $0x2b,%esi
lea    -0x24(%rbp),%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5a,%esi
lea    -0x24(%rbp),%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <print_stack@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <pop@plt>
mov    %al,-0x25(%rbp)
lea    0xe41(%rip),%rdi
movsbl -0x25(%rbp),%esi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <print_stack@plt>
lea    -0x20(%rbp),%rdi
mov    $0x40,%esi
lea    -0x24(%rbp),%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <print_stack@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    $0x41,%esi
mov    %rbx,%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
mov    %r14,%rdi
mov    $0x2b,%esi
mov    %rbx,%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
mov    %r14,%rdi
mov    $0x5a,%esi
mov    %rbx,%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <print_stack@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <pop@plt>
movsbl %al,%esi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <print_stack@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
mov    $0x19,%ecx
call   1060 <push@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <print_stack@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c" item = %c \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 -1, i32* %3
%5 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%6 = call i32 @push(i8* %5, i8 signext 65, i32* %3, i32 25)
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%8 = call i32 @push(i8* %7, i8 signext 43, i32* %3, i32 25)
%9 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%10 = call i32 @push(i8* %9, i8 signext 90, i32* %3, i32 25)
%11 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%12 = call i32 @print_stack(i8* %11, i32* %3)
%13 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%14 = call signext i8 @pop(i8* %13, i32* %3)
store i8 %14, i8* %4
%15 = load i8, i8* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %15)
%17 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%18 = call i32 @print_stack(i8* %17, i32* %3)
%19 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%20 = call i32 @push(i8* %19, i8 signext 64, i32* %3, i32 25)
%21 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%22 = call i32 @print_stack(i8* %21, i32* %3)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c" item = %c \0A\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%5 = call i32 @push(i8* %3, i8 signext 65, i32* %2, i32 25)
%6 = call i32 @push(i8* %3, i8 signext 43, i32* %2, i32 25)
%7 = call i32 @push(i8* %3, i8 signext 90, i32* %2, i32 25)
%8 = call i32 @print_stack(i8* %3, i32* %2)
%9 = call signext i8 @pop(i8* %3, i32* %2)
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext %9)
%11 = call i32 @print_stack(i8* %3, i32* %2)
%12 = call i32 @push(i8* %3, i8 signext 64, i32* %2, i32 25)
%13 = call i32 @print_stack(i8* %3, i32* %2)
ret i32 0
}