#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 */
scalar_t__ isEmptyDynArr(struct DynArr *);
int /*<<< orphan*/ popDynArr(struct DynArr *);
int /*<<< orphan*/ pushDynArr(struct DynArr *, double);
double topDynArr(struct DynArr *);
void add(struct DynArr *stack) {
  double a, b, c;
  if (isEmptyDynArr(stack))
    return;
  a = topDynArr(stack);
  popDynArr(stack);
  if (isEmptyDynArr(stack))
    return;
  b = topDynArr(stack);
  popDynArr(stack);
  c = a + b;
  pushDynArr(stack, c);
}


x86 assembly (clang, -O0):
<add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <isEmptyDynArr@plt>
cmp    $0x0,%rax
je     1164 <add+0x24>
jmp    11c7 <add+0x87>
mov    -0x8(%rbp),%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <popDynArr@plt>
mov    -0x8(%rbp),%rdi
call   1050 <isEmptyDynArr@plt>
cmp    $0x0,%rax
je     1193 <add+0x53>
jmp    11c7 <add+0x87>
mov    -0x8(%rbp),%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <popDynArr@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1060 <pushDynArr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1050 <isEmptyDynArr@plt>
test   %rax,%rax
jne    1175 <add+0x35>
mov    %rbx,%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <popDynArr@plt>
mov    %rbx,%rdi
call   1050 <isEmptyDynArr@plt>
test   %rax,%rax
je     117b <add+0x3b>
add    $0x10,%rsp
pop    %rbx
ret
mov    %rbx,%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1040 <popDynArr@plt>
movsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1060 <pushDynArr@plt>

LLVM IR (-O0):
%struct.DynArr = type { i32 }
define void @add(%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 i64 @isEmptyDynArr(%struct.DynArr* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
br label %30
10: ; preds = %1
%11 = load %struct.DynArr*, %struct.DynArr** %2
%12 = call double @topDynArr(%struct.DynArr* %11)
store double %12, double* %3
%13 = load %struct.DynArr*, %struct.DynArr** %2
%14 = call i32 @popDynArr(%struct.DynArr* %13)
%15 = load %struct.DynArr*, %struct.DynArr** %2
%16 = call i64 @isEmptyDynArr(%struct.DynArr* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %10
br label %30
19: ; preds = %10
%20 = load %struct.DynArr*, %struct.DynArr** %2
%21 = call double @topDynArr(%struct.DynArr* %20)
store double %21, double* %4
%22 = load %struct.DynArr*, %struct.DynArr** %2
%23 = call i32 @popDynArr(%struct.DynArr* %22)
%24 = load double, double* %3
%25 = load double, double* %4
%26 = fadd double %24, %25
store double %26, double* %5
%27 = load %struct.DynArr*, %struct.DynArr** %2
%28 = load double, double* %5
%29 = call i32 @pushDynArr(%struct.DynArr* %27, double %28)
br label %30
30: ; preds = %19, %18, %9
ret void
}

LLVM IR (-O2):
%struct.DynArr = type { i32 }
define void @add(%struct.DynArr* %0) {
%2 = tail call i64 @isEmptyDynArr(%struct.DynArr* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = tail call double @topDynArr(%struct.DynArr* %0)
%6 = tail call i32 @popDynArr(%struct.DynArr* %0)
%7 = tail call i64 @isEmptyDynArr(%struct.DynArr* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = tail call double @topDynArr(%struct.DynArr* %0)
%11 = tail call i32 @popDynArr(%struct.DynArr* %0)
%12 = fadd double %5, %10
%13 = tail call i32 @pushDynArr(%struct.DynArr* %0, double %12)
br label %14
14: ; preds = %4, %1, %9
ret void
}