#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 absolut(struct DynArr *stack) {
  assert(!isEmptyDynArr(stack));
  double num1;
  double sum;
  num1 = topDynArr(stack);
  popDynArr(stack);
  if (num1 < 0) {
    sum = num1 * (-1);
  } else
    sum = num1;
  pushDynArr(stack, sum);
  printf("Solution: %f\n", sum);
}


x86 assembly (clang, -O0):
<absolut>:
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>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11c3 <absolut+0x63>
movsd  0xe4c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11cd <absolut+0x6d>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
call   1080 <pushDynArr@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<absolut>:
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>
movaps %xmm0,(%rsp)
mov    %rbx,%rdi
call   1050 <popDynArr@plt>
movapd 0xe6a(%rip),%xmm2
movapd (%rsp),%xmm3
xorpd  %xmm3,%xmm2
xorpd  %xmm1,%xmm1
movapd %xmm3,%xmm0
cmpltsd %xmm1,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
movapd %xmm0,(%rsp)
mov    %rbx,%rdi
call   1080 <pushDynArr@plt>
lea    0xe44(%rip),%rdi
movaps (%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 @absolut(%struct.DynArr* %0) {
%2 = alloca %struct.DynArr*
%3 = alloca double
%4 = alloca double
store %struct.DynArr* %0, %struct.DynArr** %2
%5 = load %struct.DynArr*, %struct.DynArr** %2
%6 = call i32 @isEmptyDynArr(%struct.DynArr* %5)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%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 double, double* %3
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load double, double* %3
%19 = fmul double %18, -1.000000e+00
store double %19, double* %4
br label %22
20: ; preds = %1
%21 = load double, double* %3
store double %21, double* %4
br label %22
22: ; preds = %20, %17
%23 = load %struct.DynArr*, %struct.DynArr** %2
%24 = load double, double* %4
%25 = call i32 @pushDynArr(%struct.DynArr* %23, double %24)
%26 = load double, double* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %26)
ret void
}

LLVM IR (-O2):
%struct.DynArr = type { i32 }
@.str = [14 x i8] c"Solution: %f\0A\00"
define void @absolut(%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 = fcmp olt double %6, 0.000000e+00
%9 = fneg double %6
%10 = select i1 %8, double %9, double %6
%11 = tail call i32 @pushDynArr(%struct.DynArr* %0, double %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %10)
ret void
}