#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*/ __assert_fail(char *, char *, unsigned int, char *);
double ellipseFunc(double, double, double, double, double, double);
void *malloc(int);
char **generateMask(int width, int height, double x, double y, double a,
                    double b) {
  char **mask;
  int i;
  int j;
  void *tmp;
  void *tmp___0;
  double tmp___1;
  {
    tmp = malloc(sizeof(char *) * (unsigned long)width);
    mask = (char **)tmp;
    if (!mask) {
      __assert_fail("mask", "src/csuPreprocessNormalize.c", 356U,
                    "generateMask");
    }
    i = 0;
    while (i < width) {
      tmp___0 = malloc(sizeof(char) * (unsigned long)height);
      *(mask + i) = (char *)tmp___0;
      if (!*(mask + i)) {
        __assert_fail("mask[i]", "src/csuPreprocessNormalize.c", 360U,
                      "generateMask");
      }
      i++;
    }
    j = 0;
    while (j < height) {
      i = 0;
      while (i < width) {
        tmp___1 = ellipseFunc((double)i, (double)j, x, y, a, b);
        if (tmp___1 > (double)0) {
          *(*(mask + i) + j) = (char)1;
        } else {
          *(*(mask + i) + j) = (char)0;
        }
        i++;
      }
      j++;
    }
    return (mask);
  }
}


