#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*/ free(char *);
int /*<<< orphan*/ rshell_exec_cmd(char *);
char *strdup(char *);
char *strtok_r(char *, char *, char **);
void rshell_exec_cmd_line(char *line) {
  int bufsize = 1024;
  int position = 0;
  char *token;
  char *saveptr;
  char *cmd;
  token = strtok_r(line, ";", &saveptr);
  while (token != NULL) {
    cmd = strdup(token);
    rshell_exec_cmd(cmd);
    token = strtok_r(NULL, ";", &saveptr);
    free(cmd);
  }
}


x86 assembly (clang, -O0):
<rshell_exec_cmd_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x400,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b9 <rshell_exec_cmd_line+0x79>
mov    -0x18(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <rshell_exec_cmd@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe62(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    1172 <rshell_exec_cmd_line+0x32>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rshell_exec_cmd_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rsi
mov    %rsp,%rdx
call   1040 <strtok_r@plt>
test   %rax,%rax
je     11a0 <rshell_exec_cmd_line+0x60>
mov    %rax,%rbx
lea    0xe9a(%rip),%r14
mov    %rsp,%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <strdup@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <rshell_exec_cmd@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <strtok_r@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <free@plt>
test   %rbx,%rbx
jne    1170 <rshell_exec_cmd_line+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c";\00"
define void @rshell_exec_cmd_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %2
store i32 1024, i32* %3
store i32 0, i32* %4
%8 = load i8*, i8** %2
%9 = call i8* @strtok_r(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
store i8* %9, i8** %5
br label %10
10: ; preds = %13, %1
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = call i32 @rshell_exec_cmd(i8* %16)
%18 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
store i8* %18, i8** %5
%19 = load i8*, i8** %7
%20 = call i32 @free(i8* %19)
br label %10
21: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
define void @rshell_exec_cmd_line(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %1, %6
%7 = phi i8* [ %10, %6 ], [ %4, %1 ]
%8 = call i8* @strdup(i8* %7)
%9 = call i32 @rshell_exec_cmd(i8* %8)
%10 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%11 = call i32 @free(i8* %8)
%12 = icmp eq i8* %10, null
br i1 %12, label %13, label %6
13: ; preds = %6, %1
ret void
}