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

/* Variables and functions */
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void badpat(char *message, char *source, char *stop) {
  fprintf(stderr, "-GREP-E-%s, pattern is\"%s\"\n", message, source);
  fprintf(stderr, "-GREP-E-Stopped at byte %d, '%c'\n", stop - source,
          stop[-1]);
  error("?GREP-E-Bad pattern\n");
}


x86 assembly (clang, -O0):
<badpat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
sub    %rax,%rdx
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%ecx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xeba(%rip),%rdi
call   1040 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<badpat>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rdx
mov    0x2eab(%rip),%r15
mov    (%r15),%edi
lea    0xec1(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
movsbl -0x1(%rbx),%ecx
sub    %r14,%rbx
lea    0xec2(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xed3(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <error@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"-GREP-E-%s, pattern is\22%s\22\0A\00"
@.str.1 = [34 x i8] c"-GREP-E-Stopped at byte %d, '%c'\0A\00"
@.str.2 = [21 x i8] c"?GREP-E-Bad pattern\0A\00"
define void @badpat(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = ptrtoint i8* %12 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 -1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %16, i32 %20)
%22 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"-GREP-E-%s, pattern is\22%s\22\0A\00"
@.str.1 = [34 x i8] c"-GREP-E-Stopped at byte %d, '%c'\0A\00"
@.str.2 = [21 x i8] c"?GREP-E-Bad pattern\0A\00"
define void @badpat(i8* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = load i32, i32* @stderr
%7 = ptrtoint i8* %2 to i64
%8 = ptrtoint i8* %1 to i64
%9 = sub i64 %7, %8
%10 = getelementptr inbounds i8, i8* %2, i64 -1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i64 %9, i32 %12)
%14 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
ret void
}