#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*/ execute_many(char ***, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int split_concurrent(char *, size_t, char ***, int *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strip_newline(char *, size_t);
bool shell_repl(char *buf, size_t buf_len) {
  fflush(stdout);
  strip_newline(buf, buf_len);
  char *args[1024 / 2][1024 / 2 + 1];
  int num_concurrent;
  bool to_continue = split_concurrent(buf, buf_len, args, &num_concurrent);
  execute_many(args, num_concurrent);
  return to_continue;
}


x86 assembly (clang, -O0):
<shell_repl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x201020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strip_newline@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x201010(%rbp),%rdx
lea    -0x201014(%rbp),%rcx
call   1040 <split_concurrent@plt>
mov    %eax,-0x201018(%rbp)
lea    -0x201010(%rbp),%rdi
mov    -0x201014(%rbp),%esi
call   1060 <execute_many@plt>
mov    -0x201018(%rbp),%eax
add    $0x201020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_repl>:
push   %r15
push   %r14
push   %rbx
sub    $0x201010,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strip_newline@plt>
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <split_concurrent@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%esi
mov    %r15,%rdi
call   1060 <execute_many@plt>
mov    %ebx,%eax
add    $0x201010,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
define i32 @shell_repl(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [512 x [513 x i8*]]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = load i8*, i8** %3
%11 = load i64, i64* %4
%12 = call i32 @strip_newline(i8* %10, i64 %11)
%13 = load i8*, i8** %3
%14 = load i64, i64* %4
%15 = getelementptr inbounds [512 x [513 x i8*]], [512 x [513 x i8*]]* %5, i64 0, i64 0
%16 = bitcast [513 x i8*]* %15 to i8***
%17 = call i32 @split_concurrent(i8* %13, i64 %14, i8*** %16, i32* %6)
store i32 %17, i32* %7
%18 = getelementptr inbounds [512 x [513 x i8*]], [512 x [513 x i8*]]* %5, i64 0, i64 0
%19 = bitcast [513 x i8*]* %18 to i8***
%20 = load i32, i32* %6
%21 = call i32 @execute_many(i8*** %19, i32 %20)
%22 = load i32, i32* %7
ret i32 %22
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @shell_repl(i8* %0, i64 %1) {
%3 = alloca [512 x [513 x i8*]]
%4 = alloca i32
%5 = load i32, i32* @stdout
%6 = tail call i32 @fflush(i32 %5)
%7 = tail call i32 @strip_newline(i8* %0, i64 %1)
%8 = bitcast [512 x [513 x i8*]]* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast [512 x [513 x i8*]]* %3 to i8***
%11 = call i32 @split_concurrent(i8* %0, i64 %1, i8*** %10, i32* %4)
%12 = load i32, i32* %4
%13 = call i32 @execute_many(i8*** %10, i32 %12)
ret i32 %11
}