void docommand(argc, argv) int argc;
char *argv[];
{
  char *s, buffer[256];
  int i, status;
  buffer[0] = '\0';
  for (i = 0; i < argc; i++) {
    strcat(buffer, argv[i]);
    strcat(buffer, " ");
  }
  s = buffer;
  while (*s == ' ' || *s == '\t')
    s++;
  if (*s && (*s == '#'))
    return;
  system(buffer);
}


x86 assembly (clang, -O0):
<docommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x120(%rbp)
movl   $0x0,-0x124(%rbp)
mov    -0x124(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1194 <docommand+0x74>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x124(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcat@plt>
lea    -0x120(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1143 <docommand+0x23>
lea    -0x120(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x129(%rbp)
je     11ca <docommand+0xaa>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    11dd <docommand+0xbd>
jmp    11ee <docommand+0xce>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119f <docommand+0x7f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1213 <docommand+0xf3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1213 <docommand+0xf3>
jmp    1221 <docommand+0x101>
lea    -0x120(%rbp),%rdi
mov    $0x0,%al
call   1030 <system@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<docommand>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
movb   $0x0,(%rsp)
test   %edi,%edi
jle    1183 <docommand+0x53>
mov    %rsi,%r14
mov    %edi,%r15d
xor    %ebx,%ebx
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %r12,%rdi
call   1050 <strcat@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
movw   $0x20,(%rsp,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <docommand+0x30>
mov    %rsp,%rax
jmp    1194 <docommand+0x64>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x9,%cl
je     1190 <docommand+0x60>
cmp    $0x20,%cl
je     1190 <docommand+0x60>
cmp    $0x23,%cl
je     11b0 <docommand+0x80>
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <system@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @docommand(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
store i8 0, i8* %9
store i32 0, i32* %7
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = load i8**, i8*** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i8* @strcat(i8* %15, i8* %20)
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = call i8* @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %14
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %10
27: ; preds = %10
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
store i8* %28, i8** %5
br label %29
29: ; preds = %41, %27
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 9
br label %39
39: ; preds = %34, %29
%40 = phi i1 [ true, %29 ], [ %38, %34 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %5
br label %29
44: ; preds = %39
%45 = load i8*, i8** %5
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load i8*, i8** %5
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 35
br i1 %53, label %54, label %55
54: ; preds = %49
br label %58
55: ; preds = %49, %44
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%57 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %56)
br label %58
58: ; preds = %55, %54
ret void
}

LLVM IR (-O2):
define void @docommand(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %16, %8 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = call i8* @strcat(i8* %4, i8* dereferenceable(1) %11)
%13 = call i64 @strlen(i8* %4)
%14 = getelementptr [256 x i8], [256 x i8]* %3, i64 0, i64 %13
%15 = bitcast i8* %14 to i16*
store i16 32, i16* %15
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %18, label %8
18: ; preds = %8, %2
br label %19
19: ; preds = %18, %22
%20 = phi i8* [ %23, %22 ], [ %4, %18 ]
%21 = load i8, i8* %20
switch i8 %21, label %24 [
i8 32, label %22
i8 9, label %22
i8 35, label %26
]
22: ; preds = %19, %19
%23 = getelementptr inbounds i8, i8* %20, i64 1
br label %19
24: ; preds = %19
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %4)
br label %26
26: ; preds = %19, %24
ret void
}