#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 */
char *AddCR(char *);
int Error(char *, int);
char *JoinWithSpaces(int, char **);
int Os9Chain(char *, char const *, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
int picolCommand9Chain(int argc, char **argv, void *pd) {
  char *program = argv[1];
  const char *params = JoinWithSpaces(argc - 2, argv + 2);
  params = AddCR((char *)params);
  int e = Os9Chain(program, params, strlen(params), 0, 0);
  return Error(argv[1], e);
}


x86 assembly (clang, -O0):
<picolCommand9Chain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x2,%edi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1070 <JoinWithSpaces@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <AddCR@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1060 <Os9Chain@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <Error@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<picolCommand9Chain>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    0x8(%rsi),%r14
add    $0xfffffffe,%edi
add    $0x10,%rsi
call   1070 <JoinWithSpaces@plt>
mov    %rax,%rdi
call   1030 <AddCR@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <Os9Chain@plt>
mov    0x8(%r15),%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <Error@plt>

LLVM IR (-O0):
define i32 @picolCommand9Chain(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %7
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = call i8* @JoinWithSpaces(i32 %14, i8** %16)
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = call i8* @AddCR(i8* %18)
store i8* %19, i8** %8
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = load i8*, i8** %8
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @Os9Chain(i8* %20, i8* %21, i32 %23, i32 0, i32 0)
store i32 %24, i32* %9
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* %9
%29 = call i32 @Error(i8* %27, i32 %28)
ret i32 %29
}

LLVM IR (-O2):
define i32 @picolCommand9Chain(i32 %0, i8** %1, i8* nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = add nsw i32 %0, -2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = tail call i8* @JoinWithSpaces(i32 %6, i8** %7)
%9 = tail call i8* @AddCR(i8* %8)
%10 = tail call i32 @strlen(i8* %9)
%11 = tail call i32 @Os9Chain(i8* %5, i8* %9, i32 %10, i32 0, i32 0)
%12 = load i8*, i8** %4
%13 = tail call i32 @Error(i8* %12, i32 %11)
ret i32 %13
}