#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__ calloc(int, int);
int /*<<< orphan*/ getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readLine(char **);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int readLines(char ***pStrings) {
  int n, i;
  printf("How many strings to input: ");
  scanf("%d", &n);
  getc(stdin);
  *pStrings = (char **)calloc(n, sizeof(char *));
  for (i = 0; i < n; i++)
    readLine(&(*pStrings)[i]);
  return n;
}


x86 assembly (clang, -O0):
<readLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1070 <getc@plt>
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d5 <readLines+0x85>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1050 <readLine@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a4 <readLines+0x54>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLines>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1070 <getc@plt>
mov    0xc(%rsp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rdi
mov    %rax,(%r14)
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11dd <readLines+0x8d>
call   1050 <readLine@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
jl     11dd <readLines+0x8d>
mov    $0x1,%r15d
mov    $0x8,%ebx
nopl   0x0(%rax)
mov    (%r14),%rdi
add    %rbx,%rdi
call   1050 <readLine@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rax
add    $0x8,%rbx
cmp    %rax,%r15
jl     11c0 <readLines+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"How many strings to input: \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
define i32 @readLines(i8*** %0) {
%2 = alloca i8***
%3 = alloca i32
%4 = alloca i32
store i8*** %0, i8**** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* @stdin
%8 = call i32 @getc(i32 %7)
%9 = load i32, i32* %3
%10 = call i64 @calloc(i32 %9, i32 8)
%11 = inttoptr i64 %10 to i8**
%12 = load i8***, i8**** %2
store i8** %11, i8*** %12
store i32 0, i32* %4
br label %13
13: ; preds = %24, %1
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8***, i8**** %2
%19 = load i8**, i8*** %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = call i32 @readLine(i8** %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %13
27: ; preds = %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [28 x i8] c"How many strings to input: \00"
@.str.1 = [3 x i8] c"%d\00"
@stdin = global i32 0
define i32 @readLines(i8*** nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* @stdin
%7 = call i32 @getc(i32 %6)
%8 = load i32, i32* %2
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to i8**
store i8** %10, i8*** %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %1
%14 = call i32 @readLine(i8** %10)
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %26
17: ; preds = %13, %17
%18 = phi i64 [ %22, %17 ], [ 1, %13 ]
%19 = load i8**, i8*** %0
%20 = getelementptr inbounds i8*, i8** %19, i64 %18
%21 = call i32 @readLine(i8** %20)
%22 = add nuw nsw i64 %18, 1
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %17, label %26
26: ; preds = %17, %13, %1
%27 = phi i32 [ %11, %1 ], [ %15, %13 ], [ %23, %17 ]
ret i32 %27
}