#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char *words[100], *p;
  int i = 0;
  while (strcmp(p, "end") != 0) {
    printf("[%d]:", i);
    p = malloc(100);
    scanf("%s", p);
    words[i] = malloc(strlen(p) + 3);
    strcpy(words[i], "a");
    strcat(words[i], p);
    words[i][0] = words[i][strlen(words[i]) - 1];
    words[i][strlen(words[i]) - 1] = 0;
    i++;
  }
  i = 0;
  while (strcmp(words[i], "den") != 0) {
    printf("[%d]:%s\n", i, words[i]);
    i++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x33c(%rbp)
mov    -0x338(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12dd <main+0x16d>
mov    -0x33c(%rbp),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x338(%rbp)
mov    -0x338(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x338(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
movslq -0x33c(%rbp),%rax
mov    %rcx,-0x330(%rbp,%rax,8)
ff
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rdi
ff
lea    0xdee(%rip),%rsi
call   1030 <strcpy@plt>
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rdi
ff
mov    -0x338(%rbp),%rsi
call   1090 <strcat@plt>
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rax
ff
mov    %rax,-0x350(%rbp)
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rdi
ff
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x350(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rax
ff
mov    %cl,(%rax)
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rax
ff
mov    %rax,-0x348(%rbp)
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rdi
ff
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x348(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x33c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x33c(%rbp)
jmp    118c <main+0x1c>
movl   $0x0,-0x33c(%rbp)
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rdi
ff
lea    0xd12(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1343 <main+0x1d3>
mov    -0x33c(%rbp),%esi
movslq -0x33c(%rbp),%rax
mov    -0x330(%rbp,%rax,8),%rdx
ff
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x33c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x33c(%rbp)
jmp    12e7 <main+0x177>
mov    -0x4(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
@.str = [4 x i8] c"end\00"
@.str.1 = [6 x i8] c"[%d]:\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [4 x i8] c"den\00"
@.str.5 = [9 x i8] c"[%d]:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8*]
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %9, %0
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %65
9: ; preds = %5
%10 = load i32, i32* %4
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i8* @malloc(i32 100)
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 3
%18 = call i8* @malloc(i32 %17)
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %20
store i8* %18, i8** %21
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = load i8*, i8** %3
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %34
%36 = load i8*, i8** %35
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @strlen(i8* %40)
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %36, i64 %43
%45 = load i8, i8* %44
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %47
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 0
store i8 %45, i8* %50
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %52
%54 = load i8*, i8** %53
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @strlen(i8* %58)
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %54, i64 %61
store i8 0, i8* %62
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
br label %5
65: ; preds = %5
store i32 0, i32* %4
br label %66
66: ; preds = %73, %65
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %68
%70 = load i8*, i8** %69
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %82
73: ; preds = %66
%74 = load i32, i32* %4
%75 = load i32, i32* %4
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %74, i8* %78)
%80 = load i32, i32* %4
%81 = add nsw i32 %80, 1
store i32 %81, i32* %4
br label %66
82: ; preds = %66
%83 = load i32, i32* %1
ret i32 %83
}

LLVM IR (-O2):