x86 assembly (clang, -O0):
<generateMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1197 <generateMask+0x67>
lea    0xe81(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x164,%edx
lea    0xe90(%rip),%rcx
call   1030 <__assert_fail@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    120d <generateMask+0xdd>
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11ff <generateMask+0xcf>
lea    0xe48(%rip),%rdi
lea    0xe17(%rip),%rsi
mov    $0x168,%edx
lea    0xe28(%rip),%rcx
call   1030 <__assert_fail@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119e <generateMask+0x6e>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b6 <generateMask+0x186>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a8 <generateMask+0x178>
cvtsi2sdl -0x34(%rbp),%xmm0
cvtsi2sdl -0x38(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
call   1050 <ellipseFunc@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1286 <generateMask+0x156>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
jmp    129a <generateMask+0x16a>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1227 <generateMask+0xf7>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1214 <generateMask+0xe4>
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateMask>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %esi,%ebp
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    118e <generateMask+0x5e>
lea    0xe92(%rip),%rdi
lea    0xe90(%rip),%rsi
lea    0xea6(%rip),%rcx
mov    $0x164,%edx
call   1030 <__assert_fail@plt>
mov    %r14d,%r15d
test   %r14d,%r14d
jle    11e7 <generateMask+0xb7>
xor    %r12d,%r12d
lea    0xe8a(%rip),%rbx
jmp    11b9 <generateMask+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r12,%r15
je     11e7 <generateMask+0xb7>
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,0x0(%r13,%r12,8)
test   %rax,%rax
jne    11b0 <generateMask+0x80>
lea    0xe66(%rip),%rdi
lea    0xe35(%rip),%rsi
mov    $0x168,%edx
mov    %rbx,%rcx
call   1030 <__assert_fail@plt>
jmp    11b0 <generateMask+0x80>
test   %ebp,%ebp
jle    1275 <generateMask+0x145>
mov    %ebp,%r12d
xor    %ebp,%ebp
jmp    1209 <generateMask+0xd9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %r12,%rbp
je     1275 <generateMask+0x145>
test   %r14d,%r14d
movsd  (%rsp),%xmm2
jle    1200 <generateMask+0xd0>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm4
movsd  0x18(%rsp),%xmm5
call   1050 <ellipseFunc@plt>
movsd  (%rsp),%xmm2
ucomisd 0xd9f(%rip),%xmm0
mov    0x0(%r13,%rbx,8),%rax
seta   (%rax,%rbp,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1230 <generateMask+0x100>
jmp    1200 <generateMask+0xd0>
mov    %r13,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"mask\00"
@.str.1 = [29 x i8] c"src/csuPreprocessNormalize.c\00"
@.str.2 = [13 x i8] c"generateMask\00"
@.str.3 = [8 x i8] c"mask[i]\00"
define i8** @generateMask(i32 %0, i32 %1, double %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i8* @malloc(i32 %22)
store i8* %23, i8** %16
%24 = load i8*, i8** %16
%25 = bitcast i8* %24 to i8**
store i8** %25, i8*** %13
%26 = load i8**, i8*** %13
%27 = icmp ne i8** %26, null
br i1 %27, label %30, label %28
28: ; preds = %6
%29 = call i32 @__assert_fail(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 356, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %6
store i32 0, i32* %14
br label %31
31: ; preds = %54, %30
%32 = load i32, i32* %14
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %57
35: ; preds = %31
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = mul i64 1, %37
%39 = trunc i64 %38 to i32
%40 = call i8* @malloc(i32 %39)
store i8* %40, i8** %17
%41 = load i8*, i8** %17
%42 = load i8**, i8*** %13
%43 = load i32, i32* %14
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
store i8* %41, i8** %45
%46 = load i8**, i8*** %13
%47 = load i32, i32* %14
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = icmp ne i8* %50, null
br i1 %51, label %54, label %52
52: ; preds = %35
%53 = call i32 @__assert_fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 360, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %35
%55 = load i32, i32* %14
%56 = add nsw i32 %55, 1
store i32 %56, i32* %14
br label %31
57: ; preds = %31
store i32 0, i32* %15
br label %58
58: ; preds = %100, %57
%59 = load i32, i32* %15
%60 = load i32, i32* %8
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %103
62: ; preds = %58
store i32 0, i32* %14
br label %63
63: ; preds = %97, %62
%64 = load i32, i32* %14
%65 = load i32, i32* %7
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %100
67: ; preds = %63
%68 = load i32, i32* %14
%69 = sitofp i32 %68 to double
%70 = load i32, i32* %15
%71 = sitofp i32 %70 to double
%72 = load double, double* %9
%73 = load double, double* %10
%74 = load double, double* %11
%75 = load double, double* %12
%76 = call double @ellipseFunc(double %69, double %71, double %72, double %73, double %74, double %75)
store double %76, double* %18
%77 = load double, double* %18
%78 = fcmp ogt double %77, 0.000000e+00
br i1 %78, label %79, label %88
79: ; preds = %67
%80 = load i8**, i8*** %13
%81 = load i32, i32* %14
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = load i32, i32* %15
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
store i8 1, i8* %87
br label %97
88: ; preds = %67
%89 = load i8**, i8*** %13
%90 = load i32, i32* %14
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8*, i8** %89, i64 %91
%93 = load i8*, i8** %92
%94 = load i32, i32* %15
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
store i8 0, i8* %96
br label %97
97: ; preds = %88, %79
%98 = load i32, i32* %14
%99 = add nsw i32 %98, 1
store i32 %99, i32* %14
br label %63
100: ; preds = %63
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
store i32 %102, i32* %15
br label %58
103: ; preds = %58
%104 = load i8**, i8*** %13
ret i8** %104
}

LLVM IR (-O2):
@.str = [5 x i8] c"mask\00"
@.str.1 = [29 x i8] c"src/csuPreprocessNormalize.c\00"
@.str.2 = [13 x i8] c"generateMask\00"
@.str.3 = [8 x i8] c"mask[i]\00"
define noalias i8** @generateMask(i32 %0, i32 %1, double %2, double %3, double %4, double %5) {
%7 = shl i32 %0, 3
%8 = tail call i8* @malloc(i32 %7)
%9 = bitcast i8* %8 to i8**
%10 = icmp eq i8* %8, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @__assert_fail(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 356, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = zext i32 %0 to i64
br label %22
17: ; preds = %29, %13
%18 = icmp sgt i32 %1, 0
br i1 %18, label %19, label %52
19: ; preds = %17
%20 = zext i32 %1 to i64
%21 = zext i32 %0 to i64
br label %32
22: ; preds = %15, %29
%23 = phi i64 [ 0, %15 ], [ %30, %29 ]
%24 = tail call i8* @malloc(i32 %1)
%25 = getelementptr inbounds i8*, i8** %9, i64 %23
store i8* %24, i8** %25
%26 = icmp eq i8* %24, null
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @__assert_fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 360, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = add nuw nsw i64 %23, 1
%31 = icmp eq i64 %30, %16
br i1 %31, label %17, label %22
32: ; preds = %19, %49
%33 = phi i64 [ 0, %19 ], [ %50, %49 ]
br i1 %14, label %34, label %49
34: ; preds = %32
%35 = trunc i64 %33 to i32
%36 = sitofp i32 %35 to double
br label %37
37: ; preds = %34, %37
%38 = phi i64 [ 0, %34 ], [ %47, %37 ]
%39 = trunc i64 %38 to i32
%40 = sitofp i32 %39 to double
%41 = tail call double @ellipseFunc(double %40, double %36, double %2, double %3, double %4, double %5)
%42 = fcmp ogt double %41, 0.000000e+00
%43 = getelementptr inbounds i8*, i8** %9, i64 %38
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i64 %33
%46 = zext i1 %42 to i8
store i8 %46, i8* %45
%47 = add nuw nsw i64 %38, 1
%48 = icmp eq i64 %47, %21
br i1 %48, label %49, label %37
49: ; preds = %37, %32
%50 = add nuw nsw i64 %33, 1
%51 = icmp eq i64 %50, %20
br i1 %51, label %52, label %32
52: ; preds = %49, %17
ret i8** %9
}