#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*/ name;
typedef int /*<<< orphan*/ def;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ args;

/* Variables and functions */
int atoi(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
char *strdup(char *);
int strlen(char *);
int main() {
  char name[512];
  char num[512];
  char def[512];
  char args[512];
  char buf[512];
  char *defines[512];
  int i = 0;
  printf("/* this file is auto generated, edit textevents.in instead! "
         "*/\n\nconst struct text_event te[] = {\n");
  while (fgets(name, sizeof(name), stdin)) {
    name[strlen(name) - 1] = 0;
    fgets(def, sizeof(def), stdin);
    def[strlen(def) - 1] = 0;
    fgets(args, sizeof(args), stdin);
    args[strlen(args) - 1] = 0;
    fgets(buf, sizeof(buf), stdin);
    printf("\n{\"%s\", %d, \n\"%s\"},\n", name, atoi(args), def);
    defines[i] = strdup(num);
    i++;
  }
  printf("\n{NULL} /* sentinel */\n");
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a14(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     12a1 <main+0x151>
lea    -0x210(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x210(%rbp,%rax,1)
lea    -0x610(%rbp),%rdi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    -0x610(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x610(%rbp,%rax,1)
lea    -0x810(%rbp),%rdi
mov    0x2df0(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    -0x810(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x810(%rbp,%rax,1)
lea    -0xa10(%rbp),%rdi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    -0x210(%rbp),%rax
mov    %rax,-0x1a20(%rbp)
lea    -0x810(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x1a20(%rbp),%rsi
mov    %eax,%edx
lea    -0x610(%rbp),%rcx
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
movslq -0x1a14(%rbp),%rax
mov    %rcx,-0x1a10(%rbp,%rax,8)
ff
mov    -0x1a14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a14(%rbp)
jmp    117a <main+0x2a>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e74(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x600(%rsp),%r14
mov    %r14,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1242 <main+0xf2>
lea    0x400(%rsp),%r15
lea    0x200(%rsp),%rbx
mov    %rsp,%r12
lea    0xe51(%rip),%r13
nop
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%edx
mov    %r14,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    11b0 <main+0x60>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [98 x i8] c"/* this file is auto generated, edit textevents.in instead! */\0A\0Aconst struct text_event te[] = {\0A\00"
@stdin = global i32 0
@.str.1 = [21 x i8] c"\0A{\22%s\22, %d, \0A\22%s\22},\0A\00"
@.str.2 = [24 x i8] c"\0A{NULL} /* sentinel */\0A\00"
@.str.3 = [4 x i8] c"};\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [512 x i8*]
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %15, %0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i64 @fgets(i8* %11, i32 512, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %52
15: ; preds = %10
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%22 = load i32, i32* @stdin
%23 = call i64 @fgets(i8* %21, i32 512, i32 %22)
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %27
store i8 0, i8* %28
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%30 = load i32, i32* @stdin
%31 = call i64 @fgets(i8* %29, i32 512, i32 %30)
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %35
store i8 0, i8* %36
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%38 = load i32, i32* @stdin
%39 = call i64 @fgets(i8* %37, i32 512, i32 %38)
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%42 = call i32 @atoi(i8* %41)
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %40, i32 %42, i8* %43)
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%46 = call i8* @strdup(i8* %45)
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [512 x i8*], [512 x i8*]* %7, i64 0, i64 %48
store i8* %46, i8** %49
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %10
52: ; preds = %10
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [21 x i8] c"\0A{\22%s\22, %d, \0A\22%s\22},\0A\00"
@str = [97 x i8] c"/* this file is auto generated, edit textevents.in instead! */\0A\0Aconst struct text_event te[] = {\00"
@str.4 = [23 x i8] c"\0A{NULL} /* sentinel */\00"
@str.5 = [3 x i8] c"};\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i64 @fgets(i8* %5, i32 512, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %37, label %13
13: ; preds = %0, %13
%14 = call i32 @strlen(i8* %5)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 %16
store i8 0, i8* %17
%18 = load i32, i32* @stdin
%19 = call i64 @fgets(i8* %6, i32 512, i32 %18)
%20 = call i32 @strlen(i8* %6)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
%24 = load i32, i32* @stdin
%25 = call i64 @fgets(i8* %7, i32 512, i32 %24)
%26 = call i32 @strlen(i8* %7)
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = load i32, i32* @stdin
%31 = call i64 @fgets(i8* %8, i32 512, i32 %30)
%32 = call i32 @atoi(i8* %7)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %32, i8* %6)
%34 = load i32, i32* @stdin
%35 = call i64 @fgets(i8* %5, i32 512, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %13
37: ; preds = %13, %0
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}