#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 */

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char *buffer = malloc(100);
  int cnt = 0;
  puts("/* auto-generated array - do not modify */");
  puts("#include \"actionlist.h\"");
  puts("#include \"control.h\"");
  puts("struct action_struct action_table[]={");
  while (!feof(stdin)) {
    scanf("%s\n", buffer);
    printf("    {\"%s\",%s_action},\n", buffer, buffer);
    cnt++;
  }
  puts("};");
  printf("\nint action_count=%d;\n", cnt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c7 <main+0x77>
jmp    11fb <main+0xab>
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <main+0x54>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    -0x14(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4c(%rip),%r12
mov    (%r12),%edi
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    11eb <main+0x9b>
lea    0xecc(%rip),%r14
lea    0xec9(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    (%r12),%edi
call   1050 <feof@plt>
test   %eax,%eax
je     11c0 <main+0x70>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"/* auto-generated array - do not modify */\00"
@.str.1 = [24 x i8] c"#include \22actionlist.h\22\00"
@.str.2 = [21 x i8] c"#include \22control.h\22\00"
@.str.3 = [38 x i8] c"struct action_struct action_table[]={\00"
@stdin = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [23 x i8] c" {\22%s\22,%s_action},\0A\00"
@.str.6 = [3 x i8] c"};\00"
@.str.7 = [23 x i8] c"\0Aint action_count=%d;\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i8* @malloc(i32 100)
store i8* %4, i8** %2
store i32 0, i32* %3
%5 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %14, %0
%10 = load i32, i32* @stdin
%11 = call i32 @feof(i32 %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %2
%18 = load i8*, i8** %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %9
22: ; preds = %9
%23 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"/* auto-generated array - do not modify */\00"
@.str.1 = [24 x i8] c"#include \22actionlist.h\22\00"
@.str.2 = [21 x i8] c"#include \22control.h\22\00"
@.str.3 = [38 x i8] c"struct action_struct action_table[]={\00"
@stdin = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [23 x i8] c" {\22%s\22,%s_action},\0A\00"
@.str.6 = [3 x i8] c"};\00"
@.str.7 = [23 x i8] c"\0Aint action_count=%d;\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = tail call i32 @feof(i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %0, %9
%10 = phi i32 [ %13, %9 ], [ 0, %0 ]
%11 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %1)
%13 = add nuw nsw i32 %10, 1
%14 = load i32, i32* @stdin
%15 = tail call i32 @feof(i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %9, label %17
17: ; preds = %9, %0
%18 = phi i32 [ 0, %0 ], [ %13, %9 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %18)
ret i32 0
}