#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ jb_execvp(char *, char **);
char *strdup(char const *);
char *strtok(char *, char *);
void jb_system(const char *command) {
  enum { MAXARGS = 64 };
  char *argv[MAXARGS];
  uint8_t argc = 0;
  char *buf = strdup(command);
  for (char *i = strtok(buf, " "); i && argc < MAXARGS;
       i = strtok(NULL, " "), ++argc)
    argv[argc] = i;
  argv[argc] = NULL;
  jb_execvp(argv[0], argv);
  free(buf);
}


x86 assembly (clang, -O0):
<jb_system>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x214(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x220(%rbp)
mov    -0x220(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x228(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x228(%rbp)
mov    %al,-0x229(%rbp)
je     11a9 <jb_system+0x69>
cmpl   $0x40,-0x214(%rbp)
setl   %al
mov    %al,-0x229(%rbp)
mov    -0x229(%rbp),%al
test   $0x1,%al
jne    11bc <jb_system+0x7c>
jmp    11fd <jb_system+0xbd>
mov    -0x228(%rbp),%rcx
movslq -0x214(%rbp),%rax
mov    %rcx,-0x210(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xe23(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x228(%rbp)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    1183 <jb_system+0x43>
movslq -0x214(%rbp),%rax
movq   $0x0,-0x210(%rbp,%rax,8)
mov    -0x210(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1040 <jb_execvp@plt>
mov    -0x220(%rbp),%rdi
call   1030 <free@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jb_system>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
call   1060 <strdup@plt>
mov    %rax,%r14
lea    0xea5(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11a2 <jb_system+0x62>
xor    %ebx,%ebx
lea    0xe8f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,(%rsp,%rbx,8)
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
je     11a4 <jb_system+0x64>
cmp    $0x3f,%rbx
mov    %rcx,%rbx
jb     1180 <jb_system+0x40>
jmp    11a4 <jb_system+0x64>
xor    %ecx,%ecx
movq   $0x0,(%rsp,%rcx,8)
mov    (%rsp),%rdi
mov    %rsp,%rsi
call   1040 <jb_execvp@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @jb_system(i8* nocapture %0) {
%2 = alloca [64 x i8*]
%3 = bitcast [64 x i8*]* %2 to i8*
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %14
7: ; preds = %14, %1
%8 = phi i64 [ 0, %1 ], [ %19, %14 ]
%9 = getelementptr inbounds [64 x i8*], [64 x i8*]* %2, i64 0, i64 %8
store i8* null, i8** %9
%10 = getelementptr inbounds [64 x i8*], [64 x i8*]* %2, i64 0, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @jb_execvp(i8* %11, i8** %10)
%13 = call i32 @free(i8* %4)
ret void
14: ; preds = %1, %14
%15 = phi i64 [ %19, %14 ], [ 0, %1 ]
%16 = phi i8* [ %18, %14 ], [ %5, %1 ]
%17 = getelementptr inbounds [64 x i8*], [64 x i8*]* %2, i64 0, i64 %15
store i8* %16, i8** %17
%18 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = add nuw nsw i64 %15, 1
%20 = icmp ne i8* %18, null
%21 = icmp ult i64 %15, 63
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %14, label %7
}