#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*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stack_dump(struct Stack *);
int /*<<< orphan*/ stack_ok(struct Stack *);
double stack_pop(struct Stack *);
int /*<<< orphan*/ stack_push(struct Stack *, double);
int mul(struct Stack *stk_p) {
  if (!stack_ok(stk_p)) {
    stack_dump(stk_p);
    printf("INVALID STACK IN THE BEGINNING OF mul!!!\n");
    assert(NULL);
  }
  double operand1 = -666;
  double operand2 = -666;
  operand1 = stack_pop(stk_p);
  operand2 = stack_pop(stk_p);
  stack_push(stk_p, operand1 * operand2);
  if (!stack_ok(stk_p)) {
    stack_dump(stk_p);
    printf("INVALID STACK IN THE END OF mul!!!\n");
    assert(NULL);
  }
  return 0;
}


x86 assembly (clang, -O0):
<mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <stack_ok@plt>
cmp    $0x0,%eax
jne    119c <mul+0x3c>
mov    -0x8(%rbp),%rdi
call   1060 <stack_dump@plt>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <assert@plt>
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe4f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <stack_pop@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <stack_pop@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1070 <stack_push@plt>
mov    -0x8(%rbp),%rdi
call   1050 <stack_ok@plt>
cmp    $0x0,%eax
jne    1215 <mul+0xb5>
mov    -0x8(%rbp),%rdi
call   1060 <stack_dump@plt>
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mul>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1050 <stack_ok@plt>
test   %eax,%eax
jne    118c <mul+0x2c>
mov    %rbx,%rdi
call   1060 <stack_dump@plt>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1080 <stack_pop@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1080 <stack_pop@plt>
mulsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1070 <stack_push@plt>
mov    %rbx,%rdi
call   1050 <stack_ok@plt>
test   %eax,%eax
jne    11d7 <mul+0x77>
mov    %rbx,%rdi
call   1060 <stack_dump@plt>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.Stack = type { i32 }
@.str = [42 x i8] c"INVALID STACK IN THE BEGINNING OF mul!!!\0A\00"
@.str.1 = [36 x i8] c"INVALID STACK IN THE END OF mul!!!\0A\00"
define i32 @mul(%struct.Stack* %0) {
%2 = alloca %struct.Stack*
%3 = alloca double
%4 = alloca double
store %struct.Stack* %0, %struct.Stack** %2
%5 = load %struct.Stack*, %struct.Stack** %2
%6 = call i32 @stack_ok(%struct.Stack* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = load %struct.Stack*, %struct.Stack** %2
%10 = call i32 @stack_dump(%struct.Stack* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @assert(i32* null)
br label %13
13: ; preds = %8, %1
store double -6.660000e+02, double* %3
store double -6.660000e+02, double* %4
%14 = load %struct.Stack*, %struct.Stack** %2
%15 = call double @stack_pop(%struct.Stack* %14)
store double %15, double* %3
%16 = load %struct.Stack*, %struct.Stack** %2
%17 = call double @stack_pop(%struct.Stack* %16)
store double %17, double* %4
%18 = load %struct.Stack*, %struct.Stack** %2
%19 = load double, double* %3
%20 = load double, double* %4
%21 = fmul double %19, %20
%22 = call i32 @stack_push(%struct.Stack* %18, double %21)
%23 = load %struct.Stack*, %struct.Stack** %2
%24 = call i32 @stack_ok(%struct.Stack* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %13
%27 = load %struct.Stack*, %struct.Stack** %2
%28 = call i32 @stack_dump(%struct.Stack* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @assert(i32* null)
br label %31
31: ; preds = %26, %13
ret i32 0
}

LLVM IR (-O2):
%struct.Stack = type { i32 }
@str = [41 x i8] c"INVALID STACK IN THE BEGINNING OF mul!!!\00"
@str.2 = [35 x i8] c"INVALID STACK IN THE END OF mul!!!\00"
define i32 @mul(%struct.Stack* %0) {
%2 = tail call i32 @stack_ok(%struct.Stack* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 @stack_dump(%struct.Stack* %0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @assert(i32* null)
br label %8
8: ; preds = %4, %1
%9 = tail call double @stack_pop(%struct.Stack* %0)
%10 = tail call double @stack_pop(%struct.Stack* %0)
%11 = fmul double %9, %10
%12 = tail call i32 @stack_push(%struct.Stack* %0, double %11)
%13 = tail call i32 @stack_ok(%struct.Stack* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = tail call i32 @stack_dump(%struct.Stack* %0)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.2, i64 0, i64 0))
%18 = tail call i32 @assert(i32* null)
br label %19
19: ; preds = %15, %8
ret i32 0
}