#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ string;
struct TYPE_3__ {
  int rm_eo;
  int rm_so;
};
typedef TYPE_1__ regmatch_t;

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int getConfigOptionArgument(char string[], char line[], regmatch_t *submatch) {
  int match_length;
  match_length = submatch[1].rm_eo - submatch[1].rm_so;
  if (sizeof(string) >= match_length) {
    match_length = sizeof(string) - 1;
  }
  strncpy(string, &line[submatch[1].rm_so], match_length);
  strcpy(string + match_length, "");
  return 0;
}


x86 assembly (clang, -O0):
<getConfigOptionArgument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    0xc(%rcx),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rcx
mov    $0x8,%eax
cmp    %rcx,%rax
jb     115e <getConfigOptionArgument+0x3e>
movl   $0x7,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq 0xc(%rax),%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getConfigOptionArgument>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x8(%rdx),%eax
movslq 0xc(%rdx),%rcx
sub    %ecx,%eax
cmp    $0x9,%eax
mov    $0x7,%ebp
cmovae %eax,%ebp
add    %rcx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rdi
add    %rbx,%rdi
lea    0xeaf(%rip),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [1 x i8] zeroinitializer
define i32 @getConfigOptionArgument(i8* %0, i8* %1, %struct.TYPE_3__* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.TYPE_3__*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.TYPE_3__* %2, %struct.TYPE_3__** %6
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i64 1
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i64 1
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = sub nsw i32 %11, %15
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = icmp uge i64 8, %18
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 7, i32* %7
br label %21
21: ; preds = %20, %3
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i64 1
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %23, i64 %28
%30 = load i32, i32* %7
%31 = call i32 @strncpy(i8* %22, i8* %29, i32 %30)
%32 = load i8*, i8** %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [1 x i8] zeroinitializer
define i32 @getConfigOptionArgument(i8* %0, i8* %1, %struct.TYPE_3__* nocapture %2) {
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 1, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 1, i32 1
%7 = load i32, i32* %6
%8 = sub nsw i32 %5, %7
%9 = icmp ult i32 %8, 9
%10 = select i1 %9, i32 7, i32 %8
%11 = sext i32 %7 to i64
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = tail call i32 @strncpy(i8* %0, i8* %12, i32 %10)
%14 = sext i32 %10 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = tail call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
ret i32 0
}