#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
void print_error(const char *raw, size_t error_location) {
  fprintf(stderr, "\n*** parse error ***\n\n");
  int this_line = 0, char_len = 0;
  size_t i, j, len = strlen(raw), error_location_line = 0;
  for (i = 0; i < len; i++) {
    if (i == error_location)
      this_line = 1;
    switch (raw[i]) {
    case '\r':
      char_len = 2;
      fprintf(stderr, "\\r");
      break;
    case '\n':
      char_len = 2;
      fprintf(stderr, "\\n\n");
      if (this_line)
        goto print;
      error_location_line = 0;
      continue;
    default:
      char_len = 1;
      fputc(raw[i], stderr);
      break;
    }
    if (!this_line)
      error_location_line += char_len;
  }
  fprintf(stderr, "[eof]\n");
print:
  for (j = 0; j < error_location_line; j++) {
    fputc(' ', stderr);
  }
  fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location);
}


x86 assembly (clang, -O0):
<print_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    127f <print_error+0x14f>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11a5 <print_error+0x75>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
sub    $0xa,%eax
je     11f6 <print_error+0xc6>
jmp    11c2 <print_error+0x92>
mov    -0x3c(%rbp),%eax
sub    $0xd,%eax
jne    1230 <print_error+0x100>
jmp    11d3 <print_error+0xa3>
movl   $0x2,-0x18(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1253 <print_error+0x123>
movl   $0x2,-0x18(%rbp)
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     1223 <print_error+0xf3>
jmp    1296 <print_error+0x166>
movq   $0x0,-0x38(%rbp)
jmp    126e <print_error+0x13e>
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    0x2d97(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1269 <print_error+0x139>
movslq -0x18(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    126e <print_error+0x13e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1182 <print_error+0x52>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    12d0 <print_error+0x1a0>
mov    0x2d2d(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1040 <fputc@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    129e <print_error+0x16e>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
lea    0xd3f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_error>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    %rdi,%r15
mov    0x2e97(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xead(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
je     11f7 <print_error+0xc7>
mov    %rax,%rbx
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    11a2 <print_error+0x72>
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r13d,%r13d
jne    120b <print_error+0xdb>
xor    %r12d,%r12d
add    $0x1,%r14
cmp    %r14,%rbx
je     11fa <print_error+0xca>
cmp    %r14,(%rsp)
mov    $0x1,%eax
cmove  %eax,%r13d
movsbl (%r15,%r14,1),%edi
cmp    $0xa,%edi
je     1180 <print_error+0x50>
cmp    $0xd,%edi
jne    11e0 <print_error+0xb0>
mov    0x0(%rbp),%edi
lea    0xe4f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x2,%eax
test   %r13d,%r13d
jne    1199 <print_error+0x69>
jmp    11f2 <print_error+0xc2>
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%esi
call   1040 <fputc@plt>
mov    $0x1,%eax
test   %r13d,%r13d
jne    1199 <print_error+0x69>
add    %rax,%r12
jmp    1199 <print_error+0x69>
xor    %r12d,%r12d
mov    0x0(%rbp),%edi
lea    0xe1a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r12,%r12
je     1223 <print_error+0xf3>
mov    0x0(%rbp),%esi
mov    $0x20,%edi
call   1040 <fputc@plt>
add    $0xffffffffffffffff,%r12
jne    1210 <print_error+0xe0>
mov    0x0(%rbp),%edi
lea    0xdf8(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"\0A*** parse error ***\0A\0A\00"
@.str.1 = [3 x i8] c"\\r\00"
@.str.2 = [4 x i8] c"\\n\0A\00"
@.str.3 = [7 x i8] c"[eof]\0A\00"
@.str.4 = [23 x i8] c"^\0A\0Aerror location: %u\0A\00"
define void @print_error(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
store i32 0, i32* %6
%13 = load i8*, i8** %3
%14 = call i64 @strlen(i8* %13)
store i64 %14, i64* %9
store i64 0, i64* %10
store i64 0, i64* %7
br label %15
15: ; preds = %56, %2
%16 = load i64, i64* %7
%17 = load i64, i64* %9
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %59
19: ; preds = %15
%20 = load i64, i64* %7
%21 = load i64, i64* %4
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %5
br label %24
24: ; preds = %23, %19
%25 = load i8*, i8** %3
%26 = load i64, i64* %7
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
switch i32 %29, label %40 [
i32 13, label %30
i32 10, label %33
]
30: ; preds = %24
store i32 2, i32* %6
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %47
33: ; preds = %24
store i32 2, i32* %6
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* %5
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
br label %62
39: ; preds = %33
store i64 0, i64* %10
br label %56
40: ; preds = %24
store i32 1, i32* %6
%41 = load i8*, i8** %3
%42 = load i64, i64* %7
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* @stderr
%46 = call i32 @fputc(i8 signext %44, i32 %45)
br label %47
47: ; preds = %40, %30
%48 = load i32, i32* %5
%49 = icmp ne i32 %48, 0
br i1 %49, label %55, label %50
50: ; preds = %47
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = load i64, i64* %10
%54 = add i64 %53, %52
store i64 %54, i64* %10
br label %55
55: ; preds = %50, %47
br label %56
56: ; preds = %55, %39
%57 = load i64, i64* %7
%58 = add i64 %57, 1
store i64 %58, i64* %7
br label %15
59: ; preds = %15
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %59, %38
store i64 0, i64* %8
br label %63
63: ; preds = %70, %62
%64 = load i64, i64* %8
%65 = load i64, i64* %10
%66 = icmp ult i64 %64, %65
br i1 %66, label %67, label %73
67: ; preds = %63
%68 = load i32, i32* @stderr
%69 = call i32 @fputc(i8 signext 32, i32 %68)
br label %70
70: ; preds = %67
%71 = load i64, i64* %8
%72 = add i64 %71, 1
store i64 %72, i64* %8
br label %63
73: ; preds = %63
%74 = load i32, i32* @stderr
%75 = load i64, i64* %4
%76 = trunc i64 %75 to i32
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %76)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"\0A*** parse error ***\0A\0A\00"
@.str.1 = [3 x i8] c"\\r\00"
@.str.2 = [4 x i8] c"\\n\0A\00"
@.str.3 = [7 x i8] c"[eof]\0A\00"
@.str.4 = [23 x i8] c"^\0A\0Aerror location: %u\0A\00"
define void @print_error(i8* nocapture %0, i64 %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %35, label %7
7: ; preds = %2, %31
%8 = phi i64 [ %32, %31 ], [ 0, %2 ]
%9 = phi i32 [ %12, %31 ], [ 0, %2 ]
%10 = phi i64 [ %33, %31 ], [ 0, %2 ]
%11 = icmp eq i64 %10, %1
%12 = select i1 %11, i32 1, i32 %9
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %23 [
i32 13, label %16
i32 10, label %19
]
16: ; preds = %7
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %26
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %12, 0
br i1 %22, label %31, label %39
23: ; preds = %7
%24 = load i32, i32* @stderr
%25 = tail call i32 @fputc(i8 signext %14, i32 %24)
br label %26
26: ; preds = %23, %16
%27 = phi i64 [ 1, %23 ], [ 2, %16 ]
%28 = icmp eq i32 %12, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = add i64 %27, %8
br label %31
31: ; preds = %19, %26, %29
%32 = phi i64 [ %8, %26 ], [ %30, %29 ], [ 0, %19 ]
%33 = add nuw i64 %10, 1
%34 = icmp eq i64 %33, %5
br i1 %34, label %35, label %7
35: ; preds = %31, %2
%36 = phi i64 [ 0, %2 ], [ %32, %31 ]
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %19, %35
%40 = phi i64 [ %36, %35 ], [ %8, %19 ]
%41 = icmp eq i64 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %39, %42
%43 = phi i64 [ %46, %42 ], [ 0, %39 ]
%44 = load i32, i32* @stderr
%45 = tail call i32 @fputc(i8 signext 32, i32 %44)
%46 = add nuw i64 %43, 1
%47 = icmp eq i64 %46, %40
br i1 %47, label %48, label %42
48: ; preds = %42, %39
%49 = load i32, i32* @stderr
%50 = trunc i64 %1 to i32
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %50)
ret void
}