int GenCmd(cmd, resultstr, resultlen)
char *cmd;
char **resultstr;
int *resultlen;
{
  extern char *ExecuteStrFunction();
  char *argv[100];
  int argc;
  argc = ServerArgv(cmd, argv, 100);
  if (argc > 100)
    return 103;
  cmd = argv[0];
  *resultstr = ExecuteStrFunction(argc, argv);
  *resultlen = strlen(*resultstr);
  return 0;
}


x86 assembly (clang, -O0):
<GenCmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x340(%rbp),%rsi
mov    $0x64,%edx
mov    $0x0,%al
call   1050 <ServerArgv@plt>
mov    %eax,-0x344(%rbp)
cmpl   $0x64,-0x344(%rbp)
jle    117d <GenCmd+0x4d>
movl   $0x67,-0x4(%rbp)
jmp    11c1 <GenCmd+0x91>
mov    -0x340(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x344(%rbp),%edi
lea    -0x340(%rbp),%rsi
mov    $0x0,%al
call   1030 <ExecuteStrFunction@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenCmd>:
push   %r14
push   %rbx
sub    $0x328,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rsp,%rsi
mov    $0x64,%edx
xor    %eax,%eax
call   1050 <ServerArgv@plt>
mov    $0x67,%ecx
cmp    $0x64,%eax
jg     1175 <GenCmd+0x45>
mov    %rsp,%rsi
mov    %eax,%edi
xor    %eax,%eax
call   1030 <ExecuteStrFunction@plt>
mov    %rax,(%rbx)
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,(%r14)
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x328,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @GenCmd(i8* %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca [100 x i8*]
%9 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [100 x i8*], [100 x i8*]* %8, i64 0, i64 0
%12 = call i32 (i8*, i8**, i32, ...) bitcast (i32 (...)* @ServerArgv to i32 (i8*, i8**, i32, ...)*)(i8* %10, i8** %11, i32 100)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp sgt i32 %13, 100
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 103, i32* %4
br label %28
16: ; preds = %3
%17 = getelementptr inbounds [100 x i8*], [100 x i8*]* %8, i64 0, i64 0
%18 = load i8*, i8** %17
store i8* %18, i8** %5
%19 = load i32, i32* %9
%20 = getelementptr inbounds [100 x i8*], [100 x i8*]* %8, i64 0, i64 0
%21 = call i8* (i32, i8**, ...) bitcast (i8* (...)* @ExecuteStrFunction to i8* (i32, i8**, ...)*)(i32 %19, i8** %20)
%22 = load i8**, i8*** %6
store i8* %21, i8** %22
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = call i64 @strlen(i8* %24)
%26 = trunc i64 %25 to i32
%27 = load i32*, i32** %7
store i32 %26, i32* %27
store i32 0, i32* %4
br label %28
28: ; preds = %16, %15
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @GenCmd(i8* %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca [100 x i8*]
%5 = bitcast [100 x i8*]* %4 to i8*
%6 = getelementptr inbounds [100 x i8*], [100 x i8*]* %4, i64 0, i64 0
%7 = call i32 (i8*, i8**, i32, ...) bitcast (i32 (...)* @ServerArgv to i32 (i8*, i8**, i32, ...)*)(i8* %0, i8** %6, i32 100)
%8 = icmp sgt i32 %7, 100
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = call i8* (i32, i8**, ...) bitcast (i8* (...)* @ExecuteStrFunction to i8* (i32, i8**, ...)*)(i32 %7, i8** %6)
store i8* %10, i8** %1
%11 = call i64 @strlen(i8* dereferenceable(1) %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %2
br label %13
13: ; preds = %3, %9
%14 = phi i32 [ 0, %9 ], [ 103, %3 ]
ret i32 %14
}