#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__ {
  scalar_t__ re_nsub;
};
typedef TYPE_2__ regex_t;

/* Variables and functions */
int /*<<< orphan*/ addchars(char const *, int);
int /*<<< orphan*/ warnx(char *, int);
void add_sub(int n, const char *string, regex_t *re, regmatch_t *pm) {
  if (n > (int)re->re_nsub)
    warnx("No subexpression %d", 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    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
cmp    %ecx,%eax
jle    115d <add_sub+0x3d>
mov    -0x4(%rbp),%esi
lea    0xead(%rip),%rdi
call   1030 <warnx@plt>
jmp    11b6 <add_sub+0x96>
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,8)
je     11b1 <add_sub+0x91>
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmpl   $0xffffffff,0x4(%rax,%rcx,8)
je     11b1 <add_sub+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
movslq (%rax,%rcx,8),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%esi
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
sub    (%rax,%rcx,8),%esi
call   1040 <addchars@plt>
jmp    11b6 <add_sub+0x96>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_sub>:
mov    %edi,%eax
cmp    %edi,(%rdx)
jge    1134 <add_sub+0x14>
lea    0xed3(%rip),%rdi
mov    %eax,%esi
jmp    1030 <warnx@plt>
cltq
movslq (%rcx,%rax,8),%rdx
cmp    $0xffffffffffffffff,%rdx
je     1158 <add_sub+0x38>
mov    0x4(%rcx,%rax,8),%eax
cmp    $0xffffffff,%eax
je     1158 <add_sub+0x38>
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 = [20 x i8] c"No subexpression %d\00"
define void @add_sub(i32 %0, i8* %1, %struct.TYPE_6__* %2, %struct.TYPE_5__* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.TYPE_6__*
%8 = alloca %struct.TYPE_5__*
store i32 %0, i32* %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 i32, i32* %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 = trunc i64 %12 to i32
%14 = icmp sgt i32 %9, %13
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = load i32, i32* %5
%17 = call i32 @warnx(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %59
18: ; preds = %4
%19 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %19, i64 %21
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %58
26: ; preds = %18
%27 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %27, i64 %29
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = icmp ne i32 %32, -1
br i1 %33, label %34, label %58
34: ; preds = %26
%35 = load i8*, i8** %6
%36 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i64 %38
%40 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %35, i64 %42
%44 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %44, i64 %46
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %47, i32 0, i32 1
%49 = load i32, i32* %48
%50 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %50, i64 %52
%54 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %53, i32 0, i32 0
%55 = load i32, i32* %54
%56 = sub nsw i32 %49, %55
%57 = call i32 @addchars(i8* %43, i32 %56)
br label %58
58: ; preds = %34, %26, %18
br label %59
59: ; preds = %58, %15
ret void
}

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