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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ isEmptyDynArr(struct DynArr *);
int /*<<< orphan*/ popDynArr(struct DynArr *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ pushDynArr(struct DynArr *, double);
double topDynArr(struct DynArr *);
void square(struct DynArr *stack) {
  assert(!isEmptyDynArr(stack));
  double num1, num2, sum;
  num1 = topDynArr(stack);
  popDynArr(stack);
  sum = num1 * num1;
  pushDynArr(stack, sum);
  printf("Solution: %f\n", sum);
}


x86 assembly (clang, -O0):
<square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <isEmptyDynArr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <popDynArr@plt>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1080 <pushDynArr@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<square>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1070 <isEmptyDynArr@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <popDynArr@plt>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1080 <pushDynArr@plt>
lea    0xe51(%rip),%rdi
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.DynArr = type { i32 }
@.str = [14 x i8] c"Solution: %f\0A\00"
define void @square(%struct.DynArr* %0) {
%2 = alloca %struct.DynArr*
%3 = alloca double
%4 = alloca double
%5 = alloca double
store %struct.DynArr* %0, %struct.DynArr** %2
%6 = load %struct.DynArr*, %struct.DynArr** %2
%7 = call i32 @isEmptyDynArr(%struct.DynArr* %6)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load %struct.DynArr*, %struct.DynArr** %2
%13 = call double @topDynArr(%struct.DynArr* %12)
store double %13, double* %3
%14 = load %struct.DynArr*, %struct.DynArr** %2
%15 = call i32 @popDynArr(%struct.DynArr* %14)
%16 = load double, double* %3
%17 = load double, double* %3
%18 = fmul double %16, %17
store double %18, double* %5
%19 = load %struct.DynArr*, %struct.DynArr** %2
%20 = load double, double* %5
%21 = call i32 @pushDynArr(%struct.DynArr* %19, double %20)
%22 = load double, double* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %22)
ret void
}

LLVM IR (-O2):
%struct.DynArr = type { i32 }
@.str = [14 x i8] c"Solution: %f\0A\00"
define void @square(%struct.DynArr* %0) {
%2 = tail call i32 @isEmptyDynArr(%struct.DynArr* %0)
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call double @topDynArr(%struct.DynArr* %0)
%7 = tail call i32 @popDynArr(%struct.DynArr* %0)
%8 = fmul double %6, %6
%9 = tail call i32 @pushDynArr(%struct.DynArr* %0, double %8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %8)
ret void
}