#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 fabs(double);
void assignDirichletCondition(int meshSize, double g, double *meshPoints,
                              double *w, double *b) {
  int i, j;
  for (i = 0; i < meshSize; i++) {
    double x = *(meshPoints + 2 * i);
    double y = *(meshPoints + 2 * i + 1);
    if (fabs(x * x + y * y - 1) < 10e-3) {
      for (j = 0; j < meshSize; j++) {
        *(w + meshSize * i + j) = (i == j) ? 1 : 0;
      }
      b[i] = g;
    }
  }
}


x86 assembly (clang, -O0):
<assignDirichletCondition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122b <assignDirichletCondition+0x11b>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  0x8(%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe76(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe59(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1218 <assignDirichletCondition+0x108>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1206 <assignDirichletCondition+0xf6>
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x4(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11b8 <assignDirichletCondition+0xa8>
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    121d <assignDirichletCondition+0x10d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1133 <assignDirichletCondition+0x23>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assignDirichletCondition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x10(%rsp)
mov    %rsi,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
test   %edi,%edi
jle    1287 <assignDirichletCondition+0x177>
mov    %rdx,%rbx
mov    %edi,%eax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rsp)
mov    %eax,%ebp
and    $0x3,%ebp
mov    %eax,%r12d
and    $0xfffffffc,%r12d
lea    0x18(%rdx),%r13
mov    %rax,0x18(%rsp)
lea    0x0(,%rax,8),%r14
xor    %r15d,%r15d
jmp    1196 <assignDirichletCondition+0x86>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%rax
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rax,%r15,8)
add    $0x1,%r15
add    %r14,%r13
add    %r14,%rbx
cmp    0x18(%rsp),%r15
je     1287 <assignDirichletCondition+0x177>
mov    %r15,%rax
shl    $0x4,%rax
mov    0x20(%rsp),%rcx
movsd  (%rcx,%rax,1),%xmm0
movsd  0x8(%rcx,%rax,1),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe3f(%rip),%xmm0
call   1030 <fabs@plt>
movsd  0xe3a(%rip),%xmm1
test   %eax,%eax
jg     1181 <assignDirichletCondition+0x71>
cmpq   $0x3,(%rsp)
jae    1211 <assignDirichletCondition+0x101>
xor    %eax,%eax
test   %rbp,%rbp
je     1170 <assignDirichletCondition+0x60>
lea    (%rbx,%rax,8),%rcx
mov    %r15,%rdx
sub    %rax,%rdx
xor    %eax,%eax
jmp    1202 <assignDirichletCondition+0xf2>
xchg   %ax,%ax
movsd  %xmm0,(%rcx,%rax,8)
add    $0x1,%rax
cmp    %rax,%rbp
je     1170 <assignDirichletCondition+0x60>
movapd %xmm1,%xmm0
cmp    %rax,%rdx
je     11f0 <assignDirichletCondition+0xe0>
xorpd  %xmm0,%xmm0
jmp    11f0 <assignDirichletCondition+0xe0>
xor    %eax,%eax
jmp    1230 <assignDirichletCondition+0x120>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x4,%rax
cmp    %r12,%rax
je     11db <assignDirichletCondition+0xcb>
movapd %xmm1,%xmm0
cmp    %rax,%r15
je     123d <assignDirichletCondition+0x12d>
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x18(%r13,%rax,8)
lea    0x1(%rax),%rcx
movapd %xmm1,%xmm0
cmp    %rcx,%r15
je     1255 <assignDirichletCondition+0x145>
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x10(%r13,%rax,8)
lea    0x2(%rax),%rcx
movapd %xmm1,%xmm0
cmp    %rcx,%r15
je     126d <assignDirichletCondition+0x15d>
xorpd  %xmm0,%xmm0
movsd  %xmm0,-0x8(%r13,%rax,8)
lea    0x3(%rax),%rcx
movapd %xmm1,%xmm0
cmp    %rcx,%r15
je     1220 <assignDirichletCondition+0x110>
xorpd  %xmm0,%xmm0
jmp    1220 <assignDirichletCondition+0x110>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @assignDirichletCondition(i32 %0, double %1, double* nocapture %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %67
7: ; preds = %5
%8 = zext i32 %0 to i64
%9 = zext i32 %0 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %9, 3
%12 = icmp ult i64 %10, 3
%13 = and i64 %9, 4294967292
%14 = icmp eq i64 %11, 0
br label %15
15: ; preds = %7, %64
%16 = phi i64 [ 0, %7 ], [ %65, %64 ]
%17 = shl nuw nsw i64 %16, 1
%18 = getelementptr inbounds double, double* %2, i64 %17
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %18, i64 1
%21 = load double, double* %20
%22 = fmul double %21, %21
%23 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %22)
%24 = fadd double %23, -1.000000e+00
%25 = tail call i32 @fabs(double %24)
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %64
27: ; preds = %15
%28 = mul nsw i64 %16, %8
%29 = getelementptr inbounds double, double* %3, i64 %28
br i1 %12, label %51, label %30
30: ; preds = %27, %30
%31 = phi i64 [ %48, %30 ], [ 0, %27 ]
%32 = phi i64 [ %49, %30 ], [ 0, %27 ]
%33 = icmp eq i64 %16, %31
%34 = uitofp i1 %33 to double
%35 = getelementptr inbounds double, double* %29, i64 %31
store double %34, double* %35
%36 = or i64 %31, 1
%37 = icmp eq i64 %16, %36
%38 = uitofp i1 %37 to double
%39 = getelementptr inbounds double, double* %29, i64 %36
store double %38, double* %39
%40 = or i64 %31, 2
%41 = icmp eq i64 %16, %40
%42 = uitofp i1 %41 to double
%43 = getelementptr inbounds double, double* %29, i64 %40
store double %42, double* %43
%44 = or i64 %31, 3
%45 = icmp eq i64 %16, %44
%46 = uitofp i1 %45 to double
%47 = getelementptr inbounds double, double* %29, i64 %44
store double %46, double* %47
%48 = add nuw nsw i64 %31, 4
%49 = add i64 %32, 4
%50 = icmp eq i64 %49, %13
br i1 %50, label %51, label %30
51: ; preds = %30, %27
%52 = phi i64 [ 0, %27 ], [ %48, %30 ]
br i1 %14, label %62, label %53
53: ; preds = %51, %53
%54 = phi i64 [ %59, %53 ], [ %52, %51 ]
%55 = phi i64 [ %60, %53 ], [ 0, %51 ]
%56 = icmp eq i64 %16, %54
%57 = uitofp i1 %56 to double
%58 = getelementptr inbounds double, double* %29, i64 %54
store double %57, double* %58
%59 = add nuw nsw i64 %54, 1
%60 = add i64 %55, 1
%61 = icmp eq i64 %60, %11
br i1 %61, label %62, label %53
62: ; preds = %53, %51
%63 = getelementptr inbounds double, double* %4, i64 %16
store double %1, double* %63
br label %64
64: ; preds = %62, %15
%65 = add nuw nsw i64 %16, 1
%66 = icmp eq i64 %65, %9
br i1 %66, label %67, label %15
67: ; preds = %64, %5
ret void
}