#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 */
size_t atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  size_t max_size = 255, i;
  if (argc == 2)
    max_size = atoi(argv[1]);
  printf("#define _MAGIC_ARRAY_NARGS(...) _MAGIC_ARRAY_NARGS_(,##__VA_ARGS__");
  for (i = max_size + 1; i > 0; --i)
    printf(",%lli", (long long)i);
  printf(")\n#define _MAGIC_ARRAY_NARGS_(");
  for (i = 0; i <= max_size; ++i)
    printf("_%lli,", (long long)i);
  printf("cnt,...) cnt\n#define MAGIC_ARRAY(...) "
         "{_MAGIC_ARRAY_NARGS(__VA_ARGS__),##__VA_ARGS__}\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xff,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1159 <main+0x39>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %rax,-0x18(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    11a1 <main+0x81>
mov    -0x20(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1173 <main+0x53>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     11e8 <main+0xc8>
mov    -0x20(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11b7 <main+0x97>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    1165 <main+0x35>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %rax,%r14
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rbx
mov    $0xffffffffffffffff,%r15
inc    %rbx
jne    117e <main+0x4e>
jmp    11a6 <main+0x76>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xff,%r14d
mov    $0x100,%ebx
lea    0xebe(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
jne    1190 <main+0x60>
mov    %r14,%r15
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
jbe    11c0 <main+0x90>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [67 x i8] c"#define _MAGIC_ARRAY_NARGS(...) _MAGIC_ARRAY_NARGS_(,##__VA_ARGS__\00"
@.str.1 = [6 x i8] c",%lli\00"
@.str.2 = [31 x i8] c")\0A#define _MAGIC_ARRAY_NARGS_(\00"
@.str.3 = [7 x i8] c"_%lli,\00"
@.str.4 = [87 x i8] c"cnt,...) cnt\0A#define MAGIC_ARRAY(...) {_MAGIC_ARRAY_NARGS(__VA_ARGS__),##__VA_ARGS__}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 255, i64* %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @atoi(i8* %13)
store i64 %14, i64* %6
br label %15
15: ; preds = %10, %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%17 = load i64, i64* %6
%18 = add i64 %17, 1
store i64 %18, i64* %7
br label %19
19: ; preds = %25, %15
%20 = load i64, i64* %7
%21 = icmp ugt i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i64, i64* %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %22
%26 = load i64, i64* %7
%27 = add i64 %26, -1
store i64 %27, i64* %7
br label %19
28: ; preds = %19
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %7
br label %30
30: ; preds = %37, %28
%31 = load i64, i64* %7
%32 = load i64, i64* %6
%33 = icmp ule i64 %31, %32
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i64, i64* %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %35)
br label %37
37: ; preds = %34
%38 = load i64, i64* %7
%39 = add i64 %38, 1
store i64 %39, i64* %7
br label %30
40: ; preds = %30
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [67 x i8] c"#define _MAGIC_ARRAY_NARGS(...) _MAGIC_ARRAY_NARGS_(,##__VA_ARGS__\00"
@.str.1 = [6 x i8] c",%lli\00"
@.str.2 = [31 x i8] c")\0A#define _MAGIC_ARRAY_NARGS_(\00"
@.str.3 = [7 x i8] c"_%lli,\00"
@str = [86 x i8] c"cnt,...) cnt\0A#define MAGIC_ARRAY(...) {_MAGIC_ARRAY_NARGS(__VA_ARGS__),##__VA_ARGS__}\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
br label %13
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @atoi(i8* %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%11 = add i64 %9, 1
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %4, %6
%14 = phi i64 [ 256, %4 ], [ %11, %6 ]
%15 = phi i64 [ 255, %4 ], [ %9, %6 ]
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ %19, %16 ], [ %14, %13 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%19 = add i64 %17, -1
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %16
21: ; preds = %16, %6
%22 = phi i64 [ -1, %6 ], [ %15, %16 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ 0, %21 ], [ %27, %24 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %25)
%27 = add i64 %25, 1
%28 = icmp ugt i64 %27, %22
br i1 %28, label %29, label %24
29: ; preds = %24
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str, i64 0, i64 0))
ret i32 0
}