#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int rm_so;
  int rm_eo;
};
typedef TYPE_1__ regmatch_t;
struct TYPE_6__ {
  size_t re_nsub;
};
typedef TYPE_2__ regex_t;

/* Variables and functions */
int /*<<< orphan*/ addchars(char const *, int);
int /*<<< orphan*/ warnx(char *, size_t);
void add_sub(size_t n, const char *string, regex_t *re, regmatch_t *pm) {
  if (n > re->re_nsub)
    warnx("No subexpression %zu", n);
  else if (pm[n].rm_so != -1 && pm[n].rm_eo != -1) {
    addchars(string + pm[n].rm_so, pm[n].rm_eo - pm[n].rm_so);
  }
}


x86 assembly (clang, -O0):
<add_sub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jbe    115e <add_sub+0x3e>
mov    -0x8(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <warnx@plt>
jmp    11b7 <add_sub+0x97>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,8)
je     11b2 <add_sub+0x92>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmpl   $0xffffffff,0x4(%rax,%rcx,8)
je     11b2 <add_sub+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq (%rax,%rcx,8),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%esi
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    (%rax,%rcx,8),%esi
call   1040 <addchars@plt>
jmp    11b7 <add_sub+0x97>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_sub>:
mov    %rdi,%rax
cmp    %rdi,(%rdx)
jae    1137 <add_sub+0x17>
lea    0xed1(%rip),%rdi
mov    %rax,%rsi
jmp    1030 <warnx@plt>
movslq (%rcx,%rax,8),%rdx
cmp    $0xffffffffffffffff,%rdx
je     1159 <add_sub+0x39>
mov    0x4(%rcx,%rax,8),%eax
cmp    $0xffffffff,%eax
je     1159 <add_sub+0x39>
add    %rdx,%rsi
sub    %edx,%eax
mov    %rsi,%rdi
mov    %eax,%esi
jmp    1040 <addchars@plt>
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i64 }
%struct.TYPE_5__ = type { i32, i32 }
@.str = [21 x i8] c"No subexpression %zu\00"
define void @add_sub(i64 %0, i8* %1, %struct.TYPE_6__* %2, %struct.TYPE_5__* %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca %struct.TYPE_6__*
%8 = alloca %struct.TYPE_5__*
store i64 %0, i64* %5
store i8* %1, i8** %6
store %struct.TYPE_6__* %2, %struct.TYPE_6__** %7
store %struct.TYPE_5__* %3, %struct.TYPE_5__** %8
%9 = load i64, i64* %5
%10 = load %struct.TYPE_6__*, %struct.TYPE_6__** %7
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i32 0, i32 0
%12 = load i64, i64* %11
%13 = icmp ugt i64 %9, %12
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i64, i64* %5
%16 = call i32 @warnx(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %15)
br label %53
17: ; preds = %4
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%19 = load i64, i64* %5
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i64 %19
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %52
24: ; preds = %17
%25 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%26 = load i64, i64* %5
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %25, i64 %26
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, -1
br i1 %30, label %31, label %52
31: ; preds = %24
%32 = load i8*, i8** %6
%33 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%34 = load i64, i64* %5
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %33, i64 %34
%36 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %32, i64 %38
%40 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%41 = load i64, i64* %5
%42 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %40, i64 %41
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %42, i32 0, i32 1
%44 = load i32, i32* %43
%45 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%46 = load i64, i64* %5
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %45, i64 %46
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %47, i32 0, i32 0
%49 = load i32, i32* %48
%50 = sub nsw i32 %44, %49
%51 = call i32 @addchars(i8* %39, i32 %50)
br label %52
52: ; preds = %31, %24, %17
br label %53
53: ; preds = %52, %14
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i64 }
%struct.TYPE_5__ = type { i32, i32 }
@.str = [21 x i8] c"No subexpression %zu\00"
define void @add_sub(i64 %0, i8* %1, %struct.TYPE_6__* nocapture %2, %struct.TYPE_5__* nocapture %3) {
%5 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %2, i64 0, i32 0
%6 = load i64, i64* %5
%7 = icmp ult i64 %6, %0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @warnx(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %23
10: ; preds = %4
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 %0, i32 0
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, -1
br i1 %13, label %23, label %14
14: ; preds = %10
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 %0, i32 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, -1
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = sext i32 %12 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %19
%21 = sub nsw i32 %16, %12
%22 = tail call i32 @addchars(i8* %20, i32 %21)
br label %23
23: ; preds = %10, %14, %18, %8
ret void
}