#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*/ gets(char *);
int strlen(int /*<<< orphan*/);
LeerCadena(char cad[][81], char *pcad[], int nmc) {
  int longitud = 0, ncads = 0;
  if (nmc < 1)
    return -1;
  while ((longitud = strlen(gets(cad[ncads]))) > 0) {
    pcad[ncads++] = cad[ncads];
    if (ncads == nmc)
      break;
  }
  return (ncads);
}


x86 assembly (clang, -O0):
<LeerCadena>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    1157 <LeerCadena+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <LeerCadena+0xa4>
jmp    115c <LeerCadena+0x3c>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
imul   $0x51,%rax,%rax
add    %rax,%rdi
call   1040 <gets@plt>
mov    %eax,%edi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    11be <LeerCadena+0x9e>
mov    -0x10(%rbp),%rdx
movslq -0x24(%rbp),%rax
imul   $0x51,%rax,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11b9 <LeerCadena+0x99>
jmp    11be <LeerCadena+0x9e>
jmp    115c <LeerCadena+0x3c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LeerCadena>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1169 <LeerCadena+0x49>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%r12d
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <gets@plt>
mov    %eax,%edi
call   1030 <strlen@plt>
test   %eax,%eax
jle    116f <LeerCadena+0x4f>
mov    %rbx,(%r14,%r15,8)
add    $0x1,%r15
add    $0x51,%rbx
cmp    %r15,%r12
jne    1140 <LeerCadena+0x20>
mov    %r12d,%r15d
jmp    116f <LeerCadena+0x4f>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @LeerCadena([81 x i8]* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = icmp slt i32 %2, 1
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %13
%8 = phi i64 [ 0, %5 ], [ %14, %13 ]
%9 = getelementptr inbounds [81 x i8], [81 x i8]* %0, i64 %8, i64 0
%10 = tail call i32 @gets(i8* %9)
%11 = tail call i32 @strlen(i32 %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = add nuw nsw i64 %8, 1
%15 = getelementptr inbounds i8*, i8** %1, i64 %8
store i8* %9, i8** %15
%16 = icmp eq i64 %14, %6
br i1 %16, label %19, label %7
17: ; preds = %7
%18 = trunc i64 %8 to i32
br label %19
19: ; preds = %13, %17, %3
%20 = phi i32 [ -1, %3 ], [ %18, %17 ], [ %2, %13 ]
ret i32 %20
}