#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_fig0(double *, double *, int, double, double, double);
int flush(double x[], double y[], int n, double w, double h, double fct) {
  if (n > 1) {
    draw_fig0(x, y, n, w, h, fct);
    x[0] = x[n - 1];
    y[0] = y[n - 1];
    return (1);
  } else
    return (n);
}


x86 assembly (clang, -O0):
<flush>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jle    119b <flush+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1030 <draw_fig0@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a1 <flush+0x91>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flush>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
cmp    $0x2,%edx
jl     1147 <flush+0x37>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %ebx,%edx
call   1030 <draw_fig0@plt>
add    $0xffffffff,%ebx
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%r15)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @flush(double* %0, double* %1, i32 %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %8
store double* %1, double** %9
store i32 %2, i32* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%14 = load i32, i32* %10
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %40
16: ; preds = %6
%17 = load double*, double** %8
%18 = load double*, double** %9
%19 = load i32, i32* %10
%20 = load double, double* %11
%21 = load double, double* %12
%22 = load double, double* %13
%23 = call i32 @draw_fig0(double* %17, double* %18, i32 %19, double %20, double %21, double %22)
%24 = load double*, double** %8
%25 = load i32, i32* %10
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %8
%31 = getelementptr inbounds double, double* %30, i64 0
store double %29, double* %31
%32 = load double*, double** %9
%33 = load i32, i32* %10
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %32, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %9
%39 = getelementptr inbounds double, double* %38, i64 0
store double %37, double* %39
store i32 1, i32* %7
br label %42
40: ; preds = %6
%41 = load i32, i32* %10
store i32 %41, i32* %7
br label %42
42: ; preds = %40, %16
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
define i32 @flush(double* %0, double* %1, i32 %2, double %3, double %4, double %5) {
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %16
8: ; preds = %6
%9 = tail call i32 @draw_fig0(double* %0, double* %1, i32 %2, double %3, double %4, double %5)
%10 = add nsw i32 %2, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
store double %13, double* %0
%14 = getelementptr inbounds double, double* %1, i64 %11
%15 = load double, double* %14
store double %15, double* %1
br label %16
16: ; preds = %6, %8
%17 = phi i32 [ 1, %8 ], [ %2, %6 ]
ret i32 %17
}