#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 */
long double get_val(long double, long double, int);
scalar_t__ xmalloc(int);
long double *gen_mandel(int width, int height, long double xmin,
                        long double xmax, long double ymin, long double ymax,
                        int it) {
  long double xres = (xmax - xmin) / width;
  long double yres = (ymax - ymin) / height;
  long double *img =
      (long double *)xmalloc(width * height * sizeof(long double));
  int i, j;
  for (j = 0; j < height; j++)
    for (i = 0; i < width; i++)
      img[i + j * width] = get_val(xmin + i * xres, ymin + j * yres, it);
  return img;
}


x86 assembly (clang, -O0):
<gen_mandel>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
fldt   0x40(%rbp)
fldt   0x30(%rbp)
fldt   0x20(%rbp)
fldt   0x10(%rbp)
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
fstpt  -0x50(%rbp)
mov    %edx,-0x54(%rbp)
fldt   -0x30(%rbp)
fldt   -0x20(%rbp)
fsubrp %st,%st(1)
mov    -0x4(%rbp),%eax
mov    %eax,-0x98(%rbp)
fildl  -0x98(%rbp)
fdivrp %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
fsubrp %st,%st(1)
mov    -0x8(%rbp),%eax
mov    %eax,-0x94(%rbp)
fildl  -0x94(%rbp)
fdivrp %st,%st(1)
fstpt  -0x80(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x4,%rax
mov    %eax,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126b <gen_mandel+0x14b>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1252 <gen_mandel+0x132>
fldt   -0x20(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0xa0(%rbp)
fildl  -0xa0(%rbp)
fldt   -0x70(%rbp)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fldt   -0x40(%rbp)
mov    -0x90(%rbp),%eax
mov    %eax,-0x9c(%rbp)
fildl  -0x9c(%rbp)
fldt   -0x80(%rbp)
fmulp  %st,%st(1)
faddp  %st,%st(1)
mov    -0x54(%rbp),%edi
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <get_val@plt>
mov    -0x88(%rbp),%rax
mov    -0x8c(%rbp),%ecx
mov    -0x90(%rbp),%edx
mov    -0x4(%rbp),%esi
imul   %esi,%edx
add    %edx,%ecx
movslq %ecx,%rcx
shl    $0x4,%rcx
fstpt  (%rax,%rcx,1)
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    11c2 <gen_mandel+0xa2>
jmp    1257 <gen_mandel+0x137>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    11a9 <gen_mandel+0x89>
mov    -0x88(%rbp),%rax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_mandel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %edx,%ebx
mov    %esi,%r15d
fldt   0xf0(%rsp)
fldt   0xd0(%rsp)
fldt   0x100(%rsp)
fldt   0xe0(%rsp)
fld    %st(2)
fstpt  0x54(%rsp)
fsubp  %st,%st(2)
mov    %edi,0x38(%rsp)
fxch   %st(1)
fidivl 0x38(%rsp)
fstpt  0x48(%rsp)
fld    %st(1)
fstpt  0x80(%rsp)
fsubp  %st,%st(1)
mov    %esi,0x3c(%rsp)
fidivl 0x3c(%rsp)
fstpt  0x74(%rsp)
mov    %edi,0x2c(%rsp)
imul   %esi,%edi
shl    $0x4,%edi
call   1040 <xmalloc@plt>
mov    %rax,0x40(%rsp)
test   %r15d,%r15d
jle    1250 <gen_mandel+0x130>
mov    0x2c(%rsp),%eax
movslq %eax,%rcx
mov    %r15d,%edx
mov    %rdx,0x60(%rsp)
mov    %eax,%ebp
shl    $0x4,%rcx
mov    %rcx,0x68(%rsp)
xor    %r14d,%r14d
mov    0x40(%rsp),%r15
jmp    11d4 <gen_mandel+0xb4>
fstp   %st(1)
fstp   %st(0)
add    $0x1,%r14
add    0x68(%rsp),%r15
cmp    0x60(%rsp),%r14
je     1250 <gen_mandel+0x130>
cmpl   $0x0,0x2c(%rsp)
fldt   0x54(%rsp)
fldt   0x48(%rsp)
jle    11c0 <gen_mandel+0xa0>
mov    %r14d,0x34(%rsp)
fldt   0x74(%rsp)
fimull 0x34(%rsp)
fldt   0x80(%rsp)
faddp  %st,%st(1)
fstpt  0x8c(%rsp)
mov    %r15,%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %r13d,0x30(%rsp)
fimull 0x30(%rsp)
faddp  %st,%st(1)
fldt   0x8c(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
mov    %ebx,%edi
call   1030 <get_val@plt>
fldt   0x48(%rsp)
fldt   0x54(%rsp)
fxch   %st(2)
fstpt  (%r12)
add    $0x1,%r13
add    $0x10,%r12
cmp    %r13,%rbp
jne    1210 <gen_mandel+0xf0>
jmp    11c0 <gen_mandel+0xa0>
mov    0x40(%rsp),%rax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80* @gen_mandel(i32 %0, i32 %1, x86_fp80 %2, x86_fp80 %3, x86_fp80 %4, x86_fp80 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca x86_fp80
%11 = alloca x86_fp80
%12 = alloca x86_fp80
%13 = alloca x86_fp80
%14 = alloca i32
%15 = alloca x86_fp80
%16 = alloca x86_fp80
%17 = alloca x86_fp80*
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store x86_fp80 %2, x86_fp80* %10
store x86_fp80 %3, x86_fp80* %11
store x86_fp80 %4, x86_fp80* %12
store x86_fp80 %5, x86_fp80* %13
store i32 %6, i32* %14
%20 = load x86_fp80, x86_fp80* %11
%21 = load x86_fp80, x86_fp80* %10
%22 = fsub x86_fp80 %20, %21
%23 = load i32, i32* %8
%24 = sitofp i32 %23 to x86_fp80
%25 = fdiv x86_fp80 %22, %24
store x86_fp80 %25, x86_fp80* %15
%26 = load x86_fp80, x86_fp80* %13
%27 = load x86_fp80, x86_fp80* %12
%28 = fsub x86_fp80 %26, %27
%29 = load i32, i32* %9
%30 = sitofp i32 %29 to x86_fp80
%31 = fdiv x86_fp80 %28, %30
store x86_fp80 %31, x86_fp80* %16
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = mul nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 16
%37 = trunc i64 %36 to i32
%38 = call i64 @xmalloc(i32 %37)
%39 = inttoptr i64 %38 to x86_fp80*
store x86_fp80* %39, x86_fp80** %17
store i32 0, i32* %19
br label %40
40: ; preds = %74, %7
%41 = load i32, i32* %19
%42 = load i32, i32* %9
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %77
44: ; preds = %40
store i32 0, i32* %18
br label %45
45: ; preds = %70, %44
%46 = load i32, i32* %18
%47 = load i32, i32* %8
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %73
49: ; preds = %45
%50 = load x86_fp80, x86_fp80* %10
%51 = load i32, i32* %18
%52 = sitofp i32 %51 to x86_fp80
%53 = load x86_fp80, x86_fp80* %15
%54 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %52, x86_fp80 %53, x86_fp80 %50)
%55 = load x86_fp80, x86_fp80* %12
%56 = load i32, i32* %19
%57 = sitofp i32 %56 to x86_fp80
%58 = load x86_fp80, x86_fp80* %16
%59 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %57, x86_fp80 %58, x86_fp80 %55)
%60 = load i32, i32* %14
%61 = call x86_fp80 @get_val(x86_fp80 %54, x86_fp80 %59, i32 %60)
%62 = load x86_fp80*, x86_fp80** %17
%63 = load i32, i32* %18
%64 = load i32, i32* %19
%65 = load i32, i32* %8
%66 = mul nsw i32 %64, %65
%67 = add nsw i32 %63, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds x86_fp80, x86_fp80* %62, i64 %68
store x86_fp80 %61, x86_fp80* %69
br label %70
70: ; preds = %49
%71 = load i32, i32* %18
%72 = add nsw i32 %71, 1
store i32 %72, i32* %18
br label %45
73: ; preds = %45
br label %74
74: ; preds = %73
%75 = load i32, i32* %19
%76 = add nsw i32 %75, 1
store i32 %76, i32* %19
br label %40
77: ; preds = %40
%78 = load x86_fp80*, x86_fp80** %17
ret x86_fp80* %78
}

LLVM IR (-O2):
define x86_fp80* @gen_mandel(i32 %0, i32 %1, x86_fp80 %2, x86_fp80 %3, x86_fp80 %4, x86_fp80 %5, i32 %6) {
%8 = fsub x86_fp80 %3, %2
%9 = sitofp i32 %0 to x86_fp80
%10 = fdiv x86_fp80 %8, %9
%11 = fsub x86_fp80 %5, %4
%12 = sitofp i32 %1 to x86_fp80
%13 = fdiv x86_fp80 %11, %12
%14 = shl i32 %0, 4
%15 = mul i32 %14, %1
%16 = tail call i64 @xmalloc(i32 %15)
%17 = inttoptr i64 %16 to x86_fp80*
%18 = icmp sgt i32 %1, 0
br i1 %18, label %19, label %44
19: ; preds = %7
%20 = icmp sgt i32 %0, 0
%21 = sext i32 %0 to i64
%22 = zext i32 %1 to i64
%23 = zext i32 %0 to i64
br label %24
24: ; preds = %19, %41
%25 = phi i64 [ 0, %19 ], [ %42, %41 ]
br i1 %20, label %26, label %41
26: ; preds = %24
%27 = trunc i64 %25 to i32
%28 = sitofp i32 %27 to x86_fp80
%29 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %28, x86_fp80 %13, x86_fp80 %4)
%30 = mul nsw i64 %25, %21
br label %31
31: ; preds = %26, %31
%32 = phi i64 [ 0, %26 ], [ %39, %31 ]
%33 = trunc i64 %32 to i32
%34 = sitofp i32 %33 to x86_fp80
%35 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %34, x86_fp80 %10, x86_fp80 %2)
%36 = tail call x86_fp80 @get_val(x86_fp80 %35, x86_fp80 %29, i32 %6)
%37 = add nsw i64 %32, %30
%38 = getelementptr inbounds x86_fp80, x86_fp80* %17, i64 %37
store x86_fp80 %36, x86_fp80* %38
%39 = add nuw nsw i64 %32, 1
%40 = icmp eq i64 %39, %23
br i1 %40, label %41, label %31
41: ; preds = %31, %24
%42 = add nuw nsw i64 %25, 1
%43 = icmp eq i64 %42, %22
br i1 %43, label %44, label %24
44: ; preds = %41, %7
ret x86_fp80* %17
}