#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 */
struct TYPE_3__ {
  int rm_eo;
  int rm_so;
};
typedef TYPE_1__ regmatch_t;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int rx_match_to_int(const char *source, regmatch_t match) {
  char buf[1024];
  int length = match.rm_eo - match.rm_so;
  strncpy(buf, source + match.rm_so, length);
  buf[length] = 0;
  return atoi(buf);
}


x86 assembly (clang, -O0):
<rx_match_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rsi,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
add    %rax,%rsi
mov    -0x414(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
call   1040 <atoi@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rx_match_to_int>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rax
shr    $0x20,%rax
mov    %esi,%ebx
sub    %eax,%ebx
sar    $0x20,%rsi
add    %rdi,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1040 <atoi@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @rx_match_to_int(i8* %0, i64 %1) {
%3 = alloca %struct.TYPE_3__
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = bitcast %struct.TYPE_3__* %3 to i64*
store i64 %1, i64* %7
store i8* %0, i8** %4
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
%11 = load i32, i32* %10
%12 = sub nsw i32 %9, %11
store i32 %12, i32* %6
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %4
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 1
%16 = load i32, i32* %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i32, i32* %6
%20 = call i32 @strncpy(i8* %13, i8* %18, i32 %19)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %22
store i8 0, i8* %23
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @atoi(i8* %24)
ret i32 %25
}

LLVM IR (-O2):
define i32 @rx_match_to_int(i8* %0, i64 %1) {
%3 = alloca [1024 x i8]
%4 = trunc i64 %1 to i32
%5 = lshr i64 %1, 32
%6 = trunc i64 %5 to i32
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = sub nsw i32 %4, %6
%9 = ashr i64 %1, 32
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = call i32 @strncpy(i8* %7, i8* %10, i32 %8)
%12 = sext i32 %8 to i64
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %12
store i8 0, i8* %13
%14 = call i32 @atoi(i8* %7)
ret i32 %14
}