#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__ {
  scalar_t__ rm_so;
  int rm_eo;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
scalar_t__ REG_NOERROR;
scalar_t__ REG_NOMATCH;
int /*<<< orphan*/ printf(char *, scalar_t__, int, char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
scalar_t__ regexec(int /*<<< orphan*/ *, char *, int, TYPE_1__ *,
                   int /*<<< orphan*/);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  regex_t re;
  regmatch_t mat[1];
  int exitcode = 1;
  if (setlocale(LC_ALL, "de_DE.ISO-8859-1") == NULL)
    puts("cannot set locale");
  else if (regcomp(&re, "[a-f]*", 0) != REG_NOERROR)
    puts("cannot compile expression \"[a-f]*\"");
  else if (regexec(&re, "abcdefCDEF", 1, mat, 0) == REG_NOMATCH)
    puts("no match");
  else {
    exitcode = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
    printf("match from %d to %d - %s\n", mat[0].rm_so, mat[0].rm_eo,
           exitcode ? "WRONG!" : "ok");
  }
  return exitcode;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x34(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1070 <setlocale@plt>
cmp    $0x0,%rax
jne    119d <main+0x4d>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
jmp    1267 <main+0x117>
lea    -0x14(%rbp),%rdi
lea    0xe7b(%rip),%rsi
xor    %edx,%edx
call   1050 <regcomp@plt>
mov    0x2e32(%rip),%rcx
cmp    (%rcx),%rax
je     11d0 <main+0x80>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
jmp    1262 <main+0x112>
lea    -0x30(%rbp),%rcx
lea    -0x14(%rbp),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1060 <regexec@plt>
mov    0x2ded(%rip),%rcx
cmp    (%rcx),%rax
jne    120d <main+0xbd>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
jmp    125d <main+0x10d>
mov    $0x1,%al
cmpq   $0x0,-0x30(%rbp)
mov    %al,-0x35(%rbp)
jne    1227 <main+0xd7>
cmpl   $0x6,-0x28(%rbp)
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x34(%rbp),%edi
lea    0xe3f(%rip),%rcx
lea    0xe31(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
jmp    1262 <main+0x112>
jmp    1267 <main+0x117>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1070 <setlocale@plt>
test   %rax,%rax
je     11cb <main+0x7b>
lea    0xead(%rip),%rsi
lea    0xc(%rsp),%rdi
xor    %edx,%edx
call   1050 <regcomp@plt>
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%rax
jne    11d4 <main+0x84>
lea    0xeb8(%rip),%rsi
lea    0xc(%rsp),%rdi
mov    $0x1,%ebx
lea    0x10(%rsp),%rcx
mov    $0x1,%edx
xor    %r8d,%r8d
call   1060 <regexec@plt>
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%rax
jne    11ed <main+0x9d>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
jmp    11e5 <main+0x95>
lea    0xe3f(%rip),%rdi
jmp    11db <main+0x8b>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    0x10(%rsp),%rsi
test   %rsi,%rsi
setne  %al
mov    0x18(%rsp),%edx
cmp    $0x6,%edx
setne  %cl
or     %al,%cl
movzbl %cl,%ebx
lea    0xe6d(%rip),%rax
lea    0xe6d(%rip),%rcx
test   %bl,%bl
cmovne %rax,%rcx
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
jmp    11e5 <main+0x95>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32 }
@LC_ALL = global i32 0
@.str = [17 x i8] c"de_DE.ISO-8859-1\00"
@.str.1 = [18 x i8] c"cannot set locale\00"
@.str.2 = [7 x i8] c"[a-f]*\00"
@REG_NOERROR = global i64 0
@.str.3 = [35 x i8] c"cannot compile expression \22[a-f]*\22\00"
@.str.4 = [11 x i8] c"abcdefCDEF\00"
@REG_NOMATCH = global i64 0
@.str.5 = [9 x i8] c"no match\00"
@.str.6 = [26 x i8] c"match from %d to %d - %s\0A\00"
@.str.7 = [7 x i8] c"WRONG!\00"
@.str.8 = [3 x i8] c"ok\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1 x %struct.TYPE_3__]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
%9 = load i32, i32* @LC_ALL
%10 = call i32* @setlocale(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %53
14: ; preds = %2
%15 = call i64 @regcomp(i32* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%16 = load i64, i64* @REG_NOERROR
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %52
20: ; preds = %14
%21 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %7, i64 0, i64 0
%22 = call i64 @regexec(i32* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 1, %struct.TYPE_3__* %21, i32 0)
%23 = load i64, i64* @REG_NOMATCH
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %51
27: ; preds = %20
%28 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %7, i64 0, i64 0
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %28, i32 0, i32 0
%30 = load i64, i64* %29
%31 = icmp ne i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %27
%33 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %7, i64 0, i64 0
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = icmp ne i32 %35, 6
br label %37
37: ; preds = %32, %27
%38 = phi i1 [ true, %27 ], [ %36, %32 ]
%39 = zext i1 %38 to i32
store i32 %39, i32* %8
%40 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %7, i64 0, i64 0
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 0
%42 = load i64, i64* %41
%43 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %7, i64 0, i64 0
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = load i32, i32* %8
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0)
%50 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 %42, i32 %45, i8* %49)
br label %51
51: ; preds = %37, %25
br label %52
52: ; preds = %51, %18
br label %53
53: ; preds = %52, %12
%54 = load i32, i32* %8
ret i32 %54
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32 }
@LC_ALL = global i32 0
@.str = [17 x i8] c"de_DE.ISO-8859-1\00"
@.str.1 = [18 x i8] c"cannot set locale\00"
@.str.2 = [7 x i8] c"[a-f]*\00"
@REG_NOERROR = global i64 0
@.str.3 = [35 x i8] c"cannot compile expression \22[a-f]*\22\00"
@.str.4 = [11 x i8] c"abcdefCDEF\00"
@REG_NOMATCH = global i64 0
@.str.5 = [9 x i8] c"no match\00"
@.str.6 = [26 x i8] c"match from %d to %d - %s\0A\00"
@.str.7 = [7 x i8] c"WRONG!\00"
@.str.8 = [3 x i8] c"ok\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [1 x %struct.TYPE_3__]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [1 x %struct.TYPE_3__]* %4 to i8*
%7 = load i32, i32* @LC_ALL
%8 = tail call i32* @setlocale(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %36
12: ; preds = %2
%13 = call i64 @regcomp(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%14 = load i64, i64* @REG_NOERROR
%15 = icmp eq i64 %13, %14
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %36
18: ; preds = %12
%19 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %4, i64 0, i64 0
%20 = call i64 @regexec(i32* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 1, %struct.TYPE_3__* %19, i32 0)
%21 = load i64, i64* @REG_NOMATCH
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %36
25: ; preds = %18
%26 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %4, i64 0, i64 0, i32 0
%27 = load i64, i64* %26
%28 = icmp ne i64 %27, 0
%29 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %4, i64 0, i64 0, i32 1
%30 = load i32, i32* %29
%31 = icmp ne i32 %30, 6
%32 = or i1 %28, %31
%33 = zext i1 %32 to i32
%34 = select i1 %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0)
%35 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 %27, i32 %30, i8* %34)
br label %36
36: ; preds = %16, %25, %23, %10
%37 = phi i32 [ 1, %10 ], [ 1, %16 ], [ 1, %23 ], [ %33, %25 ]
ret i32 %37
}