#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  FILE *c_file, *h_file;
  char line[512];
  int count = 0;
  c_file = fopen("opcodes.c", "w");
  h_file = fopen("opcodes.h", "w");
  if (c_file == NULL || h_file == NULL) {
    fprintf(stderr, "unable to open output file(s)\n");
    exit(1);
  }
  fprintf(c_file, "/* Automatically generated file. Do not edit */\n");
  fprintf(c_file, "char *sqliteOpcodeNames[] = { \"???\",\n");
  fprintf(h_file, "/* Automatically generated file. Do not edit */\n");
  while (fgets(line, sizeof(line), stdin) != NULL) {
    if (strncmp(line, "case OP_", 7) == 0) {
      char *p, *q;
      p = line + 8;
      q = strchr(p, ':');
      if (q == NULL) {
        continue;
      }
      *q = '\0';
      fprintf(c_file, "  \"%s\",\n", p);
      fprintf(h_file, "#define %-30s %3d\n", p - 3, ++count);
    }
  }
  fprintf(c_file, "};\n");
  fclose(h_file);
  fclose(c_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x224(%rbp)
lea    0xe66(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe5b(%rip),%rdi
lea    0xe52(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d7 <main+0x67>
cmpq   $0x0,-0x20(%rbp)
jne    11f9 <main+0x89>
mov    0x2dfa(%rip),%rax
mov    (%rax),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x220(%rbp),%rdi
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1306 <main+0x196>
lea    -0x220(%rbp),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1301 <main+0x191>
lea    -0x220(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
jne    12b2 <main+0x142>
jmp    122f <main+0xbf>
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x230(%rbp),%rdx
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x230(%rbp),%rdx
add    $0xfffffffffffffffd,%rdx
mov    -0x224(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
lea    0xda4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    122f <main+0xbf>
mov    -0x18(%rbp),%rdi
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
lea    0xe68(%rip),%rdi
lea    0xe6b(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
test   %r15,%r15
je     12f3 <main+0x173>
mov    %rax,%rbp
test   %rax,%rax
je     12f3 <main+0x173>
lea    0xe60(%rip),%rbx
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r15,%rcx
call   10a0 <fwrite@plt>
lea    0xe75(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %rbp,0x8(%rsp)
mov    %rbp,%rcx
call   10a0 <fwrite@plt>
lea    0x18(%rsp),%r13
mov    0x2dbf(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe57(%rip),%rbp
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12b4 <main+0x134>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1240 <main+0xc0>
mov    %r13,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1240 <main+0xc0>
movb   $0x0,(%rax)
mov    %r15,%rdi
lea    0xe0c(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r12d
mov    0x8(%rsp),%rdi
lea    0xdfb(%rip),%rsi
lea    0x15(%rsp),%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1240 <main+0xc0>
lea    0xdf6(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cde(%rip),%rax
mov    (%rax),%rcx
lea    0xd12(%rip),%rdi
mov    $0x1e,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"opcodes.c\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"opcodes.h\00"
@stderr = global i32* null
@.str.3 = [31 x i8] c"unable to open output file(s)\0A\00"
@.str.4 = [49 x i8] c"/* Automatically generated file. Do not edit */\0A\00"
@.str.5 = [38 x i8] c"char *sqliteOpcodeNames[] = { \22???\22,\0A\00"
@stdin = global i32 0
@.str.6 = [9 x i8] c"case OP_\00"
@.str.7 = [9 x i8] c" \22%s\22,\0A\00"
@.str.8 = [19 x i8] c"#define %-30s %3d\0A\00"
@.str.9 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [512 x i8]
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%12 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %6
%13 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %7
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %16, %2
%20 = load i32*, i32** @stderr
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = load i32*, i32** %6
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32*, i32** %6
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32*, i32** %7
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %58, %46, %23
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%32 = load i32, i32* @stdin
%33 = call i32* @fgets(i8* %31, i32 512, i32 %32)
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %59
35: ; preds = %30
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%37 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 7)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %58
39: ; preds = %35
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%41 = getelementptr inbounds i8, i8* %40, i64 8
store i8* %41, i8** %10
%42 = load i8*, i8** %10
%43 = call i8* @strchr(i8* %42, i8 signext 58)
store i8* %43, i8** %11
%44 = load i8*, i8** %11
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %47
46: ; preds = %39
br label %30
47: ; preds = %39
%48 = load i8*, i8** %11
store i8 0, i8* %48
%49 = load i32*, i32** %6
%50 = load i8*, i8** %10
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %50)
%52 = load i32*, i32** %7
%53 = load i8*, i8** %10
%54 = getelementptr inbounds i8, i8* %53, i64 -3
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %54, i32 %56)
br label %58
58: ; preds = %47, %35
br label %30
59: ; preds = %30
%60 = load i32*, i32** %6
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%62 = load i32*, i32** %7
%63 = call i32 @fclose(i32* %62)
%64 = load i32*, i32** %6
%65 = call i32 @fclose(i32* %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"opcodes.c\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"opcodes.h\00"
@stderr = global i32* null
@.str.3 = [31 x i8] c"unable to open output file(s)\0A\00"
@.str.4 = [49 x i8] c"/* Automatically generated file. Do not edit */\0A\00"
@.str.5 = [38 x i8] c"char *sqliteOpcodeNames[] = { \22???\22,\0A\00"
@stdin = global i32 0
@.str.6 = [9 x i8] c"case OP_\00"
@.str.7 = [9 x i8] c" \22%s\22,\0A\00"
@.str.8 = [19 x i8] c"#define %-30s %3d\0A\00"
@.str.9 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %5, null
%8 = icmp eq i32* %6, null
%9 = or i1 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32*, i32** @stderr
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i64 30, i64 1, i32* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i64 48, i64 1, i32* %5)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i64 37, i64 1, i32* %5)
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i64 48, i64 1, i32* %6)
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 8
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 5
br label %20
20: ; preds = %33, %14
%21 = phi i32 [ %35, %33 ], [ 0, %14 ]
br label %22
22: ; preds = %27, %20
br label %23
23: ; preds = %22, %30
%24 = load i32, i32* @stdin
%25 = call i32* @fgets(i8* %4, i32 512, i32 %24)
%26 = icmp eq i32* %25, null
br i1 %26, label %37, label %27
27: ; preds = %23
%28 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 7)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %22
30: ; preds = %27
%31 = call i8* @strchr(i8* %18, i8 signext 58)
%32 = icmp eq i8* %31, null
br i1 %32, label %23, label %33
33: ; preds = %30
store i8 0, i8* %31
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %18)
%35 = add nuw nsw i32 %21, 1
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %19, i32 %35)
br label %20
37: ; preds = %23
%38 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64 3, i64 1, i32* %5)
%39 = call i32 @fclose(i32* %6)
%40 = call i32 @fclose(i32* %5)
ret i32 0
}