#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 */
struct stack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ initStack(struct stack **);
int /*<<< orphan*/ printStack(struct stack *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push(struct stack **, int);
int /*<<< orphan*/ sortStack(struct stack **);
int main(void) {
  struct stack *top;
  initStack(&top);
  push(&top, 30);
  push(&top, -5);
  push(&top, 18);
  push(&top, 14);
  push(&top, -3);
  printf("Stack elements before sorting:\n");
  printStack(top);
  sortStack(&top);
  printf("\n\n");
  printf("Stack elements after sorting:\n");
  printStack(top);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <initStack@plt>
lea    -0x10(%rbp),%rdi
mov    $0x1e,%esi
call   1060 <push@plt>
lea    -0x10(%rbp),%rdi
mov    $0xfffffffb,%esi
call   1060 <push@plt>
lea    -0x10(%rbp),%rdi
mov    $0x12,%esi
call   1060 <push@plt>
lea    -0x10(%rbp),%rdi
mov    $0xe,%esi
call   1060 <push@plt>
lea    -0x10(%rbp),%rdi
mov    $0xfffffffd,%esi
call   1060 <push@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <printStack@plt>
lea    -0x10(%rbp),%rdi
call   1070 <sortStack@plt>
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <printStack@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <initStack@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0xfffffffb,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
call   1060 <push@plt>
mov    %rbx,%rdi
mov    $0xfffffffd,%esi
call   1060 <push@plt>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdi
call   1050 <printStack@plt>
mov    %rbx,%rdi
call   1070 <sortStack@plt>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdi
call   1050 <printStack@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stack = type { i32 }
@.str = [32 x i8] c"Stack elements before sorting:\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [31 x i8] c"Stack elements after sorting:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stack*
store i32 0, i32* %1
%3 = call i32 @initStack(%struct.stack** %2)
%4 = call i32 @push(%struct.stack** %2, i32 30)
%5 = call i32 @push(%struct.stack** %2, i32 -5)
%6 = call i32 @push(%struct.stack** %2, i32 18)
%7 = call i32 @push(%struct.stack** %2, i32 14)
%8 = call i32 @push(%struct.stack** %2, i32 -3)
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = load %struct.stack*, %struct.stack** %2
%11 = call i32 @printStack(%struct.stack* %10)
%12 = call i32 @sortStack(%struct.stack** %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%15 = load %struct.stack*, %struct.stack** %2
%16 = call i32 @printStack(%struct.stack* %15)
ret i32 0
}

LLVM IR (-O2):
%struct.stack = type { i32 }
@str = [31 x i8] c"Stack elements before sorting:\00"
@str.3 = [2 x i8] c"\0A\00"
@str.4 = [30 x i8] c"Stack elements after sorting:\00"
define i32 @main() {
%1 = alloca %struct.stack*
%2 = bitcast %struct.stack** %1 to i8*
%3 = call i32 @initStack(%struct.stack** %1)
%4 = call i32 @push(%struct.stack** %1, i32 30)
%5 = call i32 @push(%struct.stack** %1, i32 -5)
%6 = call i32 @push(%struct.stack** %1, i32 18)
%7 = call i32 @push(%struct.stack** %1, i32 14)
%8 = call i32 @push(%struct.stack** %1, i32 -3)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%10 = load %struct.stack*, %struct.stack** %1
%11 = call i32 @printStack(%struct.stack* %10)
%12 = call i32 @sortStack(%struct.stack** %1)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
%15 = load %struct.stack*, %struct.stack** %1
%16 = call i32 @printStack(%struct.stack* %15)
ret i32 0
}