#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*/ calloc(int, int);
char **check_ptr(int /*<<< orphan*/);
size_t getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char **read_labels(int count) {
  char **result;
  int i;
  size_t tmp;
  result = check_ptr(calloc(count, sizeof *result));
  for (i = 0; i < count; i++) {
    tmp = getline(&(result[i]), &tmp, stdin);
    result[i][tmp - 1] = 0;
  }
  return result;
}


x86 assembly (clang, -O0):
<read_labels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %eax,%edi
call   1050 <check_ptr@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b1 <read_labels+0x81>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rsi
call   1040 <getline@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <read_labels+0x2a>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_labels>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %eax,%edi
call   1050 <check_ptr@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    1196 <read_labels+0x66>
mov    %ebx,%r12d
mov    0x2e87(%rip),%r13
lea    0x8(%rsp),%r15
mov    %r14,%rbx
nopl   0x0(%rax)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <getline@plt>
mov    %rax,0x8(%rsp)
mov    (%rbx),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
add    $0x8,%rbx
add    $0xffffffffffffffff,%r12
jne    1170 <read_labels+0x40>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
define i8** @read_labels(i32 %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i64
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @calloc(i32 %6, i32 8)
%8 = call i8** @check_ptr(i32 %7)
store i8** %8, i8*** %3
store i32 0, i32* %4
br label %9
9: ; preds = %28, %1
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load i8**, i8*** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i32, i32* @stdin
%19 = call i64 @getline(i8** %17, i64* %5, i32 %18)
store i64 %19, i64* %5
%20 = load i8**, i8*** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = load i64, i64* %5
%26 = sub i64 %25, 1
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %13
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %9
31: ; preds = %9
%32 = load i8**, i8*** %3
ret i8** %32
}

LLVM IR (-O2):
@stdin = global i32 0
define i8** @read_labels(i32 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i32 @calloc(i32 %0, i32 8)
%5 = tail call i8** @check_ptr(i32 %4)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = getelementptr inbounds i8*, i8** %5, i64 %10
%12 = load i32, i32* @stdin
%13 = call i64 @getline(i8** %11, i64* %2, i32 %12)
store i64 %13, i64* %2
%14 = load i8*, i8** %11
%15 = add i64 %13, -1
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8 0, i8* %16
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %9
19: ; preds = %9, %1
ret i8** %5
}