#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 *, ...);
void declArray(FILE *fs, FILE *fh, char *type, char *name, int size, int align,
               int global) {
  fprintf(fs, "    .align  %d\n", (align < 2) ? 2 : align);
  if (global)
    fprintf(fs, "    .global %s\n", name);
  fprintf(fs, "%s:\n", name);
  if (global)
    fprintf(fh, "extern const %s %s[%d];\n", type, name, size);
}


x86 assembly (clang, -O0):
<declArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x2,-0x28(%rbp)
jge    1152 <declArray+0x42>
mov    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    1158 <declArray+0x48>
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,0x10(%rbp)
je     118d <declArray+0x7d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,0x10(%rbp)
je     11cb <declArray+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<declArray>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbp
cmp    $0x3,%r9d
mov    $0x2,%edx
cmovge %r9d,%edx
lea    0xec5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
cmpl   $0x0,0x30(%rsp)
je     1193 <declArray+0x83>
lea    0xec0(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xebc(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xead(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>
lea    0xe86(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c" .align %d\0A\00"
@.str.1 = [16 x i8] c" .global %s\0A\00"
@.str.2 = [5 x i8] c"%s:\0A\00"
@.str.3 = [25 x i8] c"extern const %s %s[%d];\0A\00"
define void @declArray(i32* %0, i32* %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %8
store i32* %1, i32** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%15 = load i32*, i32** %8
%16 = load i32, i32* %13
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %7
br label %21
19: ; preds = %7
%20 = load i32, i32* %13
br label %21
21: ; preds = %19, %18
%22 = phi i32 [ 2, %18 ], [ %20, %19 ]
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %14
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i32*, i32** %8
%28 = load i8*, i8** %11
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %26, %21
%31 = load i32*, i32** %8
%32 = load i8*, i8** %11
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* %14
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %30
%37 = load i32*, i32** %9
%38 = load i8*, i8** %10
%39 = load i8*, i8** %11
%40 = load i32, i32* %12
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %39, i32 %40)
br label %42
42: ; preds = %36, %30
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c" .align %d\0A\00"
@.str.1 = [16 x i8] c" .global %s\0A\00"
@.str.2 = [5 x i8] c"%s:\0A\00"
@.str.3 = [25 x i8] c"extern const %s %s[%d];\0A\00"
define void @declArray(i32* nocapture %0, i32* nocapture %1, i8* %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = icmp sgt i32 %5, 2
%9 = select i1 %8, i32 %5, i32 2
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i32 %6, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %3, i32 %4)
br label %18
16: ; preds = %7
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %18
18: ; preds = %16, %12
ret void
}