void shell_cmd(command) char *command;
{
  int child_pid;
  int wait_pid;
  switch (child_pid = vfork()) {
  case -1:
    tcpd_warn("cannot fork: %m");
    break;
  case 00:
    do_child(command);
  default:
    while ((wait_pid = wait((int *)0)) != -1 && wait_pid != child_pid)
      ;
  }
}


x86 assembly (clang, -O0):
<shell_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
call   1050 <vfork@plt>
mov    %eax,-0xc(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0xffffffff,%eax
je     1177 <shell_cmd+0x37>
jmp    1167 <shell_cmd+0x27>
mov    -0x14(%rbp),%eax
test   %eax,%eax
je     118a <shell_cmd+0x4a>
jmp    1195 <shell_cmd+0x55>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <tcpd_warn@plt>
jmp    11de <shell_cmd+0x9e>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <do_child@plt>
jmp    119a <shell_cmd+0x5a>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x0,%al
call   1060 <wait@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x15(%rbp)
je     11c4 <shell_cmd+0x84>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11d4 <shell_cmd+0x94>
jmp    11d9 <shell_cmd+0x99>
jmp    119a <shell_cmd+0x5a>
jmp    11de <shell_cmd+0x9e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_cmd>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1050 <vfork@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1167 <shell_cmd+0x27>
cmp    $0xffffffff,%ebx
jne    1171 <shell_cmd+0x31>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <tcpd_warn@plt>
jmp    1192 <shell_cmd+0x52>
xor    %eax,%eax
mov    %r14,%rdi
call   1030 <do_child@plt>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %ebp,%eax
call   1060 <wait@plt>
cmp    $0xffffffff,%eax
je     1192 <shell_cmd+0x52>
cmp    %ebx,%eax
jne    1180 <shell_cmd+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"cannot fork: %m\00"
define void @shell_cmd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @vfork()
store i32 %5, i32* %3
switch i32 %5, label %11 [
i32 -1, label %6
i32 0, label %8
]
6: ; preds = %1
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @tcpd_warn to i32 (i8*, ...)*)(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %23
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @do_child to i32 (i8*, ...)*)(i8* %9)
br label %11
11: ; preds = %1, %8
br label %12
12: ; preds = %21, %11
%13 = call i32 (i32*, ...) bitcast (i32 (...)* @wait to i32 (i32*, ...)*)(i32* null)
store i32 %13, i32* %4
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = icmp ne i32 %16, %17
br label %19
19: ; preds = %15, %12
%20 = phi i1 [ false, %12 ], [ %18, %15 ]
br i1 %20, label %21, label %22
21: ; preds = %19
br label %12
22: ; preds = %19
br label %23
23: ; preds = %22, %6
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"cannot fork: %m\00"
define void @shell_cmd(i8* %0) {
%2 = call i32 @vfork()
switch i32 %2, label %7 [
i32 -1, label %3
i32 0, label %5
]
3: ; preds = %1
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @tcpd_warn to i32 (i8*, ...)*)(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %13
5: ; preds = %1
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @do_child to i32 (i8*, ...)*)(i8* %0)
br label %7
7: ; preds = %1, %5
br label %8
8: ; preds = %7, %8
%9 = call i32 (i32*, ...) bitcast (i32 (...)* @wait to i32 (i32*, ...)*)(i32* null)
%10 = icmp ne i32 %9, -1
%11 = icmp ne i32 %9, %2
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %8, label %13
13: ; preds = %8, %3
ret void
}