#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 */
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ REG_NOSUB;
int /*<<< orphan*/ puts(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
scalar_t__ regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                   int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int do_test(void) {
  regex_t r;
  if (setlocale(LC_ALL, "cs_CZ.UTF-8") == NULL) {
    puts("setlocale failed");
    return 1;
  }
  if (regcomp(&r, "[[.ch.]]", REG_NOSUB) != 0) {
    puts("regcomp failed");
    return 1;
  }
  if (regexec(&r, "ch", 0, 0, 0) != 0) {
    puts("regexec failed");
    return 1;
  }
  regfree(&r);
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1070 <setlocale@plt>
cmp    $0x0,%rax
jne    118f <do_test+0x3f>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1215 <do_test+0xc5>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <regcomp@plt>
cmp    $0x0,%rax
je     11ca <do_test+0x7a>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1215 <do_test+0xc5>
lea    -0x8(%rbp),%rdi
lea    0xe60(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1060 <regexec@plt>
cmp    $0x0,%rax
je     1205 <do_test+0xb5>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1215 <do_test+0xc5>
lea    -0x8(%rbp),%rdi
call   1040 <regfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1070 <setlocale@plt>
test   %rax,%rax
je     1197 <do_test+0x47>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
lea    0xe9e(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1050 <regcomp@plt>
test   %rax,%rax
je     11a0 <do_test+0x50>
lea    0xe91(%rip),%rdi
jmp    11c6 <do_test+0x76>
lea    0xe6e(%rip),%rdi
jmp    11c6 <do_test+0x76>
lea    0xe8e(%rip),%rsi
lea    0xc(%rsp),%rdi
xor    %ebx,%ebx
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
test   %rax,%rax
je     11d8 <do_test+0x88>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xc(%rsp),%rdi
call   1040 <regfree@plt>
jmp    11d0 <do_test+0x80>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [12 x i8] c"cs_CZ.UTF-8\00"
@.str.1 = [17 x i8] c"setlocale failed\00"
@.str.2 = [9 x i8] c"[[.ch.]]\00"
@REG_NOSUB = global i32 0
@.str.3 = [15 x i8] c"regcomp failed\00"
@.str.4 = [3 x i8] c"ch\00"
@.str.5 = [15 x i8] c"regexec failed\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @LC_ALL
%4 = call i32* @setlocale(i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %21
8: ; preds = %0
%9 = load i32, i32* @REG_NOSUB
%10 = call i64 @regcomp(i32* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %21
14: ; preds = %8
%15 = call i64 @regexec(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 0, i32 0)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %21
19: ; preds = %14
%20 = call i32 @regfree(i32* %2)
store i32 0, i32* %1
br label %21
21: ; preds = %19, %17, %12, %6
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [12 x i8] c"cs_CZ.UTF-8\00"
@.str.1 = [17 x i8] c"setlocale failed\00"
@.str.2 = [9 x i8] c"[[.ch.]]\00"
@REG_NOSUB = global i32 0
@.str.3 = [15 x i8] c"regcomp failed\00"
@.str.4 = [3 x i8] c"ch\00"
@.str.5 = [15 x i8] c"regexec failed\00"
define i32 @do_test() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @LC_ALL
%4 = tail call i32* @setlocale(i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %21
8: ; preds = %0
%9 = load i32, i32* @REG_NOSUB
%10 = call i64 @regcomp(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %21
14: ; preds = %8
%15 = call i64 @regexec(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 0, i32 0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %21
19: ; preds = %14
%20 = call i32 @regfree(i32* %1)
br label %21
21: ; preds = %19, %17, %12, %6
%22 = phi i32 [ 1, %6 ], [ 1, %12 ], [ 1, %17 ], [ 0, %19 ]
ret i32 %22
}