#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*/ clear_screen();
int /*<<< orphan*/ draw_double(int, int /*<<< orphan*/, double);
int /*<<< orphan*/ draw_ellipse_p(double, double, double, double, double, char);
int /*<<< orphan*/ draw_string(int /*<<< orphan*/, int /*<<< orphan*/, char *);
double screen_height();
double screen_width();
int /*<<< orphan*/ show_screen();
int /*<<< orphan*/ timer_pause(int);
void demo() {
  const int N = 5;
  const double X_MAX = screen_width();
  const double Y_MAX = screen_height();
  double p[] = {0.5, 1, 1.5, 2, 3};
  for (int i = 0; i < N; i++) {
    clear_screen();
    double x0 = X_MAX / 2;
    double y0 = Y_MAX / 2;
    double xr = X_MAX / 3;
    double yr = Y_MAX / 3;
    draw_ellipse_p(x0, y0, xr, yr, p[i], '*');
    draw_string(0, 0, "p = ");
    draw_double(4, 0, p[i]);
    show_screen();
    timer_pause(5000);
  }
}


x86 assembly (clang, -O0):
<demo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x5,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <screen_width@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <screen_height@plt>
movsd  %xmm0,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
movsd  0xe51(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe3c(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe12(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    12e5 <demo+0x155>
mov    $0x0,%al
call   10b0 <clear_screen@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xddb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdc5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xda7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xd91(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm3
movslq -0x44(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm4
mov    $0x2a,%edi
call   1040 <draw_ellipse_p@plt>
xor    %esi,%esi
lea    0xd7f(%rip),%rdx
mov    %esi,%edi
call   1080 <draw_string@plt>
movslq -0x44(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
mov    $0x4,%edi
xor    %esi,%esi
call   1050 <draw_double@plt>
mov    $0x0,%al
call   1070 <show_screen@plt>
mov    $0x1388,%edi
call   1090 <timer_pause@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    120f <demo+0x7f>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demo>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1090 <screen_width@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <screen_height@plt>
movsd  0xe60(%rip),%xmm3
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm3,%xmm2
movsd  %xmm2,0x18(%rsp)
movapd %xmm0,%xmm2
mulsd  %xmm3,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0xe3f(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  %xmm1,(%rsp)
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   10a0 <clear_screen@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movsd  0xdfe(%rip),%xmm4
mov    $0x2a,%edi
call   1040 <draw_ellipse_p@plt>
lea    0xe15(%rip),%rbx
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1070 <draw_string@plt>
mov    $0x4,%edi
xor    %esi,%esi
movsd  0xdd2(%rip),%xmm0
call   1050 <draw_double@plt>
xor    %eax,%eax
call   1060 <show_screen@plt>
mov    $0x1388,%edi
call   1080 <timer_pause@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
movsd  0xdbd(%rip),%xmm4
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
mov    $0x2a,%edi
call   1040 <draw_ellipse_p@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1070 <draw_string@plt>
mov    $0x4,%edi
xor    %esi,%esi
movsd  0xd81(%rip),%xmm0
call   1050 <draw_double@plt>
xor    %eax,%eax
call   1060 <show_screen@plt>
mov    $0x1388,%edi
call   1080 <timer_pause@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
movsd  0xd64(%rip),%xmm4
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
mov    $0x2a,%edi
call   1040 <draw_ellipse_p@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1070 <draw_string@plt>
mov    $0x4,%edi
xor    %esi,%esi
movsd  0xd28(%rip),%xmm0
call   1050 <draw_double@plt>
xor    %eax,%eax
call   1060 <show_screen@plt>
mov    $0x1388,%edi
call   1080 <timer_pause@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
movsd  0xd0b(%rip),%xmm4
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
mov    $0x2a,%edi
call   1040 <draw_ellipse_p@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1070 <draw_string@plt>
mov    $0x4,%edi
xor    %esi,%esi
movsd  0xccf(%rip),%xmm0
call   1050 <draw_double@plt>
xor    %eax,%eax
call   1060 <show_screen@plt>
mov    $0x1388,%edi
call   1080 <timer_pause@plt>
xor    %eax,%eax
call   10a0 <clear_screen@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movsd  0xc7b(%rip),%xmm4
mov    $0x2a,%edi
call   1040 <draw_ellipse_p@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1070 <draw_string@plt>
mov    $0x4,%edi
xor    %esi,%esi
movsd  0xc56(%rip),%xmm0
call   1050 <draw_double@plt>
xor    %eax,%eax
call   1060 <show_screen@plt>
mov    $0x1388,%edi
add    $0x20,%rsp
pop    %rbx
jmp    1080 <timer_pause@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"p = \00"
define void @demo() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca [5 x double]
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 5, i32* %1
%10 = call double (...) @screen_width()
store double %10, double* %2
%11 = call double (...) @screen_height()
store double %11, double* %3
%12 = bitcast [5 x double]* %4 to i8*
%13 = bitcast i8* %12 to [5 x double]*
%14 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 0
store double 5.000000e-01, double* %14
%15 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 1
store double 1.000000e+00, double* %15
%16 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 2
store double 1.500000e+00, double* %16
%17 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 3
store double 2.000000e+00, double* %17
%18 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 4
store double 3.000000e+00, double* %18
store i32 0, i32* %5
br label %19
19: ; preds = %49, %0
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 5
br i1 %21, label %22, label %52
22: ; preds = %19
%23 = call i32 (...) @clear_screen()
%24 = load double, double* %2
%25 = fdiv double %24, 2.000000e+00
store double %25, double* %6
%26 = load double, double* %3
%27 = fdiv double %26, 2.000000e+00
store double %27, double* %7
%28 = load double, double* %2
%29 = fdiv double %28, 3.000000e+00
store double %29, double* %8
%30 = load double, double* %3
%31 = fdiv double %30, 3.000000e+00
store double %31, double* %9
%32 = load double, double* %6
%33 = load double, double* %7
%34 = load double, double* %8
%35 = load double, double* %9
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 %37
%39 = load double, double* %38
%40 = call i32 @draw_ellipse_p(double %32, double %33, double %34, double %35, double %39, i8 signext 42)
%41 = call i32 @draw_string(i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 %43
%45 = load double, double* %44
%46 = call i32 @draw_double(i32 4, i32 0, double %45)
%47 = call i32 (...) @show_screen()
%48 = call i32 @timer_pause(i32 5000)
br label %49
49: ; preds = %22
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %19
52: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"p = \00"
define void @demo() {
%1 = tail call double (...) @screen_width()
%2 = tail call double (...) @screen_height()
%3 = fmul double %1, 5.000000e-01
%4 = fmul double %2, 5.000000e-01
%5 = fdiv double %1, 3.000000e+00
%6 = fdiv double %2, 3.000000e+00
%7 = tail call i32 (...) @clear_screen()
%8 = tail call i32 @draw_ellipse_p(double %3, double %4, double %5, double %6, double 5.000000e-01, i8 signext 42)
%9 = tail call i32 @draw_string(i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @draw_double(i32 4, i32 0, double 5.000000e-01)
%11 = tail call i32 (...) @show_screen()
%12 = tail call i32 @timer_pause(i32 5000)
%13 = tail call i32 (...) @clear_screen()
%14 = tail call i32 @draw_ellipse_p(double %3, double %4, double %5, double %6, double 1.000000e+00, i8 signext 42)
%15 = tail call i32 @draw_string(i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @draw_double(i32 4, i32 0, double 1.000000e+00)
%17 = tail call i32 (...) @show_screen()
%18 = tail call i32 @timer_pause(i32 5000)
%19 = tail call i32 (...) @clear_screen()
%20 = tail call i32 @draw_ellipse_p(double %3, double %4, double %5, double %6, double 1.500000e+00, i8 signext 42)
%21 = tail call i32 @draw_string(i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 @draw_double(i32 4, i32 0, double 1.500000e+00)
%23 = tail call i32 (...) @show_screen()
%24 = tail call i32 @timer_pause(i32 5000)
%25 = tail call i32 (...) @clear_screen()
%26 = tail call i32 @draw_ellipse_p(double %3, double %4, double %5, double %6, double 2.000000e+00, i8 signext 42)
%27 = tail call i32 @draw_string(i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @draw_double(i32 4, i32 0, double 2.000000e+00)
%29 = tail call i32 (...) @show_screen()
%30 = tail call i32 @timer_pause(i32 5000)
%31 = tail call i32 (...) @clear_screen()
%32 = tail call i32 @draw_ellipse_p(double %3, double %4, double %5, double %6, double 3.000000e+00, i8 signext 42)
%33 = tail call i32 @draw_string(i32 0, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%34 = tail call i32 @draw_double(i32 4, i32 0, double 3.000000e+00)
%35 = tail call i32 (...) @show_screen()
%36 = tail call i32 @timer_pause(i32 5000)
ret void
}