#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 */
scalar_t__ isdigit(char);
int /*<<< orphan*/ memmove(char *, char *, scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strstr(char *, char *);
void isql_norm_line_with_xxx(char *line) {
  char *frag;
  if (NULL != (frag = strstr(line, "parse error"))) {
    strcpy(frag, "parse error");
  } else if (NULL != (frag = strstr(line, "syntax error"))) {
    strcpy(frag, "parse error");
  }
  if (NULL != (frag = strstr(line, "at line "))) {
    char *tail = frag + 8;
    while (isdigit(tail[0]))
      tail++;
    while (' ' == (tail[0]))
      tail++;
    strcpy(frag, "at XXX ");
    memmove(frag + 7, tail, strlen(tail) + 1);
  }
  if (NULL != (frag = strstr(line, "at lines "))) {
    char *tail = frag + 9;
    while (isdigit(tail[0]))
      tail++;
    if ('-' == tail[0]) {
      tail++;
      while (isdigit(tail[0]))
        tail++;
    }
    while (' ' == (tail[0]))
      tail++;
    strcpy(frag, "at XXX ");
    memmove(frag + 7, tail, strlen(tail) + 1);
  }
}


x86 assembly (clang, -O0):
<isql_norm_line_with_xxx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1193 <isql_norm_line_with_xxx+0x43>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcpy@plt>
jmp    11ca <isql_norm_line_with_xxx+0x7a>
mov    -0x8(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     11c5 <isql_norm_line_with_xxx+0x75>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1040 <strcpy@plt>
jmp    11ca <isql_norm_line_with_xxx+0x7a>
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     128a <isql_norm_line_with_xxx+0x13a>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     121f <isql_norm_line_with_xxx+0xcf>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11f8 <isql_norm_line_with_xxx+0xa8>
jmp    1224 <isql_norm_line_with_xxx+0xd4>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jne    1249 <isql_norm_line_with_xxx+0xf9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1224 <isql_norm_line_with_xxx+0xd4>
mov    -0x10(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1060 <memmove@plt>
mov    -0x8(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1396 <isql_norm_line_with_xxx+0x246>
mov    -0x10(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     12df <isql_norm_line_with_xxx+0x18f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12b8 <isql_norm_line_with_xxx+0x168>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x2d,%eax
cmp    %ecx,%eax
jne    132b <isql_norm_line_with_xxx+0x1db>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1326 <isql_norm_line_with_xxx+0x1d6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12ff <isql_norm_line_with_xxx+0x1af>
jmp    132b <isql_norm_line_with_xxx+0x1db>
jmp    1330 <isql_norm_line_with_xxx+0x1e0>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x20,%eax
cmp    %ecx,%eax
jne    1355 <isql_norm_line_with_xxx+0x205>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1330 <isql_norm_line_with_xxx+0x1e0>
mov    -0x10(%rbp),%rdi
lea    0xcc2(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1060 <memmove@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isql_norm_line_with_xxx>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea1(%rip),%rsi
call   1070 <strstr@plt>
test   %rax,%rax
jne    117d <isql_norm_line_with_xxx+0x2d>
lea    0xe9c(%rip),%rsi
mov    %r14,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     118c <isql_norm_line_with_xxx+0x3c>
lea    0xe7c(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe86(%rip),%rsi
mov    %r14,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     1204 <isql_norm_line_with_xxx+0xb4>
mov    %rax,%r15
lea    0x6(%rax),%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x2(%rbx),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    11b0 <isql_norm_line_with_xxx+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     11d0 <isql_norm_line_with_xxx+0x80>
lea    0xe41(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
add    $0x7,%r15
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <memmove@plt>
lea    0xe1f(%rip),%rsi
mov    %r14,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     12a9 <isql_norm_line_with_xxx+0x159>
mov    %rax,%r14
lea    0x8(%rax),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1230 <isql_norm_line_with_xxx+0xe0>
cmpb   $0x2d,(%rbx)
jne    1262 <isql_norm_line_with_xxx+0x112>
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1250 <isql_norm_line_with_xxx+0x100>
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1270 <isql_norm_line_with_xxx+0x120>
lea    0xda1(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
add    $0x7,%r14
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <memmove@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"parse error\00"
@.str.1 = [13 x i8] c"syntax error\00"
@.str.2 = [9 x i8] c"at line \00"
@.str.3 = [8 x i8] c"at XXX \00"
@.str.4 = [10 x i8] c"at lines \00"
define void @isql_norm_line_with_xxx(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @strstr(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
%8 = icmp ne i8* null, %7
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %20
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %3
%15 = icmp ne i8* null, %14
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %12
br label %20
20: ; preds = %19, %9
%21 = load i8*, i8** %2
%22 = call i8* @strstr(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i8* %22, i8** %3
%23 = icmp ne i8* null, %22
br i1 %23, label %24, label %56
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 8
store i8* %26, i8** %4
br label %27
27: ; preds = %33, %24
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = call i64 @isdigit(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
br label %27
36: ; preds = %27
br label %37
37: ; preds = %43, %36
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 32, %41
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %4
br label %37
46: ; preds = %37
%47 = load i8*, i8** %3
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 7
%51 = load i8*, i8** %4
%52 = load i8*, i8** %4
%53 = call i64 @strlen(i8* %52)
%54 = add nsw i64 %53, 1
%55 = call i32 @memmove(i8* %50, i8* %51, i64 %54)
br label %56
56: ; preds = %46, %20
%57 = load i8*, i8** %2
%58 = call i8* @strstr(i8* %57, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i8* %58, i8** %3
%59 = icmp ne i8* null, %58
br i1 %59, label %60, label %111
60: ; preds = %56
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i64 9
store i8* %62, i8** %5
br label %63
63: ; preds = %69, %60
%64 = load i8*, i8** %5
%65 = getelementptr inbounds i8, i8* %64, i64 0
%66 = load i8, i8* %65
%67 = call i64 @isdigit(i8 signext %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %63
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %5
br label %63
72: ; preds = %63
%73 = load i8*, i8** %5
%74 = getelementptr inbounds i8, i8* %73, i64 0
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 45, %76
br i1 %77, label %78, label %91
78: ; preds = %72
%79 = load i8*, i8** %5
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %5
br label %81
81: ; preds = %87, %78
%82 = load i8*, i8** %5
%83 = getelementptr inbounds i8, i8* %82, i64 0
%84 = load i8, i8* %83
%85 = call i64 @isdigit(i8 signext %84)
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %81
%88 = load i8*, i8** %5
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %5
br label %81
90: ; preds = %81
br label %91
91: ; preds = %90, %72
br label %92
92: ; preds = %98, %91
%93 = load i8*, i8** %5
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 32, %96
br i1 %97, label %98, label %101
98: ; preds = %92
%99 = load i8*, i8** %5
%100 = getelementptr inbounds i8, i8* %99, i32 1
store i8* %100, i8** %5
br label %92
101: ; preds = %92
%102 = load i8*, i8** %3
%103 = call i32 @strcpy(i8* %102, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%104 = load i8*, i8** %3
%105 = getelementptr inbounds i8, i8* %104, i64 7
%106 = load i8*, i8** %5
%107 = load i8*, i8** %5
%108 = call i64 @strlen(i8* %107)
%109 = add nsw i64 %108, 1
%110 = call i32 @memmove(i8* %105, i8* %106, i64 %109)
br label %111
111: ; preds = %101, %56
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"parse error\00"
@.str.1 = [13 x i8] c"syntax error\00"
@.str.2 = [9 x i8] c"at line \00"
@.str.3 = [8 x i8] c"at XXX \00"
@.str.4 = [10 x i8] c"at lines \00"
define void @isql_norm_line_with_xxx(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4, %1
%8 = phi i8* [ %2, %1 ], [ %5, %4 ]
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %7, %4
%11 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %32, label %13
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %11, i64 8
br label %15
15: ; preds = %15, %13
%16 = phi i8* [ %14, %13 ], [ %20, %15 ]
%17 = load i8, i8* %16
%18 = tail call i64 @isdigit(i8 signext %17)
%19 = icmp eq i64 %18, 0
%20 = getelementptr inbounds i8, i8* %16, i64 1
br i1 %19, label %21, label %15
21: ; preds = %15, %21
%22 = phi i8* [ %25, %21 ], [ %16, %15 ]
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 32
%25 = getelementptr inbounds i8, i8* %22, i64 1
br i1 %24, label %21, label %26
26: ; preds = %21
%27 = tail call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds i8, i8* %11, i64 7
%29 = tail call i64 @strlen(i8* %22)
%30 = add nsw i64 %29, 1
%31 = tail call i32 @memmove(i8* %28, i8* %22, i64 %30)
br label %32
32: ; preds = %26, %10
%33 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %65, label %35
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %33, i64 9
br label %37
37: ; preds = %37, %35
%38 = phi i8* [ %36, %35 ], [ %42, %37 ]
%39 = load i8, i8* %38
%40 = tail call i64 @isdigit(i8 signext %39)
%41 = icmp eq i64 %40, 0
%42 = getelementptr inbounds i8, i8* %38, i64 1
br i1 %41, label %43, label %37
43: ; preds = %37
%44 = load i8, i8* %38
%45 = icmp eq i8 %44, 45
br i1 %45, label %46, label %52
46: ; preds = %43, %46
%47 = phi i8* [ %48, %46 ], [ %38, %43 ]
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = load i8, i8* %48
%50 = tail call i64 @isdigit(i8 signext %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %46
52: ; preds = %46, %43
%53 = phi i8* [ %38, %43 ], [ %48, %46 ]
br label %54
54: ; preds = %52, %54
%55 = phi i8* [ %58, %54 ], [ %53, %52 ]
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 32
%58 = getelementptr inbounds i8, i8* %55, i64 1
br i1 %57, label %54, label %59
59: ; preds = %54
%60 = tail call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%61 = getelementptr inbounds i8, i8* %33, i64 7
%62 = tail call i64 @strlen(i8* %55)
%63 = add nsw i64 %62, 1
%64 = tail call i32 @memmove(i8* %61, i8* %55, i64 %63)
br label %65
65: ; preds = %59, %32
ret void
}