#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 decl(FILE *fs, FILE *fh, char *type, char *name, 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;\n", type, name);
}


x86 assembly (clang, -O0):
<decl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
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,-0x24(%rbp)
jge    114f <decl+0x3f>
mov    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    1155 <decl+0x45>
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x28(%rbp)
je     118a <decl+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x28(%rbp)
je     11c4 <decl+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%ebp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
cmp    $0x3,%r8d
mov    $0x2,%edx
cmovge %r8d,%edx
lea    0xec5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
je     118d <decl+0x7d>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xeaf(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

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

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