#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 *alloca(scalar_t__);
int hpgs_get_arg_value(char *, char const **, char const **, int *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
int get_dev_arg_value(const char *dev_name, int dev_name_len, const char *opt,
                      const char *argv[], const char **value, int *narg) {
  char *opt_name = alloca(4 + dev_name_len + strlen(opt));
  opt_name[1] = opt_name[0] = '-';
  memcpy(opt_name + 2, dev_name, dev_name_len);
  strcpy(&opt_name[2 + dev_name_len], opt);
  return hpgs_get_arg_value(opt_name, argv, value, narg);
}


x86 assembly (clang, -O0):
<get_dev_arg_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0x4,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
call   1050 <alloca@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x2d,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x2d,0x1(%rax)
mov    -0x38(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0x2,%eax
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1070 <hpgs_get_arg_value@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dev_arg_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r13
mov    %rdx,%rdi
call   1040 <strlen@plt>
movslq %ebp,%rbp
lea    (%rax,%rbp,1),%rdi
add    $0x4,%rdi
call   1050 <alloca@plt>
mov    %rax,%r14
movw   $0x2d2d,(%rax)
lea    0x2(%rax),%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1060 <memcpy@plt>
lea    (%r14,%rbp,1),%rdi
add    $0x2,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    (%rsp),%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <hpgs_get_arg_value@plt>

LLVM IR (-O0):
define i32 @get_dev_arg_value(i8* %0, i32 %1, i8* %2, i8** %3, i8** %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i32*
%13 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8** %3, i8*** %10
store i8** %4, i8*** %11
store i32* %5, i32** %12
%14 = load i32, i32* %8
%15 = add nsw i32 4, %14
%16 = sext i32 %15 to i64
%17 = load i8*, i8** %9
%18 = call i64 @strlen(i8* %17)
%19 = add nsw i64 %16, %18
%20 = call i8* @alloca(i64 %19)
store i8* %20, i8** %13
%21 = load i8*, i8** %13
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 45, i8* %22
%23 = load i8*, i8** %13
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 45, i8* %24
%25 = load i8*, i8** %13
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = load i8*, i8** %7
%28 = load i32, i32* %8
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
%30 = load i8*, i8** %13
%31 = load i32, i32* %8
%32 = add nsw i32 2, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = load i8*, i8** %9
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = load i8*, i8** %13
%38 = load i8**, i8*** %10
%39 = load i8**, i8*** %11
%40 = load i32*, i32** %12
%41 = call i32 @hpgs_get_arg_value(i8* %37, i8** %38, i8** %39, i32* %40)
ret i32 %41
}

LLVM IR (-O2):
define i32 @get_dev_arg_value(i8* %0, i32 %1, i8* %2, i8** %3, i8** %4, i32* %5) {
%7 = add nsw i32 %1, 4
%8 = sext i32 %7 to i64
%9 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%10 = add nsw i64 %9, %8
%11 = tail call i8* @alloca(i64 %10)
store i8 45, i8* %11
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8 45, i8* %12
%13 = getelementptr inbounds i8, i8* %11, i64 2
%14 = tail call i32 @memcpy(i8* %13, i8* %0, i32 %1)
%15 = add nsw i32 %1, 2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %11, i64 %16
%18 = tail call i32 @strcpy(i8* %17, i8* %2)
%19 = tail call i32 @hpgs_get_arg_value(i8* %11, i8** %3, i8** %4, i32* %5)
ret i32 %19
}