#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 */
struct vm_err {
  int dummy;
};
struct virtual_machine_startup {
  int dummy;
};
struct multiple_stub_function_list {
  int dummy;
};
struct multiple_ir {
  int dummy;
};
struct multiple_error {
  int dummy;
};

/* Variables and functions */
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char *, size_t);
int /*<<< orphan*/ vm_completion_lib_dir(struct multiple_error *);
int virtual_machine_completion(
    struct multiple_error *err, struct vm_err *r, struct multiple_ir *icode,
    struct virtual_machine_startup *startup, int debug,
    struct multiple_stub_function_list *external_functions,
    const char *completion_cmd) {
  size_t completion_cmd_len;
  (void)r;
  (void)icode;
  (void)startup;
  (void)debug;
  (void)external_functions;
  completion_cmd_len = strlen(completion_cmd);
  if ((completion_cmd_len == strlen("lib-dir")) &&
      (strncmp(completion_cmd, "lib-dir", completion_cmd_len) == 0)) {
    vm_completion_lib_dir(err);
  }
  return 0;
}


x86 assembly (clang, -O0):
<virtual_machine_completion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x7,-0x38(%rbp)
jne    1193 <virtual_machine_completion+0x63>
mov    0x10(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xe85(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1193 <virtual_machine_completion+0x63>
mov    -0x8(%rbp),%rdi
call   1050 <vm_completion_lib_dir@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<virtual_machine_completion>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x7,%rax
jne    116b <virtual_machine_completion+0x3b>
lea    0xeaf(%rip),%rsi
mov    $0x7,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %rax,%rax
jne    116b <virtual_machine_completion+0x3b>
mov    %r14,%rdi
call   1050 <vm_completion_lib_dir@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.multiple_error = type { i32 }
%struct.vm_err = type { i32 }
%struct.multiple_ir = type { i32 }
%struct.virtual_machine_startup = type { i32 }
%struct.multiple_stub_function_list = type { i32 }
@.str = [8 x i8] c"lib-dir\00"
define i32 @virtual_machine_completion(%struct.multiple_error* %0, %struct.vm_err* %1, %struct.multiple_ir* %2, %struct.virtual_machine_startup* %3, i32 %4, %struct.multiple_stub_function_list* %5, i8* %6) {
%8 = alloca %struct.multiple_error*
%9 = alloca %struct.vm_err*
%10 = alloca %struct.multiple_ir*
%11 = alloca %struct.virtual_machine_startup*
%12 = alloca i32
%13 = alloca %struct.multiple_stub_function_list*
%14 = alloca i8*
%15 = alloca i64
store %struct.multiple_error* %0, %struct.multiple_error** %8
store %struct.vm_err* %1, %struct.vm_err** %9
store %struct.multiple_ir* %2, %struct.multiple_ir** %10
store %struct.virtual_machine_startup* %3, %struct.virtual_machine_startup** %11
store i32 %4, i32* %12
store %struct.multiple_stub_function_list* %5, %struct.multiple_stub_function_list** %13
store i8* %6, i8** %14
%16 = load %struct.vm_err*, %struct.vm_err** %9
%17 = load %struct.multiple_ir*, %struct.multiple_ir** %10
%18 = load %struct.virtual_machine_startup*, %struct.virtual_machine_startup** %11
%19 = load i32, i32* %12
%20 = load %struct.multiple_stub_function_list*, %struct.multiple_stub_function_list** %13
%21 = load i8*, i8** %14
%22 = call i64 @strlen(i8* %21)
store i64 %22, i64* %15
%23 = load i64, i64* %15
%24 = icmp eq i64 %23, 7
br i1 %24, label %25, label %33
25: ; preds = %7
%26 = load i8*, i8** %14
%27 = load i64, i64* %15
%28 = call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load %struct.multiple_error*, %struct.multiple_error** %8
%32 = call i32 @vm_completion_lib_dir(%struct.multiple_error* %31)
br label %33
33: ; preds = %30, %25, %7
ret i32 0
}

LLVM IR (-O2):
%struct.multiple_error = type { i32 }
%struct.vm_err = type { i32 }
%struct.multiple_ir = type { i32 }
%struct.virtual_machine_startup = type { i32 }
%struct.multiple_stub_function_list = type { i32 }
@.str = [8 x i8] c"lib-dir\00"
define i32 @virtual_machine_completion(%struct.multiple_error* %0, %struct.vm_err* nocapture readnone %1, %struct.multiple_ir* nocapture readnone %2, %struct.virtual_machine_startup* nocapture readnone %3, i32 %4, %struct.multiple_stub_function_list* nocapture readnone %5, i8* %6) {
%8 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%9 = icmp eq i64 %8, 7
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @vm_completion_lib_dir(%struct.multiple_error* %0)
br label %15
15: ; preds = %13, %10, %7
ret i32 0
}