// File: /workspace/github_c_makefile_star2_O0/ZmengXu[P]boxMesh/boxMesh.C
// Function: pointsOfExternalFace(int, int, int, int)
Points pointsOfExternalFace(int externalFaceId, int Nx, int Ny, int Nz)
{
    /* Returns Points of face nInternalFaces+externalFaceId (which is an external face) */

    /* The way to calculate the points depends on which face of the domain it belongs to:
     * The first Ny*Nz faces have outward normal (-1, 0, 0) (referred to as x-)
     * The next  Ny*Nz faces have outward normal ( 1, 0, 0) (referred to as x+)
     * The next  Nx*Nz faces have outward normal ( 0,-1, 0) (referred to as y-)
     * The next  Nx*Nz faces have outward normal ( 0, 1, 0) (referred to as y+)
     * The next  Nx*Ny faces have outward normal ( 0, 0,-1) (referred to as z-)
     * The next  Nx*Ny faces have outward normal ( 0, 0, 1) (referred to as z+)
     * The following tests check in which face of the domain the face is. */
    string normal;
    if   (externalFaceId < Ny*Nz)
        normal = "x-";
    else if (externalFaceId < 2*Ny*Nz)
        normal = "x+";
    else if (externalFaceId < 2*Ny*Nz + Nx*Nz)
        normal = "y-";
    else if (externalFaceId < 2*Ny*Nz + 2*Nx*Nz)
        normal = "y+";
    else if (externalFaceId < 2*Ny*Nz + 2*Nx*Nz + Nx*Ny)
        normal = "z-";
    else if (externalFaceId < 2*Ny*Nz + 2*Nx*Nz + 2*Nx*Ny)
        normal = "z+";
    else
        throw invalid_argument("externalFaceId is too large");

    /* Now that the normal to the face is known, calculate the points in the
     * respective way. */
    int temp;
    int point_1, point_2, point_3, point_4;
    if (normal == "x-")
    {
        temp  = externalFaceId;     // index on "x-" face
        int zCell = int(temp/Ny);   // z-grid-coordinate of face
        int yCell = temp%Ny;        // y-grid-coordinate of face
        point_1 = zCell*(Nx+1)*(Ny+1) + yCell*(Nx+1);
        point_2 = point_1 + (Nx+1)*(Ny+1);
        point_3 = point_2 + (Nx+1);
        point_4 = point_1 + (Nx+1);
    }
    else if (normal == "x+")
    {
        /* To get the formula for point_1, start with the formula for point_1 of face x-,
         * and replace externalFaceId by (externalFaceId-Ny*Nz), and then add Nx. */
        temp  = externalFaceId - (Ny*Nz);
        int zCell = int(temp/Ny);
        int yCell = temp%Ny;
        point_1 = zCell*(Nx+1)*(Ny+1) + yCell*(Nx+1) + Nx;
        point_2 = point_1 + (Nx+1);
        point_3 = point_2 + (Nx+1)*(Ny+1);
        point_4 = point_1 + (Nx+1)*(Ny+1);
    }
    else if (normal == "y-")
    {
        temp  = externalFaceId - (2*Ny*Nz);     // index on "y-" face
        int xCell = int(temp/Nz);               // x-grid-coordinate of face
        int zCell = temp%Nz;                    // z-grid-coordinate of face
        point_1 = zCell*(Nx+1)*(Ny+1) + xCell;
        point_2 = point_1 + 1;
        point_3 = point_2 + (Nx+1)*(Ny+1);
        point_4 = point_3 -1;
    }
    else if (normal == "y+")
    {
        /* To get the formula for point_1, start with the formula for point_1 of face y-,
         * and replace externalFaceId by (externalFaceId-Nx*Nz), and then add (Nx+1)*Ny. */
        temp  = externalFaceId - (2*Ny*Nz + Nx*Nz);
        int xCell = int(temp/Nz);
        int zCell = temp%Nz;
        point_1 = zCell*(Nx+1)*(Ny+1) + xCell + (Nx+1)*Ny;
        point_2 = point_1 + (Nx+1)*(Ny+1);
        point_3 = point_2 + 1;
        point_4 = point_1 + 1;
    }
    else if (normal == "z-")
    {
        temp  = externalFaceId - (2*Ny*Nz + 2*Nx*Nz);   // index on "z-" face
        int xCell = int(temp/Ny);                       // x-grid-coordinate of face
        int yCell = temp%Ny;                            // y-grid-coordinate of face
        point_1 = yCell*(Nx+1) + xCell;
        point_2 = point_1 + (Nx+1);
        point_3 = point_2 + 1;
        point_4 = point_1 + 1;
    }
    else if (normal == "z+")
    {
        /* To get the formula for point_1, start with the formula for point_1 of face z-,
         * and replace externalFaceId by (externalFaceId-Nx*Ny), and then add (Nx+1)*(Ny+1)*Nz. */
        temp  = externalFaceId - (2*Ny*Nz + 2*Nx*Nz + Nx*Ny);
        int xCell = int(temp/Ny);
        int yCell = temp%Ny;
        point_1 = yCell*(Nx+1) + xCell + (Nx+1)*(Ny+1)*Nz;
        point_2 = point_1 + 1;
        point_3 = point_2 + (Nx+1);
        point_4 = point_3 -1;
    }
    else
        throw logic_error("Unexpected value for normal: " + normal);

    Points points;
    points.push_back(point_1);
    points.push_back(point_2);
    points.push_back(point_3);
    points.push_back(point_4);

    return points;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0xc0(%rbp)
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2280
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
imull -0x18(%rbp), %ecx
cmpl %ecx, %eax
jge 0x363c
leaq 0x5f7b(%rip), %rsi      # 0x9596
leaq -0x38(%rbp), %rdi
callq 0x2270
jmp 0x3626
jmp 0x37a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3cd8
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
cmpl %ecx, %eax
jge 0x3663
leaq 0x5f46(%rip), %rsi      # 0x9599
leaq -0x38(%rbp), %rdi
callq 0x2270
jmp 0x365e
jmp 0x37a3
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x3693
leaq 0x5f19(%rip), %rsi      # 0x959c
leaq -0x38(%rbp), %rdi
callq 0x2270
jmp 0x368e
jmp 0x37a1
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
shll %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x36c5
leaq 0x5eea(%rip), %rsi      # 0x959f
leaq -0x38(%rbp), %rdi
callq 0x2270
jmp 0x36c0
jmp 0x379f
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
shll %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movl -0x10(%rbp), %edx
imull -0x14(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x3700
leaq 0x5eb2(%rip), %rsi      # 0x95a2
leaq -0x38(%rbp), %rdi
callq 0x2270
jmp 0x36fb
jmp 0x379d
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
shll %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movl -0x10(%rbp), %edx
shll %edx
imull -0x14(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x373a
leaq 0x5e78(%rip), %rsi      # 0x95a5
leaq -0x38(%rbp), %rdi
callq 0x2270
jmp 0x3738
jmp 0x379b
movl $0x10, %edi
callq 0x20d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
leaq 0x5e50(%rip), %rsi      # 0x95a8
callq 0x23a0
jmp 0x375f
movq -0xc8(%rbp), %rdi
movq 0x9873(%rip), %rsi      # 0xcfe0
movq 0x9854(%rip), %rdx      # 0xcfc8
callq 0x2340
jmp 0x3cea
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x2140
jmp 0x3cd8
jmp 0x379d
jmp 0x379f
jmp 0x37a1
jmp 0x37a3
jmp 0x37a5
leaq 0x5dea(%rip), %rsi      # 0x9596
leaq -0x38(%rbp), %rdi
callq 0x61f0
movb %al, -0xc9(%rbp)
jmp 0x37bd
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x37c9
jmp 0x3841
movl -0xc(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %eax, -0x5c(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %edx, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl -0x60(%rbp), %ecx
movl -0x10(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl -0x14(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
addl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
addl %ecx, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c2c
leaq 0x5d51(%rip), %rsi      # 0x9599
leaq -0x38(%rbp), %rdi
callq 0x61f0
movb %al, -0xca(%rbp)
jmp 0x3859
movb -0xca(%rbp), %al
testb $0x1, %al
jne 0x3868
jmp 0x38f5
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
imull -0x18(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %eax, -0x64(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %edx, -0x68(%rbp)
movl -0x64(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl -0x68(%rbp), %ecx
movl -0x10(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
addl -0x10(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl -0x14(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl -0x14(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c2a
leaq 0x5ca0(%rip), %rsi      # 0x959c
leaq -0x38(%rbp), %rdi
callq 0x61f0
movb %al, -0xcb(%rbp)
jmp 0x390d
movb -0xcb(%rbp), %al
testb $0x1, %al
jne 0x3919
jmp 0x3987
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x18(%rbp)
movl %eax, -0x6c(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x18(%rbp)
movl %edx, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
addl -0x6c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl -0x14(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c28
leaq 0x5c11(%rip), %rsi      # 0x959f
leaq -0x38(%rbp), %rdi
callq 0x61f0
movb %al, -0xcc(%rbp)
jmp 0x399f
movb -0xcc(%rbp), %al
testb $0x1, %al
jne 0x39ae
jmp 0x3a31
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x18(%rbp)
movl %eax, -0x74(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x18(%rbp)
movl %edx, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
addl -0x74(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl -0x14(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c26
leaq 0x5b6a(%rip), %rsi      # 0x95a2
leaq -0x38(%rbp), %rdi
callq 0x61f0
movb %al, -0xcd(%rbp)
jmp 0x3a49
movb -0xcd(%rbp), %al
testb $0x1, %al
jne 0x3a55
jmp 0x3abc
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
shll %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %eax, -0x7c(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %edx, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
addl -0x7c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c24
leaq 0x5ae2(%rip), %rsi      # 0x95a5
leaq -0x38(%rbp), %rdi
callq 0x61f0
movb %al, -0xce(%rbp)
jmp 0x3ad4
movb -0xce(%rbp), %al
testb $0x1, %al
jne 0x3ae3
jmp 0x3b74
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
shll %ecx
imull -0x18(%rbp), %ecx
movl -0x10(%rbp), %edx
shll %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movl -0x10(%rbp), %edx
imull -0x14(%rbp), %edx
addl %edx, %ecx
subl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %eax, -0x84(%rbp)
movl -0x48(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %edx, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
addl -0x84(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movl -0x14(%rbp), %edx
addl $0x1, %edx
imull %edx, %ecx
imull -0x18(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
addl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3c22
movb $0x1, -0xa9(%rbp)
movl $0x10, %edi
callq 0x20d0
movq %rax, -0xd8(%rbp)
leaq 0x5a31(%rip), %rsi      # 0x95c4
leaq -0xa8(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x6220
jmp 0x3ba5
movq -0xd8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x22b0
jmp 0x3bba
movq -0xd8(%rbp), %rdi
movb $0x0, -0xa9(%rbp)
movq 0x9409(%rip), %rsi      # 0xcfd8
movq 0x93e2(%rip), %rdx      # 0xcfb8
callq 0x2340
jmp 0x3cea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3c06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2100
testb $0x1, -0xa9(%rbp)
jne 0x3c11
jmp 0x3c1d
movq -0xd8(%rbp), %rdi
callq 0x2140
jmp 0x3cd8
jmp 0x3c24
jmp 0x3c26
jmp 0x3c28
jmp 0x3c2a
jmp 0x3c2c
movq -0xc0(%rbp), %rdi
movb $0x0, -0xaa(%rbp)
callq 0x5e30
movq -0xc0(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x6110
jmp 0x3c51
movq -0xc0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x6110
jmp 0x3c63
movq -0xc0(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x6110
jmp 0x3c75
movq -0xc0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6110
jmp 0x3c87
movb $0x1, -0xaa(%rbp)
testb $0x1, -0xaa(%rbp)
jne 0x3cbf
jmp 0x3cb3
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x6050
jmp 0x3cd8
movq -0xc0(%rbp), %rdi
callq 0x6050
leaq -0x38(%rbp), %rdi
callq 0x2100
movq -0xb8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x2100
movq -0x40(%rbp), %rdi
callq 0x2370
nopw (%rax,%rax)