#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 */

/* Type definitions */

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ printf(char *, ...);
char *regcmp(char const *, int /*<<< orphan*/ *);
char *regex(char const *, char *, char *);
main(int argc, char **argv) {
  const char *intre = "^[ \t]*([+-]{0,1}[0-9]+)$0";
  const char *cintre = NULL;
  if ((cintre = regcmp(intre, NULL)) == NULL)
    printf("regcmp failed ...\n");
  else
    printf("regcmp succeeded ...\n");
  for (int arg = 1; arg < argc; arg++) {
    char *cursor = argv[arg];
    char *newcursor = NULL;
    char intval[BUFSIZ];
    for (int i = 1; ((newcursor = regex(cintre, cursor, intval)) != NULL);
         i++) {
      printf("%d: argv[%d]=%s, intval=<%s>\n", i, arg, argv[arg], intval);
      cursor = newcursor;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <regcmp@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1187 <main+0x57>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1195 <main+0x65>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1261 <main+0x131>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x58(%rbp),%rdx
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <regex@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     124c <main+0x11c>
mov    -0x58(%rbp),%r8
mov    -0x4c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11f3 <main+0xc3>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119c <main+0x6c>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %edi,%ebx
lea    0xea3(%rip),%rdi
xor    %esi,%esi
call   1050 <regcmp@plt>
mov    %rax,%r15
test   %rax,%rax
lea    0xedc(%rip),%rax
lea    0xec0(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebx
jl     1249 <main+0x109>
mov    %ebx,%eax
mov    %rax,-0x40(%rbp)
mov    $0x1,%eax
mov    %r15,-0x30(%rbp)
jmp    11ba <main+0x7a>
nopl   0x0(%rax,%rax,1)
mov    -0x48(%rbp),%rsp
mov    -0x38(%rbp),%rax
add    $0x1,%rax
cmp    -0x40(%rbp),%rax
mov    -0x30(%rbp),%r15
je     1249 <main+0x109>
mov    %rax,-0x38(%rbp)
mov    %rsp,-0x48(%rbp)
mov    0x0(%r13,%rax,8),%rsi
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r15,%rdi
mov    %rbx,%rdx
call   1030 <regex@plt>
test   %rax,%rax
lea    0xe24(%rip),%r15
je     11a0 <main+0x60>
mov    %rax,%r12
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%rdx
mov    0x0(%r13,%rdx,8),%rcx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%r8
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r14d
mov    -0x30(%rbp),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <regex@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1210 <main+0xd0>
jmp    11a0 <main+0x60>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"^[ \09]*([+-]{0,1}[0-9]+)$0\00"
@.str.1 = [19 x i8] c"regcmp failed ...\0A\00"
@.str.2 = [22 x i8] c"regcmp succeeded ...\0A\00"
@BUFSIZ = global i32 0
@.str.3 = [30 x i8] c"%d: argv[%d]=%s, intval=<%s>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* null, i8** %7
%14 = load i8*, i8** %6
%15 = call i8* @regcmp(i8* %14, i32* null)
store i8* %15, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
store i32 1, i32* %8
br label %22
22: ; preds = %56, %21
%23 = load i32, i32* %8
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %59
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
store i8* %31, i8** %9
store i8* null, i8** %10
%32 = load i32, i32* @BUFSIZ
%33 = zext i32 %32 to i64
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %11
%35 = alloca i8, i64 %33
store i64 %33, i64* %12
store i32 1, i32* %13
br label %36
36: ; preds = %51, %26
%37 = load i8*, i8** %7
%38 = load i8*, i8** %9
%39 = call i8* @regex(i8* %37, i8* %38, i8* %35)
store i8* %39, i8** %10
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %54
41: ; preds = %36
%42 = load i32, i32* %13
%43 = load i32, i32* %8
%44 = load i8**, i8*** %5
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 %43, i8* %48, i8* %35)
%50 = load i8*, i8** %10
store i8* %50, i8** %9
br label %51
51: ; preds = %41
%52 = load i32, i32* %13
%53 = add nsw i32 %52, 1
store i32 %53, i32* %13
br label %36
54: ; preds = %36
%55 = load i8*, i8** %11
br label %56
56: ; preds = %54
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %22
59: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"^[ \09]*([+-]{0,1}[0-9]+)$0\00"
@BUFSIZ = global i32 0
@.str.3 = [30 x i8] c"%d: argv[%d]=%s, intval=<%s>\0A\00"
@str = [21 x i8] c"regcmp succeeded ...\00"
@str.4 = [18 x i8] c"regcmp failed ...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i8* @regcmp(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32* null)
%4 = icmp eq i8* %3, null
%5 = select i1 %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) %5)
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %11
10: ; preds = %23, %2
ret i32 0
11: ; preds = %8, %23
%12 = phi i64 [ 1, %8 ], [ %24, %23 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = load i32, i32* @BUFSIZ
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
%18 = alloca i8, i64 %16
%19 = call i8* @regex(i8* %3, i8* %14, i8* %18)
%20 = icmp eq i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %11
%22 = trunc i64 %12 to i32
br label %26
23: ; preds = %26, %11
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %10, label %11
26: ; preds = %21, %26
%27 = phi i8* [ %32, %26 ], [ %19, %21 ]
%28 = phi i32 [ %31, %26 ], [ 1, %21 ]
%29 = load i8*, i8** %13
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %22, i8* %29, i8* %18)
%31 = add nuw nsw i32 %28, 1
%32 = call i8* @regex(i8* %3, i8* %27, i8* %18)
%33 = icmp eq i8* %32, null
br i1 %33, label %23, label %26
}