#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 intval[BUFSIZ];
    for (int i = 1; ((cursor = regex(cintre, cursor, intval)) != NULL); i++) {
      printf("argv[%d]=%s, intval=%s\n", i, argv[arg], intval);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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    124e <main+0x11e>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x50(%rbp),%rdx
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <regex@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1239 <main+0x109>
mov    -0x50(%rbp),%rcx
mov    -0x44(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rdx
mov    (%rax,%rdx,8),%rdx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11eb <main+0xbb>
mov    -0x38(%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,%r12
mov    %edi,%r14d
lea    0xea2(%rip),%rdi
xor    %esi,%esi
call   1050 <regcmp@plt>
mov    %rax,%rbx
test   %rax,%rax
lea    0xed5(%rip),%rax
lea    0xeb9(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
cmp    $0x2,%r14d
jl     1238 <main+0xf8>
mov    %r14d,%eax
mov    %rax,-0x40(%rbp)
mov    $0x1,%eax
mov    %rbx,-0x30(%rbp)
jmp    11ba <main+0x7a>
xchg   %ax,%ax
mov    -0x48(%rbp),%rsp
mov    -0x38(%rbp),%rax
add    $0x1,%rax
cmp    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rbx
je     1238 <main+0xf8>
mov    %rax,-0x38(%rbp)
mov    %rsp,-0x48(%rbp)
mov    (%r12,%rax,8),%rsi
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rbx,%rdi
mov    %r13,%rdx
call   1030 <regex@plt>
test   %rax,%rax
lea    0xe25(%rip),%r14
je     11a0 <main+0x60>
mov    %rax,%rbx
mov    $0x1,%r15d
mov    -0x38(%rbp),%rax
mov    (%r12,%rax,8),%rdx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r15d
mov    -0x30(%rbp),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <regex@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1200 <main+0xc0>
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 = [24 x i8] c"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 i64
%12 = 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
%13 = load i8*, i8** %6
%14 = call i8* @regcmp(i8* %13, i32* null)
store i8* %14, i8** %7
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
store i32 1, i32* %8
br label %21
21: ; preds = %53, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %56
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
store i8* %30, i8** %9
%31 = load i32, i32* @BUFSIZ
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %10
%34 = alloca i8, i64 %32
store i64 %32, i64* %11
store i32 1, i32* %12
br label %35
35: ; preds = %48, %25
%36 = load i8*, i8** %7
%37 = load i8*, i8** %9
%38 = call i8* @regex(i8* %36, i8* %37, i8* %34)
store i8* %38, i8** %9
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %51
40: ; preds = %35
%41 = load i32, i32* %12
%42 = load i8**, i8*** %5
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %41, i8* %46, i8* %34)
br label %48
48: ; preds = %40
%49 = load i32, i32* %12
%50 = add nsw i32 %49, 1
store i32 %50, i32* %12
br label %35
51: ; preds = %35
%52 = load i8*, i8** %10
br label %53
53: ; preds = %51
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %21
56: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"^[ \09]*([+-]{0,1}[0-9]+)$0\00"
@BUFSIZ = global i32 0
@.str.3 = [24 x i8] c"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 = %21, %2
ret i32 0
11: ; preds = %8, %21
%12 = phi i64 [ 1, %8 ], [ %22, %21 ]
%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 %21, label %24
21: ; preds = %24, %11
%22 = add nuw nsw i64 %12, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %10, label %11
24: ; preds = %11, %24
%25 = phi i8* [ %30, %24 ], [ %19, %11 ]
%26 = phi i32 [ %29, %24 ], [ 1, %11 ]
%27 = load i8*, i8** %13
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %26, i8* %27, i8* %18)
%29 = add nuw nsw i32 %26, 1
%30 = call i8* @regex(i8* %3, i8* %25, i8* %18)
%31 = icmp eq i8* %30, null
br i1 %31, label %21, label %24
}