#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*/ msg;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getmsg(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "usage: squashml regex\n");
    exit(1);
  }
  regex_t preg;
  if (regcomp(&preg, argv[1], REG_EXTENDED)) {
    perror("regcomp");
    exit(1);
  }
  char msg[1024 * 256];
  while (!feof(stdin)) {
    getmsg(&preg, msg, sizeof(msg));
    printf("%s\n", msg);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b2 <main+0x42>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rdi
call   1050 <regcomp@plt>
cmp    $0x0,%rax
je     11ec <main+0x7c>
lea    0xe3a(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11f1 <main+0x81>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1214 <main+0xa4>
jmp    1241 <main+0xd1>
lea    -0x40020(%rbp),%rsi
lea    -0x14(%rbp),%rdi
mov    $0x40000,%edx
call   1030 <getmsg@plt>
lea    -0x40020(%rbp),%rsi
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
jmp    11f1 <main+0x81>
mov    -0x4(%rbp),%eax
add    $0x40020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40018,%rsp
cmp    $0x2,%edi
jne    1209 <main+0x99>
mov    0x8(%rsi),%rsi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rdi
call   1050 <regcomp@plt>
test   %rax,%rax
jne    1228 <main+0xb8>
mov    0x2e3a(%rip),%r12
mov    (%r12),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    11f8 <main+0x88>
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0xe53(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x40000,%edx
call   1030 <getmsg@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    (%r12),%edi
call   1070 <feof@plt>
test   %eax,%eax
je     11d0 <main+0x60>
xor    %eax,%eax
add    $0x40018,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xde8(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"usage: squashml regex\0A\00"
@REG_EXTENDED = global i32 0
@.str.1 = [8 x i8] c"regcomp\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [262144 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @REG_EXTENDED
%19 = call i64 @regcomp(i32* %6, i8* %17, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %14
br label %25
25: ; preds = %30, %24
%26 = load i32, i32* @stdin
%27 = call i32 @feof(i32 %26)
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = getelementptr inbounds [262144 x i8], [262144 x i8]* %7, i64 0, i64 0
%32 = call i32 @getmsg(i32* %6, i8* %31, i32 262144)
%33 = getelementptr inbounds [262144 x i8], [262144 x i8]* %7, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %25
35: ; preds = %25
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"usage: squashml regex\0A\00"
@REG_EXTENDED = global i32 0
@.str.1 = [8 x i8] c"regcomp\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [262144 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = bitcast i32* %3 to i8*
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* @REG_EXTENDED
%15 = call i64 @regcomp(i32* %3, i8* %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %10
%18 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %10
%21 = getelementptr inbounds [262144 x i8], [262144 x i8]* %4, i64 0, i64 0
%22 = load i32, i32* @stdin
%23 = call i32 @feof(i32 %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %20, %25
%26 = call i32 @getmsg(i32* %3, i8* %21, i32 262144)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%28 = load i32, i32* @stdin
%29 = call i32 @feof(i32 %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %25, label %31
31: ; preds = %25, %20
ret i32 0
}