#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*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isspace(char);
int /*<<< orphan*/ stdin;
int strlen(char *);
char *strtok(char *, char *);
void read_command(char *command_arglist[]) {
  char command[1000];
  fgets(command, 1000, stdin);
  int i = strlen(command) - 1;
  while (isspace(command[i]))
    command[i--] = '\0';
  command_arglist[i = 0] = strtok(command, " ");
  while (command_arglist[i] != NULL && i < 50)
    command_arglist[++i] = strtok(NULL, " ");
}


x86 assembly (clang, -O0):
<read_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%edi
ff
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11bc <read_command+0x7c>
mov    -0x3f4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x3f4(%rbp)
cltq
movb   $0x0,-0x3f0(%rbp,%rax,1)
jmp    117e <read_command+0x3e>
lea    -0x3f0(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
movl   $0x0,-0x3f4(%rbp)
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
movslq -0x3f4(%rbp),%rdx
xor    %eax,%eax
cmpq   $0x0,(%rcx,%rdx,8)
mov    %al,-0x3f5(%rbp)
je     1211 <read_command+0xd1>
cmpl   $0x32,-0x3f4(%rbp)
setl   %al
mov    %al,-0x3f5(%rbp)
mov    -0x3f5(%rbp),%al
test   $0x1,%al
jne    1224 <read_command+0xe4>
jmp    1256 <read_command+0x116>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd1(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    -0x3f4(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x3f4(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11e3 <read_command+0xa3>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_command>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rdi,%r14
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
movsbl -0x1(%rsp,%rbx,1),%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     11a5 <read_command+0x65>
add    $0xffffffffffffffff,%rbx
add    %rsp,%rbx
nopl   0x0(%rax)
movb   $0x0,(%rbx)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1190 <read_command+0x50>
lea    0xe54(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strtok@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11f1 <read_command+0xb1>
xor    %ebx,%ebx
lea    0xe3b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,0x8(%r14,%rbx,8)
test   %rax,%rax
je     11f1 <read_command+0xb1>
lea    0x1(%rbx),%rax
cmp    $0x31,%rbx
mov    %rax,%rbx
jb     11d0 <read_command+0x90>
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c" \00"
define void @read_command(i8** %0) {
%2 = alloca i8**
%3 = alloca [1000 x i8]
%4 = alloca i32
store i8** %0, i8*** %2
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 1000, i32 %6)
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %4
br label %11
11: ; preds = %18, %1
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call i64 @isspace(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %21
store i8 0, i8* %22
br label %11
23: ; preds = %11
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%25 = call i8* @strtok(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = load i8**, i8*** %2
store i32 0, i32* %4
%27 = getelementptr inbounds i8*, i8** %26, i64 0
store i8* %25, i8** %27
br label %28
28: ; preds = %40, %23
%29 = load i8**, i8*** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 50
br label %38
38: ; preds = %35, %28
%39 = phi i1 [ false, %28 ], [ %37, %35 ]
br i1 %39, label %40, label %47
40: ; preds = %38
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%42 = load i8**, i8*** %2
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
store i8* %41, i8** %46
br label %28
47: ; preds = %38
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c" \00"
define void @read_command(i8** nocapture %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 1000, i32 %4)
%6 = call i32 @strlen(i8* %3)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %1, %13
%14 = phi i64 [ %16, %13 ], [ %8, %1 ]
%15 = phi i8* [ %17, %13 ], [ %9, %1 ]
store i8 0, i8* %15
%16 = add i64 %14, -1
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %13
21: ; preds = %13, %1
%22 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %0
%23 = icmp eq i8* %22, null
br i1 %23, label %32, label %24
24: ; preds = %21, %24
%25 = phi i64 [ %27, %24 ], [ 0, %21 ]
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = add nuw nsw i64 %25, 1
%28 = getelementptr inbounds i8*, i8** %0, i64 %27
store i8* %26, i8** %28
%29 = icmp ne i8* %26, null
%30 = icmp ult i64 %25, 49
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %24, label %32
32: ; preds = %24, %21
ret void
}