#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__ getline_my(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int readlines(char *arr[100], int amount) {
  int i = 0;
  int len = 0;
  char c = 0;
  char *p;
  char line[100];
  while (i < amount && (len = getline_my(line) > 0)) {
    line[len - 1] = '\0';
    strcpy(p, line);
    arr[i++] = p;
  };
  return i;
}


x86 assembly (clang, -O0):
<readlines>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x91(%rbp)
jge    117c <readlines+0x5c>
lea    -0x90(%rbp),%rdi
call   1040 <getline_my@plt>
cmp    $0x0,%rax
setg   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x14(%rbp)
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
test   $0x1,%al
jne    118f <readlines+0x6f>
jmp    11ce <readlines+0xae>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x90(%rbp,%rax,1)
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1144 <readlines+0x24>
mov    -0x10(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readlines>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
test   %esi,%esi
jle    1164 <readlines+0x44>
mov    %esi,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <getline_my@plt>
test   %rax,%rax
jle    1166 <readlines+0x46>
movb   $0x0,(%rsp)
mov    %r14,%rsi
call   1030 <strcpy@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1140 <readlines+0x20>
mov    %ebp,%ebx
jmp    1166 <readlines+0x46>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @readlines(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
%9 = alloca [100 x i8]
store i8** %0, i8*** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i8 0, i8* %7
br label %10
10: ; preds = %21, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%16 = call i64 @getline_my(i8* %15)
%17 = icmp sgt i64 %16, 0
%18 = zext i1 %17 to i32
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %10
%20 = phi i1 [ false, %10 ], [ %17, %14 ]
br i1 %20, label %21, label %35
21: ; preds = %19
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i8*, i8** %8
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = load i8*, i8** %8
%30 = load i8**, i8*** %3
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8*, i8** %30, i64 %33
store i8* %29, i8** %34
br label %10
35: ; preds = %19
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
define i32 @readlines(i8** nocapture readnone %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %14
6: ; preds = %2, %10
%7 = phi i32 [ %12, %10 ], [ 0, %2 ]
%8 = call i64 @getline_my(i8* %4)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
store i8 0, i8* %4
%11 = call i32 @strcpy(i8* undef, i8* %4)
%12 = add nuw nsw i32 %7, 1
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %6
14: ; preds = %6, %10, %2
%15 = phi i32 [ 0, %2 ], [ %1, %10 ], [ %7, %6 ]
ret i32 %15
}