#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*/ puts(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int);
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.]]", (((1 << 1) << 1) << 1)) != 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    0x2e81(%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    1211 <do_test+0xc1>
lea    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x8,%edx
call   1050 <regcomp@plt>
cmp    $0x0,%rax
je     11c6 <do_test+0x76>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1211 <do_test+0xc1>
lea    -0x8(%rbp),%rdi
lea    0xe64(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1060 <regexec@plt>
cmp    $0x0,%rax
je     1201 <do_test+0xb1>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1211 <do_test+0xc1>
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    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1070 <setlocale@plt>
test   %rax,%rax
je     1193 <do_test+0x43>
lea    0xea7(%rip),%rsi
lea    0xc(%rsp),%rdi
mov    $0x8,%edx
call   1050 <regcomp@plt>
test   %rax,%rax
je     119c <do_test+0x4c>
lea    0xe95(%rip),%rdi
jmp    11c2 <do_test+0x72>
lea    0xe72(%rip),%rdi
jmp    11c2 <do_test+0x72>
lea    0xe92(%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     11d4 <do_test+0x84>
lea    0xe76(%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    11cc <do_test+0x7c>

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"
@.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 %20
8: ; preds = %0
%9 = call i64 @regcomp(i32* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = 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 %20
13: ; preds = %8
%14 = 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)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = 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 %20
18: ; preds = %13
%19 = call i32 @regfree(i32* %2)
store i32 0, i32* %1
br label %20
20: ; preds = %18, %16, %11, %6
%21 = load i32, i32* %1
ret i32 %21
}

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"
@.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 %20
8: ; preds = %0
%9 = call i64 @regcomp(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %20
13: ; preds = %8
%14 = 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)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %20
18: ; preds = %13
%19 = call i32 @regfree(i32* %1)
br label %20
20: ; preds = %18, %16, %11, %6
%21 = phi i32 [ 1, %6 ], [ 1, %11 ], [ 1, %16 ], [ 0, %18 ]
ret i32 %21
}