#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*/ printf(char *);
int /*<<< orphan*/ pushDynArr(struct DynArr *, double);
double topDynArr(struct DynArr *);
void divide(struct DynArr *stack) {
  double a, b, c = 0;
  if (isEmptyDynArr(stack))
    return;
  a = topDynArr(stack);
  popDynArr(stack);
  if (isEmptyDynArr(stack))
    return;
  b = topDynArr(stack);
  popDynArr(stack);
  if (a == 0) {
    printf("Devide Error: Den is 0. Automatically ignore divide operator. May "
           "cause wrong result. Please check your input.\n");
    pushDynArr(stack, b);
    pushDynArr(stack, a);
  } else {
    c = b / a;
    pushDynArr(stack, c);
  }
}


x86 assembly (clang, -O0):
<divide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <isEmptyDynArr@plt>
cmp    $0x0,%rax
je     117c <divide+0x2c>
jmp    1224 <divide+0xd4>
mov    -0x8(%rbp),%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <popDynArr@plt>
mov    -0x8(%rbp),%rdi
call   1060 <isEmptyDynArr@plt>
cmp    $0x0,%rax
je     11ab <divide+0x5b>
jmp    1224 <divide+0xd4>
mov    -0x8(%rbp),%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <popDynArr@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1207 <divide+0xb7>
jp     1207 <divide+0xb7>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
call   1070 <pushDynArr@plt>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
call   1070 <pushDynArr@plt>
jmp    1224 <divide+0xd4>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1070 <pushDynArr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divide>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1060 <isEmptyDynArr@plt>
test   %rax,%rax
jne    1185 <divide+0x35>
mov    %rbx,%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <popDynArr@plt>
mov    %rbx,%rdi
call   1060 <isEmptyDynArr@plt>
test   %rax,%rax
je     118b <divide+0x3b>
add    $0x10,%rsp
pop    %rbx
ret
mov    %rbx,%rdi
call   1030 <topDynArr@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1050 <popDynArr@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11d3 <divide+0x83>
jp     11d3 <divide+0x83>
lea    0xe47(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
call   1070 <pushDynArr@plt>
movsd  0x8(%rsp),%xmm0
jmp    11e4 <divide+0x94>
movapd %xmm1,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1070 <pushDynArr@plt>

LLVM IR (-O0):
%struct.DynArr = type { i32 }
@.str = [112 x i8] c"Devide Error: Den is 0. Automatically ignore divide operator. May cause wrong result. Please check your input.\0A\00"
define void @divide(%struct.DynArr* %0) {
%2 = alloca %struct.DynArr*
%3 = alloca double
%4 = alloca double
%5 = alloca double
store %struct.DynArr* %0, %struct.DynArr** %2
store double 0.000000e+00, double* %5
%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 %41
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 %41
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 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %34
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0))
%28 = load %struct.DynArr*, %struct.DynArr** %2
%29 = load double, double* %4
%30 = call i32 @pushDynArr(%struct.DynArr* %28, double %29)
%31 = load %struct.DynArr*, %struct.DynArr** %2
%32 = load double, double* %3
%33 = call i32 @pushDynArr(%struct.DynArr* %31, double %32)
br label %41
34: ; preds = %19
%35 = load double, double* %4
%36 = load double, double* %3
%37 = fdiv double %35, %36
store double %37, double* %5
%38 = load %struct.DynArr*, %struct.DynArr** %2
%39 = load double, double* %5
%40 = call i32 @pushDynArr(%struct.DynArr* %38, double %39)
br label %41
41: ; preds = %9, %18, %34, %26
ret void
}

LLVM IR (-O2):
%struct.DynArr = type { i32 }
@str = [111 x i8] c"Devide Error: Den is 0. Automatically ignore divide operator. May cause wrong result. Please check your input.\00"
define void @divide(%struct.DynArr* %0) {
%2 = tail call i64 @isEmptyDynArr(%struct.DynArr* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %21
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 %21
9: ; preds = %4
%10 = tail call double @topDynArr(%struct.DynArr* %0)
%11 = tail call i32 @popDynArr(%struct.DynArr* %0)
%12 = fcmp oeq double %5, 0.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @pushDynArr(%struct.DynArr* %0, double %10)
br label %18
16: ; preds = %9
%17 = fdiv double %10, %5
br label %18
18: ; preds = %16, %13
%19 = phi double [ %5, %13 ], [ %17, %16 ]
%20 = tail call i32 @pushDynArr(%struct.DynArr* %0, double %19)
br label %21
21: ; preds = %18, %4, %1
ret void
}