#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__ gets(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int get_lines(char *lines[]) {
  int n = 0;
  char buffer[80];
  puts("Enter one line at time; enter a blank when done.");
  while ((n < 25) && (gets(buffer) != 0) && (buffer[0] != '\0')) {
    if ((lines[n] = (char *)malloc(strlen(buffer) + 1)) == NULL)
      return -1;
    strcpy(lines[n++], buffer);
  }
  return n;
}


x86 assembly (clang, -O0):
<get_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
cmpl   $0x19,-0x14(%rbp)
mov    %al,-0x71(%rbp)
jge    11a9 <get_lines+0x59>
lea    -0x70(%rbp),%rdi
call   1060 <gets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x71(%rbp)
je     11a9 <get_lines+0x59>
movsbl -0x70(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    11b9 <get_lines+0x69>
jmp    1214 <get_lines+0xc4>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11f0 <get_lines+0xa0>
movl   $0xffffffff,-0x4(%rbp)
jmp    121a <get_lines+0xca>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1172 <get_lines+0x22>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_lines>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%r14
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %rsp,%r15
nopl   (%rax)
mov    %r15,%rdi
call   1060 <gets@plt>
test   %rax,%rax
je     11be <get_lines+0x6e>
cmpb   $0x0,(%rsp)
je     11be <get_lines+0x6e>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,(%r14,%rbx,8)
test   %rax,%rax
je     11b9 <get_lines+0x69>
add    $0x1,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmp    $0x19,%rbx
jne    1170 <get_lines+0x20>
mov    $0x19,%ebx
jmp    11be <get_lines+0x6e>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Enter one line at time; enter a blank when done.\00"
define i32 @get_lines(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca [80 x i8]
store i8** %0, i8*** %3
store i32 0, i32* %4
%6 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %33, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 25
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%12 = call i64 @gets(i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br label %19
19: ; preds = %14, %10, %7
%20 = phi i1 [ false, %10 ], [ false, %7 ], [ %18, %14 ]
br i1 %20, label %21, label %42
21: ; preds = %19
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%23 = call i64 @strlen(i8* %22)
%24 = add nsw i64 %23, 1
%25 = call i64 @malloc(i64 %24)
%26 = inttoptr i64 %25 to i8*
%27 = load i8**, i8*** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* %26, i8** %30
%31 = icmp eq i8* %26, null
br i1 %31, label %32, label %33
32: ; preds = %21
store i32 -1, i32* %2
br label %44
33: ; preds = %21
%34 = load i8**, i8*** %3
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8*, i8** %34, i64 %37
%39 = load i8*, i8** %38
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%41 = call i32 @strcpy(i8* %39, i8* %40)
br label %7
42: ; preds = %19
%43 = load i32, i32* %4
store i32 %43, i32* %2
br label %44
44: ; preds = %42, %32
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str = [49 x i8] c"Enter one line at time; enter a blank when done.\00"
define i32 @get_lines(i8** nocapture writeonly %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %1, %19
%6 = phi i64 [ 0, %1 ], [ %20, %19 ]
%7 = call i64 @gets(i8* %3)
%8 = icmp ne i64 %7, 0
%9 = load i8, i8* %3
%10 = icmp ne i8 %9, 0
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %12, label %23
12: ; preds = %5
%13 = call i64 @strlen(i8* %3)
%14 = add nsw i64 %13, 1
%15 = call i64 @malloc(i64 %14)
%16 = inttoptr i64 %15 to i8*
%17 = getelementptr inbounds i8*, i8** %0, i64 %6
store i8* %16, i8** %17
%18 = icmp eq i64 %15, 0
br i1 %18, label %25, label %19
19: ; preds = %12
%20 = add nuw nsw i64 %6, 1
%21 = call i32 @strcpy(i8* %16, i8* %3)
%22 = icmp eq i64 %20, 25
br i1 %22, label %25, label %5
23: ; preds = %5
%24 = trunc i64 %6 to i32
br label %25
25: ; preds = %12, %19, %23
%26 = phi i32 [ %24, %23 ], [ 25, %19 ], [ -1, %12 ]
ret i32 %26
}