#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__ strdup(char *);
char *strtok(char *, char *);
int lee_linea(char *linea, char **argumentos) {
  char *token;
  int narg = 0;
  if ((token = strtok(linea, " ")) != NULL) {
    argumentos[narg] = (char *)strdup(token);
    narg++;
    while ((token = strtok(NULL, " ")) != NULL) {
      argumentos[narg] = (char *)strdup(token);
      narg++;
    }
  }
  argumentos[narg] = NULL;
  return narg;
}


x86 assembly (clang, -O0):
<lee_linea>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11bf <lee_linea+0x9f>
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe7f(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ba <lee_linea+0x9a>
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1176 <lee_linea+0x56>
jmp    11bf <lee_linea+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lee_linea>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xed1(%rip),%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     1191 <lee_linea+0x71>
mov    %rax,%rdi
call   1040 <strdup@plt>
mov    %rax,(%r14)
lea    0xeb5(%rip),%rsi
xor    %edi,%edi
call   1030 <strtok@plt>
test   %rax,%rax
je     1195 <lee_linea+0x75>
mov    $0x1,%ebx
lea    0xe9d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rdi
call   1040 <strdup@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1170 <lee_linea+0x50>
jmp    119a <lee_linea+0x7a>
xor    %ebx,%ebx
jmp    119a <lee_linea+0x7a>
mov    $0x1,%ebx
mov    %ebx,%eax
movq   $0x0,(%r14,%rax,8)
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @lee_linea(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 0, i32* %6
%7 = load i8*, i8** %3
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %34
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i64 @strdup(i8* %11)
%13 = inttoptr i64 %12 to i8*
%14 = load i8**, i8*** %4
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
store i8* %13, i8** %17
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %20
20: ; preds = %23, %10
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %5
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i8*, i8** %5
%25 = call i64 @strdup(i8* %24)
%26 = inttoptr i64 %25 to i8*
%27 = load i8**, i8*** %4
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* %26, i8** %30
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %20
33: ; preds = %20
br label %34
34: ; preds = %33, %2
%35 = load i8**, i8*** %4
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
store i8* null, i8** %38
%39 = load i32, i32* %6
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @lee_linea(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = tail call i64 @strdup(i8* %3)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %1
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %21, label %10
10: ; preds = %5, %10
%11 = phi i64 [ %16, %10 ], [ 1, %5 ]
%12 = phi i8* [ %17, %10 ], [ %8, %5 ]
%13 = tail call i64 @strdup(i8* %12)
%14 = inttoptr i64 %13 to i8*
%15 = getelementptr inbounds i8*, i8** %1, i64 %11
store i8* %14, i8** %15
%16 = add nuw i64 %11, 1
%17 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %10
19: ; preds = %10
%20 = trunc i64 %16 to i32
br label %21
21: ; preds = %19, %5, %2
%22 = phi i32 [ 0, %2 ], [ 1, %5 ], [ %20, %19 ]
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
store i8* null, i8** %24
ret i32 %22
}