#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 */

/* Variables and functions */
int /*<<< orphan*/ draw_char(int, int, char);
int p_norm(int, int, double);
scalar_t__ round(double);
void draw_ellipse_p(double x0, double y0, double xr, double yr, double p,
                    char c) {
  if ((xr <= 0) || (yr <= 0) || (p <= 0)) {
    return;
  }
  int rect_x0 = (int)round(x0 - xr);
  int rect_y0 = (int)round(y0 - yr);
  int rect_x1 = (int)round(x0 + xr + 1);
  int rect_y1 = (int)round(y0 + yr + 1);
  for (int y = rect_y0; y < rect_y1; y++) {
    for (int x = rect_x0; x < rect_x1; x++) {
      if (p_norm((x - x0) / xr, (y - y0) / yr, p) <= 1) {
        draw_char(x, y, c);
      }
    }
  }
}


x86 assembly (clang, -O0):
<draw_ellipse_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dil,%al
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %al,-0x29(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1181 <draw_ellipse_p+0x51>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    1181 <draw_ellipse_p+0x51>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1186 <draw_ellipse_p+0x56>
jmp    1278 <draw_ellipse_p+0x148>
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1050 <round@plt>
mov    %eax,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <round@plt>
mov    %eax,-0x34(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <round@plt>
mov    %eax,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe26(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <round@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1278 <draw_ellipse_p+0x148>
mov    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1265 <draw_ellipse_p+0x135>
cvtsi2sdl -0x44(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x40(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%esi
movsd  -0x28(%rbp),%xmm0
call   1040 <p_norm@plt>
cmp    $0x1,%eax
jg     1252 <draw_ellipse_p+0x122>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%esi
movsbl -0x29(%rbp),%edx
call   1030 <draw_char@plt>
jmp    1257 <draw_ellipse_p+0x127>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11fe <draw_ellipse_p+0xce>
jmp    126a <draw_ellipse_p+0x13a>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11ec <draw_ellipse_p+0xbc>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_ellipse_p>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm2,0x20(%rsp)
ucomisd %xmm2,%xmm0
jae    1273 <draw_ellipse_p+0x143>
ucomisd 0x8(%rsp),%xmm0
jae    1273 <draw_ellipse_p+0x143>
xorpd  %xmm0,%xmm0
ucomisd 0x28(%rsp),%xmm0
jae    1273 <draw_ellipse_p+0x143>
mov    %edi,%ebp
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
call   1050 <round@plt>
mov    %rax,%r14
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
call   1050 <round@plt>
mov    %rax,%r15
movsd  0x18(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
addsd  0xe3c(%rip),%xmm0
call   1050 <round@plt>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe20(%rip),%xmm0
call   1050 <round@plt>
mov    %rax,0x30(%rsp)
cmp    %eax,%r15d
jge    1273 <draw_ellipse_p+0x143>
movsbl %bpl,%r13d
jmp    120b <draw_ellipse_p+0xdb>
nopl   0x0(%rax)
add    $0x1,%r15d
cmp    0x30(%rsp),%r15d
je     1273 <draw_ellipse_p+0x143>
cmp    %ebx,%r14d
jge    1200 <draw_ellipse_p+0xd0>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
subsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%ebp
mov    %r14d,%r12d
jmp    1239 <draw_ellipse_p+0x109>
nopl   (%rax)
add    $0x1,%r12d
cmp    %r12d,%ebx
je     1200 <draw_ellipse_p+0xd0>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
subsd  0x18(%rsp),%xmm0
divsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
mov    %ebp,%esi
movsd  0x28(%rsp),%xmm0
call   1040 <p_norm@plt>
cmp    $0x1,%eax
jg     1230 <draw_ellipse_p+0x100>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r13d,%edx
call   1030 <draw_char@plt>
jmp    1230 <draw_ellipse_p+0x100>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @draw_ellipse_p(double %0, double %1, double %2, double %3, double %4, i8 signext %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store i8 %5, i8* %12
%19 = load double, double* %9
%20 = fcmp ole double %19, 0.000000e+00
br i1 %20, label %27, label %21
21: ; preds = %6
%22 = load double, double* %10
%23 = fcmp ole double %22, 0.000000e+00
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load double, double* %11
%26 = fcmp ole double %25, 0.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %24, %21, %6
br label %93
28: ; preds = %24
%29 = load double, double* %7
%30 = load double, double* %9
%31 = fsub double %29, %30
%32 = call i64 @round(double %31)
%33 = trunc i64 %32 to i32
store i32 %33, i32* %13
%34 = load double, double* %8
%35 = load double, double* %10
%36 = fsub double %34, %35
%37 = call i64 @round(double %36)
%38 = trunc i64 %37 to i32
store i32 %38, i32* %14
%39 = load double, double* %7
%40 = load double, double* %9
%41 = fadd double %39, %40
%42 = fadd double %41, 1.000000e+00
%43 = call i64 @round(double %42)
%44 = trunc i64 %43 to i32
store i32 %44, i32* %15
%45 = load double, double* %8
%46 = load double, double* %10
%47 = fadd double %45, %46
%48 = fadd double %47, 1.000000e+00
%49 = call i64 @round(double %48)
%50 = trunc i64 %49 to i32
store i32 %50, i32* %16
%51 = load i32, i32* %14
store i32 %51, i32* %17
br label %52
52: ; preds = %90, %28
%53 = load i32, i32* %17
%54 = load i32, i32* %16
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %93
56: ; preds = %52
%57 = load i32, i32* %13
store i32 %57, i32* %18
br label %58
58: ; preds = %86, %56
%59 = load i32, i32* %18
%60 = load i32, i32* %15
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %89
62: ; preds = %58
%63 = load i32, i32* %18
%64 = sitofp i32 %63 to double
%65 = load double, double* %7
%66 = fsub double %64, %65
%67 = load double, double* %9
%68 = fdiv double %66, %67
%69 = fptosi double %68 to i32
%70 = load i32, i32* %17
%71 = sitofp i32 %70 to double
%72 = load double, double* %8
%73 = fsub double %71, %72
%74 = load double, double* %10
%75 = fdiv double %73, %74
%76 = fptosi double %75 to i32
%77 = load double, double* %11
%78 = call i32 @p_norm(i32 %69, i32 %76, double %77)
%79 = icmp sle i32 %78, 1
br i1 %79, label %80, label %85
80: ; preds = %62
%81 = load i32, i32* %18
%82 = load i32, i32* %17
%83 = load i8, i8* %12
%84 = call i32 @draw_char(i32 %81, i32 %82, i8 signext %83)
br label %85
85: ; preds = %80, %62
br label %86
86: ; preds = %85
%87 = load i32, i32* %18
%88 = add nsw i32 %87, 1
store i32 %88, i32* %18
br label %58
89: ; preds = %58
br label %90
90: ; preds = %89
%91 = load i32, i32* %17
%92 = add nsw i32 %91, 1
store i32 %92, i32* %17
br label %52
93: ; preds = %27, %52
ret void
}

LLVM IR (-O2):
define void @draw_ellipse_p(double %0, double %1, double %2, double %3, double %4, i8 signext %5) {
%7 = fcmp ole double %2, 0.000000e+00
%8 = fcmp ole double %3, 0.000000e+00
%9 = or i1 %7, %8
%10 = fcmp ole double %4, 0.000000e+00
%11 = or i1 %9, %10
br i1 %11, label %53, label %12
12: ; preds = %6
%13 = fsub double %0, %2
%14 = tail call i64 @round(double %13)
%15 = trunc i64 %14 to i32
%16 = fsub double %1, %3
%17 = tail call i64 @round(double %16)
%18 = trunc i64 %17 to i32
%19 = fadd double %0, %2
%20 = fadd double %19, 1.000000e+00
%21 = tail call i64 @round(double %20)
%22 = trunc i64 %21 to i32
%23 = fadd double %1, %3
%24 = fadd double %23, 1.000000e+00
%25 = tail call i64 @round(double %24)
%26 = trunc i64 %25 to i32
%27 = icmp slt i32 %18, %26
br i1 %27, label %28, label %53
28: ; preds = %12
%29 = icmp slt i32 %15, %22
br label %30
30: ; preds = %28, %37
%31 = phi i32 [ %18, %28 ], [ %38, %37 ]
br i1 %29, label %32, label %37
32: ; preds = %30
%33 = sitofp i32 %31 to double
%34 = fsub double %33, %1
%35 = fdiv double %34, %3
%36 = fptosi double %35 to i32
br label %40
37: ; preds = %50, %30
%38 = add i32 %31, 1
%39 = icmp eq i32 %38, %26
br i1 %39, label %53, label %30
40: ; preds = %32, %50
%41 = phi i32 [ %15, %32 ], [ %51, %50 ]
%42 = sitofp i32 %41 to double
%43 = fsub double %42, %0
%44 = fdiv double %43, %2
%45 = fptosi double %44 to i32
%46 = tail call i32 @p_norm(i32 %45, i32 %36, double %4)
%47 = icmp slt i32 %46, 2
br i1 %47, label %48, label %50
48: ; preds = %40
%49 = tail call i32 @draw_char(i32 %41, i32 %31, i8 signext %5)
br label %50
50: ; preds = %40, %48
%51 = add i32 %41, 1
%52 = icmp eq i32 %51, %22
br i1 %52, label %37, label %40
53: ; preds = %37, %12, %6
ret void
}