#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 node_stack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
struct node_stack *stack_init(int);
int stack_min(struct node_stack *);
int stack_pop(struct node_stack **);
int /*<<< orphan*/ stack_push(struct node_stack **, int);
int main() {
  struct node_stack *head = NULL;
  head = stack_init(5);
  stack_push(&head, 5);
  stack_push(&head, 8);
  stack_push(&head, -5);
  stack_push(&head, 10);
  stack_push(&head, 15);
  printf("stack min %d\n", stack_min(head));
  printf("stack pop %d \n", stack_pop(&head));
  printf("stack pop %d \n", stack_pop(&head));
  printf("stack pop %d \n", stack_pop(&head));
  printf("stack min %d\n", stack_min(head));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x5,%edi
call   1060 <stack_init@plt>
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1050 <stack_push@plt>
lea    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1050 <stack_push@plt>
lea    -0x10(%rbp),%rdi
mov    $0xfffffffb,%esi
call   1050 <stack_push@plt>
lea    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <stack_push@plt>
lea    -0x10(%rbp),%rdi
mov    $0xf,%esi
call   1050 <stack_push@plt>
mov    -0x10(%rbp),%rdi
call   1040 <stack_min@plt>
mov    %eax,%esi
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %eax,%esi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %eax,%esi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1070 <stack_pop@plt>
mov    %eax,%esi
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <stack_min@plt>
mov    %eax,%esi
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x5,%edi
call   1060 <stack_init@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
mov    $0xfffffffb,%esi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <stack_push@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
call   1050 <stack_push@plt>
mov    0x8(%rsp),%rdi
call   1040 <stack_min@plt>
lea    0xe41(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <stack_pop@plt>
lea    0xe36(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <stack_pop@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <stack_pop@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%rdi
call   1040 <stack_min@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node_stack = type { i32 }
@.str = [14 x i8] c"stack min %d\0A\00"
@.str.1 = [15 x i8] c"stack pop %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node_stack*
store i32 0, i32* %1
store %struct.node_stack* null, %struct.node_stack** %2
%3 = call %struct.node_stack* @stack_init(i32 5)
store %struct.node_stack* %3, %struct.node_stack** %2
%4 = call i32 @stack_push(%struct.node_stack** %2, i32 5)
%5 = call i32 @stack_push(%struct.node_stack** %2, i32 8)
%6 = call i32 @stack_push(%struct.node_stack** %2, i32 -5)
%7 = call i32 @stack_push(%struct.node_stack** %2, i32 10)
%8 = call i32 @stack_push(%struct.node_stack** %2, i32 15)
%9 = load %struct.node_stack*, %struct.node_stack** %2
%10 = call i32 @stack_min(%struct.node_stack* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @stack_pop(%struct.node_stack** %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 @stack_pop(%struct.node_stack** %2)
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 @stack_pop(%struct.node_stack** %2)
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load %struct.node_stack*, %struct.node_stack** %2
%19 = call i32 @stack_min(%struct.node_stack* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
%struct.node_stack = type { i32 }
@.str = [14 x i8] c"stack min %d\0A\00"
@.str.1 = [15 x i8] c"stack pop %d \0A\00"
define i32 @main() {
%1 = alloca %struct.node_stack*
%2 = bitcast %struct.node_stack** %1 to i8*
%3 = tail call %struct.node_stack* @stack_init(i32 5)
store %struct.node_stack* %3, %struct.node_stack** %1
%4 = call i32 @stack_push(%struct.node_stack** %1, i32 5)
%5 = call i32 @stack_push(%struct.node_stack** %1, i32 8)
%6 = call i32 @stack_push(%struct.node_stack** %1, i32 -5)
%7 = call i32 @stack_push(%struct.node_stack** %1, i32 10)
%8 = call i32 @stack_push(%struct.node_stack** %1, i32 15)
%9 = load %struct.node_stack*, %struct.node_stack** %1
%10 = call i32 @stack_min(%struct.node_stack* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @stack_pop(%struct.node_stack** %1)
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 @stack_pop(%struct.node_stack** %1)
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 @stack_pop(%struct.node_stack** %1)
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load %struct.node_stack*, %struct.node_stack** %1
%19 = call i32 @stack_min(%struct.node_stack* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}