#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 atoi(char *);
int /*<<< orphan*/ codegen(int *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void main(int argc, char **argv) {
  if (argc == 2) {
    int ca[1023] = {0};
    int prnNum = atoi(argv[1]);
    fprintf(stderr, "prn Num == %d\r\n", prnNum);
    if ((prnNum < 1) || (prnNum > 32)) {
      printf("prn num error\r\n");
      exit(0);
    }
    codegen(ca, prnNum);
    for (int i = 0; i < 1023; i++)
      printf("%d,", ca[i]);
  } else {
    printf("usage\r\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    124d <main+0xed>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0xffc,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1014(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x1014(%rbp),%edx
lea    0xe48(%rip),%rsi
call   1060 <fprintf@plt>
cmpl   $0x1,-0x1014(%rbp)
jl     11d7 <main+0x77>
cmpl   $0x20,-0x1014(%rbp)
jle    11ec <main+0x8c>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x1014(%rbp),%esi
call   1050 <codegen@plt>
movl   $0x0,-0x1018(%rbp)
cmpl   $0x3ff,-0x1018(%rbp)
jge    1248 <main+0xe8>
movslq -0x1018(%rbp),%rax
mov    -0x1010(%rbp,%rax,4),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1018(%rbp)
jmp    1208 <main+0xa8>
jmp    125b <main+0xfb>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
cmp    $0x2,%edi
jne    11f5 <main+0x85>
mov    %rsi,%rbx
mov    %rsp,%rdi
mov    $0xffc,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    %ebx,%edx
call   1070 <fprintf@plt>
lea    -0x21(%rbx),%eax
cmp    $0xffffffdf,%eax
jbe    120b <main+0x9b>
mov    %rsp,%rdi
mov    %ebx,%esi
call   1060 <codegen@plt>
lea    0xe44(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x3ff,%rbx
jne    11d0 <main+0x60>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe18(%rip),%rdi
add    $0x1008,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"prn Num == %d\0D\0A\00"
@.str.1 = [16 x i8] c"prn num error\0D\0A\00"
@.str.2 = [4 x i8] c"%d,\00"
@.str.3 = [8 x i8] c"usage\0D\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [1023 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %44
10: ; preds = %2
%11 = bitcast [1023 x i32]* %5 to i8*
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* @stderr
%17 = load i32, i32* %6
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 1
br i1 %20, label %24, label %21
21: ; preds = %10
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 32
br i1 %23, label %24, label %27
24: ; preds = %21, %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %21
%28 = getelementptr inbounds [1023 x i32], [1023 x i32]* %5, i64 0, i64 0
%29 = load i32, i32* %6
%30 = call i32 @codegen(i32* %28, i32 %29)
store i32 0, i32* %7
br label %31
31: ; preds = %40, %27
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 1023
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1023 x i32], [1023 x i32]* %5, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %34
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %31
43: ; preds = %31
br label %46
44: ; preds = %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %43
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"prn Num == %d\0D\0A\00"
@.str.2 = [4 x i8] c"%d,\00"
@str = [7 x i8] c"usage\0D\00"
@str.4 = [15 x i8] c"prn num error\0D\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1023 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %28
5: ; preds = %2
%6 = bitcast [1023 x i32]* %3 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = add i32 %9, -33
%13 = icmp ult i32 %12, -32
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %5
%18 = getelementptr inbounds [1023 x i32], [1023 x i32]* %3, i64 0, i64 0
%19 = call i32 @codegen(i32* %18, i32 %9)
br label %21
20: ; preds = %21
br label %30
21: ; preds = %17, %21
%22 = phi i64 [ 0, %17 ], [ %26, %21 ]
%23 = getelementptr inbounds [1023 x i32], [1023 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, 1023
br i1 %27, label %20, label %21
28: ; preds = %2
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %28, %20
ret void
}