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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
int regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int main(void) {
  regex_t re;
  int n;
  n = regcomp(&re, "[a-bA-B]", (1 << 1));
  if (n != 0) {
    char buf[500];
    regerror(n, &re, buf, sizeof(buf));
    printf("regcomp failed: %s\n", buf);
    exit(1);
  }
  regfree(&re);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x2,%edx
call   1050 <regcomp@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11b9 <main+0x69>
mov    -0xc(%rbp),%edi
lea    -0x200(%rbp),%rdx
lea    -0x8(%rbp),%rsi
mov    $0x1f4,%ecx
call   1060 <regerror@plt>
lea    -0x200(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x8(%rbp),%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x210,%rsp
lea    0xea1(%rip),%rsi
lea    0xc(%rsp),%rdi
mov    $0x2,%edx
call   1050 <regcomp@plt>
test   %eax,%eax
jne    1187 <main+0x37>
lea    0xc(%rsp),%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbx
ret
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x1f4,%ecx
call   1060 <regerror@plt>
lea    0xe62(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"[a-bA-B]\00"
@.str.1 = [20 x i8] c"regcomp failed: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [500 x i8]
store i32 0, i32* %1
%5 = call i32 @regcomp(i32* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = load i32, i32* %3
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%11 = call i32 @regerror(i32 %9, i32* %2, i8* %10, i32 500)
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = call i32 @regfree(i32* %2)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"[a-bA-B]\00"
@.str.1 = [20 x i8] c"regcomp failed: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call i32 @regcomp(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%8 = call i32 @regerror(i32 %4, i32* %1, i8* %7, i32 500)
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 @regfree(i32* %1)
ret i32 0
}