#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_so;
  int rm_eo;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int get_int_substr(const char *str, const regmatch_t *p) {
  char buff[256];
  if (p->rm_so == -1)
    return 0;
  if (p->rm_eo - p->rm_so >= sizeof(buff))
    return 0;
  memcpy(buff, str + p->rm_so, p->rm_eo - p->rm_so);
  buff[p->rm_eo - p->rm_so] = 0;
  return atoi(buff);
}


x86 assembly (clang, -O0):
<get_int_substr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    114c <get_int_substr+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <get_int_substr+0xa0>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%eax
cltq
cmp    $0x100,%rax
jb     1173 <get_int_substr+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <get_int_substr+0xa0>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x18(%rbp),%rax
sub    (%rax),%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%eax
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
lea    -0x120(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int_substr>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
movslq (%rsi),%rcx
xor    %eax,%eax
cmp    $0xffffffffffffffff,%rcx
je     116c <get_int_substr+0x4c>
mov    0x4(%rbx),%edx
sub    %ecx,%edx
cmp    $0xff,%edx
ja     116c <get_int_substr+0x4c>
mov    %rdi,%rsi
add    %rcx,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <memcpy@plt>
movslq 0x4(%rbx),%rax
movslq (%rbx),%rcx
sub    %rcx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
call   1040 <atoi@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @get_int_substr(i8* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.TYPE_3__*
%6 = alloca [256 x i8]
store i8* %0, i8** %4
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %5
%7 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %50
12: ; preds = %2
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = sub nsw i32 %15, %18
%20 = sext i32 %19 to i64
%21 = icmp uge i64 %20, 256
br i1 %21, label %22, label %23
22: ; preds = %12
store i32 0, i32* %3
br label %50
23: ; preds = %12
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%25 = load i8*, i8** %4
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
%31 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %31, i32 0, i32 1
%33 = load i32, i32* %32
%34 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = sub nsw i32 %33, %36
%38 = call i32 @memcpy(i8* %24, i8* %30, i32 %37)
%39 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %39, i32 0, i32 1
%41 = load i32, i32* %40
%42 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%43 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = sub nsw i32 %41, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %46
store i8 0, i8* %47
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %3
br label %50
50: ; preds = %23, %22, %11
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @get_int_substr(i8* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, -1
br i1 %7, label %23, label %8
8: ; preds = %2
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = sub nsw i32 %10, %6
%12 = icmp ugt i32 %11, 255
br i1 %12, label %23, label %13
13: ; preds = %8
%14 = sext i32 %6 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = call i32 @memcpy(i8* %4, i8* %15, i32 %11)
%17 = load i32, i32* %9
%18 = load i32, i32* %5
%19 = sub nsw i32 %17, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 @atoi(i8* %4)
br label %23
23: ; preds = %8, %2, %13
%24 = phi i32 [ %22, %13 ], [ 0, %2 ], [ 0, %8 ]
ret i32 %24
}