#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, char *, ...);
void gen_mask_alloc(FILE *fp, int ndims, char *tmp) {
  if (ndims == 1) {
    fprintf(fp, "  ALLOCATE(mask%d(SIZE(%s,1)))\n  mask%d = .TRUE.\n", ndims,
            tmp, ndims);
  } else if (ndims == 2) {
    fprintf(fp,
            "  ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2)))\n  mask%d = .TRUE.\n",
            ndims, tmp, tmp, ndims);
  } else if (ndims == 3) {
    fprintf(fp,
            "  ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3)))\n  mask%d = "
            ".TRUE.\n",
            ndims, tmp, tmp, tmp, ndims);
  } else if (ndims == 4) {
    fprintf(fp,
            "  ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3),SIZE(%s,4)))\n "
            " mask%d = .TRUE.\n",
            ndims, tmp, tmp, tmp, tmp, ndims);
  } else if (ndims == 5) {
    fprintf(fp,
            "  "
            "ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3),SIZE(%s,4),SIZE(%"
            "s,5)))\n  mask%d = .TRUE.\n",
            ndims, tmp, tmp, tmp, tmp, tmp, ndims);
  }
}


x86 assembly (clang, -O0):
<gen_mask_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    114f <gen_mask_alloc+0x3f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%r8d
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    124b <gen_mask_alloc+0x13b>
cmpl   $0x2,-0xc(%rbp)
jne    117f <gen_mask_alloc+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0xc(%rbp),%r9d
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1246 <gen_mask_alloc+0x136>
cmpl   $0x3,-0xc(%rbp)
jne    11b5 <gen_mask_alloc+0xa5>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0xc(%rbp),%eax
lea    0xec9(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1241 <gen_mask_alloc+0x131>
cmpl   $0x4,-0xc(%rbp)
jne    11f4 <gen_mask_alloc+0xe4>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x18(%rbp),%r10
mov    -0xc(%rbp),%eax
lea    0xed7(%rip),%rsi
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    123c <gen_mask_alloc+0x12c>
cmpl   $0x5,-0xc(%rbp)
jne    1237 <gen_mask_alloc+0x127>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x18(%rbp),%r11
mov    -0x18(%rbp),%r10
mov    -0xc(%rbp),%eax
lea    0xee7(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    123c <gen_mask_alloc+0x12c>
jmp    1241 <gen_mask_alloc+0x131>
jmp    1246 <gen_mask_alloc+0x136>
jmp    124b <gen_mask_alloc+0x13b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_mask_alloc>:
push   %rax
add    $0xffffffff,%esi
cmp    $0x4,%esi
ja     11cc <gen_mask_alloc+0xbc>
mov    %rdx,%rcx
lea    0xed9(%rip),%rax
movslq (%rax,%rsi,4),%rdx
add    %rax,%rdx
jmp    *%rdx
lea    0xedd(%rip),%rsi
mov    $0x1,%edx
mov    $0x1,%r8d
xor    %eax,%eax
pop    %r9
jmp    1030 <fprintf@plt>
lea    0xef4(%rip),%rsi
mov    $0x2,%edx
mov    %rcx,%r8
mov    $0x2,%r9d
xor    %eax,%eax
pop    %r11
jmp    1030 <fprintf@plt>
sub    $0x8,%rsp
lea    0xf0f(%rip),%rsi
mov    $0x3,%edx
mov    %rcx,%r8
mov    %rcx,%r9
xor    %eax,%eax
push   $0x3
jmp    119c <gen_mask_alloc+0x8c>
lea    0xf3f(%rip),%rsi
mov    $0x4,%edx
mov    %rcx,%r8
mov    %rcx,%r9
xor    %eax,%eax
push   $0x4
push   %rcx
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rax
ret
sub    $0x8,%rsp
lea    0xf6c(%rip),%rsi
mov    $0x5,%edx
mov    %rcx,%r8
mov    %rcx,%r9
xor    %eax,%eax
push   $0x5
push   %rcx
push   %rcx
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rax
ret

LLVM IR (-O0):
@.str = [50 x i8] c" ALLOCATE(mask%d(SIZE(%s,1)))\0A mask%d = .TRUE.\0A\00"
@.str.1 = [61 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2)))\0A mask%d = .TRUE.\0A\00"
@.str.2 = [72 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3)))\0A mask%d = .TRUE.\0A\00"
@.str.3 = [83 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3),SIZE(%s,4)))\0A mask%d = .TRUE.\0A\00"
@.str.4 = [94 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3),SIZE(%s,4),SIZE(%s,5)))\0A mask%d = .TRUE.\0A\00"
define void @gen_mask_alloc(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %3
%10 = load i32*, i32** %4
%11 = load i32, i32* %5
%12 = load i8*, i8** %6
%13 = load i32, i32* %5
%14 = call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %12, i32 %13)
br label %65
15: ; preds = %3
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = load i8*, i8** %6
%22 = load i8*, i8** %6
%23 = load i32, i32* %5
%24 = call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %21, i8* %22, i32 %23)
br label %64
25: ; preds = %15
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i32*, i32** %4
%30 = load i32, i32* %5
%31 = load i8*, i8** %6
%32 = load i8*, i8** %6
%33 = load i8*, i8** %6
%34 = load i32, i32* %5
%35 = call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i32 %30, i8* %31, i8* %32, i8* %33, i32 %34)
br label %63
36: ; preds = %25
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 4
br i1 %38, label %39, label %48
39: ; preds = %36
%40 = load i32*, i32** %4
%41 = load i32, i32* %5
%42 = load i8*, i8** %6
%43 = load i8*, i8** %6
%44 = load i8*, i8** %6
%45 = load i8*, i8** %6
%46 = load i32, i32* %5
%47 = call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0), i32 %41, i8* %42, i8* %43, i8* %44, i8* %45, i32 %46)
br label %62
48: ; preds = %36
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, 5
br i1 %50, label %51, label %61
51: ; preds = %48
%52 = load i32*, i32** %4
%53 = load i32, i32* %5
%54 = load i8*, i8** %6
%55 = load i8*, i8** %6
%56 = load i8*, i8** %6
%57 = load i8*, i8** %6
%58 = load i8*, i8** %6
%59 = load i32, i32* %5
%60 = call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0), i32 %53, i8* %54, i8* %55, i8* %56, i8* %57, i8* %58, i32 %59)
br label %61
61: ; preds = %51, %48
br label %62
62: ; preds = %61, %39
br label %63
63: ; preds = %62, %28
br label %64
64: ; preds = %63, %18
br label %65
65: ; preds = %64, %9
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c" ALLOCATE(mask%d(SIZE(%s,1)))\0A mask%d = .TRUE.\0A\00"
@.str.1 = [61 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2)))\0A mask%d = .TRUE.\0A\00"
@.str.2 = [72 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3)))\0A mask%d = .TRUE.\0A\00"
@.str.3 = [83 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3),SIZE(%s,4)))\0A mask%d = .TRUE.\0A\00"
@.str.4 = [94 x i8] c" ALLOCATE(mask%d(SIZE(%s,1),SIZE(%s,2),SIZE(%s,3),SIZE(%s,4),SIZE(%s,5)))\0A mask%d = .TRUE.\0A\00"
define void @gen_mask_alloc(i32* nocapture %0, i32 %1, i8* %2) {
switch i32 %1, label %14 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
]
4: ; preds = %3
%5 = tail call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 1, i8* %2, i32 1)
br label %14
6: ; preds = %3
%7 = tail call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* %2, i8* %2, i32 2)
br label %14
8: ; preds = %3
%9 = tail call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i32 3, i8* %2, i8* %2, i8* %2, i32 3)
br label %14
10: ; preds = %3
%11 = tail call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0), i32 4, i8* %2, i8* %2, i8* %2, i8* %2, i32 4)
br label %14
12: ; preds = %3
%13 = tail call i32 (i32*, i8*, i32, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.4, i64 0, i64 0), i32 5, i8* %2, i8* %2, i8* %2, i8* %2, i8* %2, i32 5)
br label %14
14: ; preds = %3, %6, %10, %12, %8, %4
ret void
}