#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
unsigned long hash_f(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strip(char *);
size_t strlen(char *);
int /*<<< orphan*/ strupper(char *);
int main(int argc, char *argv[]) {
  char buf[256 + 1];
  FILE *file;
  FILE *header;
  size_t len;
  unsigned long hash;
  file = fopen("defs.dat", "r");
  if (!file) {
    perror("defs.dat");
    exit(EXIT_FAILURE);
  }
  header = fopen("src/constants.h", "w");
  if (!header) {
    perror("src/constants.h");
    exit(EXIT_FAILURE);
  }
  fputs("/*\n * NOTE: PLEASE do no edit; autogenerated.\n"
        " * check +generate_header.c+ for more info.\n"
        " */\n\n",
        header);
  fprintf(header, "#ifndef _%s_H_\n#define _%s_H_\n\n", "CONSTANTS",
          "CONSTANTS");
  while (!feof(file)) {
    fgets(&buf[0], 256, file);
    strip(buf);
    if (buf[0] == '#')
      continue;
    len = strlen(buf);
    if (!len)
      continue;
    hash = hash_f(buf);
    strupper(buf);
    fprintf(header, "#define %s%s %lu\n", "I_", buf, hash);
  }
  fprintf(header, "\n#endif\n");
  fclose(file);
  fclose(header);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe20(%rip),%rdi
lea    0xe22(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    121b <main+0x5b>
lea    0xdf8(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xde9(%rip),%rdi
lea    0xdf2(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    125d <main+0x9d>
lea    0xdc1(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x130(%rbp),%rsi
lea    0xdb2(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x130(%rbp),%rdi
lea    0xdff(%rip),%rsi
lea    0xe18(%rip),%rcx
mov    %rcx,%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x128(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b0 <main+0xf0>
jmp    135d <main+0x19d>
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
lea    -0x120(%rbp),%rdi
call   1060 <strip@plt>
movsbl -0x120(%rbp),%eax
cmp    $0x23,%eax
jne    12e9 <main+0x129>
jmp    128f <main+0xcf>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jne    130f <main+0x14f>
jmp    128f <main+0xcf>
lea    -0x120(%rbp),%rdi
call   10e0 <hash_f@plt>
mov    %rax,-0x140(%rbp)
lea    -0x120(%rbp),%rdi
call   10a0 <strupper@plt>
mov    -0x130(%rbp),%rdi
lea    -0x120(%rbp),%rcx
mov    -0x140(%rbp),%r8
lea    0xd5d(%rip),%rsi
lea    0xd68(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    128f <main+0xcf>
mov    -0x130(%rbp),%rdi
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c47(%rip),%rax
mov    (%rax),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe38(%rip),%rdi
lea    0xe3a(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12fb <main+0x14b>
mov    %rax,%r15
lea    0xe24(%rip),%rdi
lea    0xe2d(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1304 <main+0x154>
mov    %rax,%r14
lea    0xe17(%rip),%rdi
mov    $0x5f,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
lea    0xe5e(%rip),%rsi
lea    0xe77(%rip),%rcx
mov    %r14,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1283 <main+0xd3>
lea    0xe76(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10c0 <fwrite@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
lea    0xe1a(%rip),%r12
lea    0xe25(%rip),%r13
jmp    12ac <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    123f <main+0x8f>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strip@plt>
movzbl (%rsp),%eax
test   %al,%al
je     12a0 <main+0xf0>
cmp    $0x23,%al
je     12a0 <main+0xf0>
mov    %rbx,%rdi
call   10d0 <hash_f@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1080 <strupper@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    12a0 <main+0xf0>
lea    0xcfe(%rip),%rdi
jmp    130b <main+0x15b>
lea    0xd00(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"defs.dat\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [16 x i8] c"src/constants.h\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [96 x i8] c"/*\0A * NOTE: PLEASE do no edit; autogenerated.\0A * check +generate_header.c+ for more info.\0A */\0A\0A\00"
@.str.5 = [32 x i8] c"#ifndef _%s_H_\0A#define _%s_H_\0A\0A\00"
@.str.6 = [10 x i8] c"CONSTANTS\00"
@.str.7 = [18 x i8] c"#define %s%s %lu\0A\00"
@.str.8 = [3 x i8] c"I_\00"
@.str.9 = [9 x i8] c"\0A#endif\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [257 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %8
%20 = load i32*, i32** %8
%21 = icmp ne i32* %20, null
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %18
%27 = load i32*, i32** %8
%28 = call i32 @fputs(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0), i32* %27)
%29 = load i32*, i32** %8
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %53, %52, %46, %26
%32 = load i32*, i32** %7
%33 = call i32 @feof(i32* %32)
%34 = icmp ne i32 %33, 0
%35 = xor i1 %34, true
br i1 %35, label %36, label %62
36: ; preds = %31
%37 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%38 = load i32*, i32** %7
%39 = call i32 @fgets(i8* %37, i32 256, i32* %38)
%40 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%41 = call i32 @strip(i8* %40)
%42 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 35
br i1 %45, label %46, label %47
46: ; preds = %36
br label %31
47: ; preds = %36
%48 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%49 = call i64 @strlen(i8* %48)
store i64 %49, i64* %9
%50 = load i64, i64* %9
%51 = icmp ne i64 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %47
br label %31
53: ; preds = %47
%54 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%55 = call i64 @hash_f(i8* %54)
store i64 %55, i64* %10
%56 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%57 = call i32 @strupper(i8* %56)
%58 = load i32*, i32** %8
%59 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%60 = load i64, i64* %10
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %59, i64 %60)
br label %31
62: ; preds = %31
%63 = load i32*, i32** %8
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%65 = load i32*, i32** %7
%66 = call i32 @fclose(i32* %65)
%67 = load i32*, i32** %8
%68 = call i32 @fclose(i32* %67)
%69 = load i32, i32* @EXIT_SUCCESS
ret i32 %69
}

LLVM IR (-O2):
@.str = [9 x i8] c"defs.dat\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [16 x i8] c"src/constants.h\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [96 x i8] c"/*\0A * NOTE: PLEASE do no edit; autogenerated.\0A * check +generate_header.c+ for more info.\0A */\0A\0A\00"
@.str.5 = [32 x i8] c"#ifndef _%s_H_\0A#define _%s_H_\0A\0A\00"
@.str.6 = [10 x i8] c"CONSTANTS\00"
@.str.7 = [18 x i8] c"#define %s%s %lu\0A\00"
@.str.8 = [3 x i8] c"I_\00"
@.str.9 = [9 x i8] c"\0A#endif\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [257 x i8]
%4 = getelementptr inbounds [257 x i8], [257 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.4, i64 0, i64 0), i64 95, i64 1, i32* %12)
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @feof(i32* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %18, %31
%24 = call i32 @fgets(i8* %4, i32 256, i32* %5)
%25 = call i32 @strip(i8* %4)
%26 = load i8, i8* %4
switch i8 %26, label %27 [
i8 35, label %31
i8 0, label %31
]
27: ; preds = %23
%28 = call i64 @hash_f(i8* %4)
%29 = call i32 @strupper(i8* %4)
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %4, i64 %28)
br label %31
31: ; preds = %27, %23, %23
%32 = call i32 @feof(i32* %5)
%33 = icmp eq i32 %32, 0
br i1 %33, label %23, label %34
34: ; preds = %31, %18
%35 = call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i64 8, i64 1, i32* %12)
%36 = call i32 @fclose(i32* %5)
%37 = call i32 @fclose(i32* %12)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}