#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 */
scalar_t__ EOF;
scalar_t__ fgetc(int /*<<< orphan*/);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ stdin;
char *strdup(char *);
char **x_realloc(char **, int);
char **read_names(int *count) {
  char buffer[100 + 1];
  char **names = NULL;
  int allocated = 0;
  int used = 0;
  while (scanf("\"%100[^\"]\"", buffer) > 0) {
    if (used >= allocated) {
      allocated++;
      allocated *= 2;
      names = x_realloc(names, allocated * sizeof(char *));
    }
    names[used++] = strdup(buffer);
    if (fgetc(stdin) == EOF)
      break;
  }
  *count = used;
  return names;
}


x86 assembly (clang, -O0):
<read_names>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x0,%rax
jle    11fe <read_names+0xbe>
mov    -0x80(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jl     11b4 <read_names+0x74>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x78(%rbp),%rdi
movslq -0x7c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <x_realloc@plt>
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,%rdx
mov    -0x78(%rbp),%rax
mov    -0x80(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x80(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    0x2df5(%rip),%rcx
cmp    (%rcx),%rax
jne    11f9 <read_names+0xb9>
jmp    11fe <read_names+0xbe>
jmp    1165 <read_names+0x25>
mov    -0x80(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x78(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_names>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdi,0x8(%rsp)
xor    %ebx,%ebx
lea    0xea4(%rip),%r15
lea    0x10(%rsp),%r12
mov    0x2e78(%rip),%r14
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    1194 <read_names+0x54>
nop
mov    %r12,%rdi
call   1060 <strdup@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
cmp    (%r14),%rax
je     11c9 <read_names+0x89>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
jle    11c9 <read_names+0x89>
movslq %ebp,%rax
cmp    %rax,%rbx
jl     1170 <read_names+0x30>
mov    %ebp,%eax
add    %eax,%eax
add    %ebp,%ebp
add    $0x2,%ebp
lea    0x10(,%rax,8),%esi
mov    %r13,%rdi
call   1040 <x_realloc@plt>
mov    %rax,%r13
jmp    1170 <read_names+0x30>
mov    0x8(%rsp),%rax
mov    %ebx,(%rax)
mov    %r13,%rax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\22%100[^\22]\22\00"
@stdin = global i32 0
@EOF = global i64 0
define i8** @read_names(i32* %0) {
%2 = alloca i32*
%3 = alloca [101 x i8]
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
store i8** null, i8*** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %39, %1
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%9 = call i64 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %40
11: ; preds = %7
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 2
store i32 %19, i32* %5
%20 = load i8**, i8*** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 8
%24 = trunc i64 %23 to i32
%25 = call i8** @x_realloc(i8** %20, i32 %24)
store i8** %25, i8*** %4
br label %26
26: ; preds = %15, %11
%27 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%28 = call i8* @strdup(i8* %27)
%29 = load i8**, i8*** %4
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8*, i8** %29, i64 %32
store i8* %28, i8** %33
%34 = load i32, i32* @stdin
%35 = call i64 @fgetc(i32 %34)
%36 = load i64, i64* @EOF
%37 = icmp eq i64 %35, %36
br i1 %37, label %38, label %39
38: ; preds = %26
br label %40
39: ; preds = %26
br label %7
40: ; preds = %38, %7
%41 = load i32, i32* %6
%42 = load i32*, i32** %2
store i32 %41, i32* %42
%43 = load i8**, i8*** %4
ret i8** %43
}

LLVM IR (-O2):
@.str = [11 x i8] c"\22%100[^\22]\22\00"
@stdin = global i32 0
@EOF = global i64 0
define i8** @read_names(i32* nocapture writeonly %0) {
%2 = alloca [101 x i8]
%3 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %18, %1
%5 = phi i64 [ %22, %18 ], [ 0, %1 ]
%6 = phi i8** [ %19, %18 ], [ null, %1 ]
%7 = phi i32 [ %20, %18 ], [ 0, %1 ]
%8 = call i64 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %4
%11 = sext i32 %7 to i64
%12 = icmp slt i64 %5, %11
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = shl i32 %7, 1
%15 = add i32 %14, 2
%16 = shl i32 %15, 3
%17 = call i8** @x_realloc(i8** %6, i32 %16)
br label %18
18: ; preds = %13, %10
%19 = phi i8** [ %17, %13 ], [ %6, %10 ]
%20 = phi i32 [ %15, %13 ], [ %7, %10 ]
%21 = call i8* @strdup(i8* %3)
%22 = add nuw i64 %5, 1
%23 = getelementptr inbounds i8*, i8** %19, i64 %5
store i8* %21, i8** %23
%24 = load i32, i32* @stdin
%25 = call i64 @fgetc(i32 %24)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %4
28: ; preds = %18, %4
%29 = phi i8** [ %19, %18 ], [ %6, %4 ]
%30 = phi i64 [ %22, %18 ], [ %5, %4 ]
%31 = trunc i64 %30 to i32
store i32 %31, i32* %0
ret i8** %29
}