#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 count_leading_whitespace(int);
int /*<<< orphan*/ errprint(char *);
int get_column_num(int);
char *get_line_from_index(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void print_location(int index) {
  char *line = get_line_from_index(index);
  putchar('\t');
  errprint(line);
  printf("\n\t");
  int i;
  for (i = 0; i < get_column_num(index) - count_leading_whitespace(index); i++)
    putchar(' ');
  printf("^\n");
}


x86 assembly (clang, -O0):
<print_location>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <get_line_from_index@plt>
mov    %rax,-0x10(%rbp)
mov    $0x9,%edi
call   1040 <putchar@plt>
mov    -0x10(%rbp),%rdi
call   1080 <errprint@plt>
lea    0xe6f(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <get_column_num@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <count_leading_whitespace@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%edx
mov    -0x18(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jge    11e0 <print_location+0x80>
mov    $0x20,%edi
call   1040 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119d <print_location+0x3d>
lea    0xe1c(%rip),%rdi
call   1060 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_location>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
call   1080 <get_line_from_index@plt>
mov    %rax,%r14
mov    $0x9,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1090 <errprint@plt>
lea    0xe65(%rip),%rdi
call   1070 <printf@plt>
mov    %r15d,%edi
call   1030 <get_column_num@plt>
mov    %eax,%ebp
mov    %r15d,%edi
call   1060 <count_leading_whitespace@plt>
cmp    %eax,%ebp
jle    11e5 <print_location+0x75>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1040 <putchar@plt>
add    $0x1,%ebx
mov    %r15d,%edi
call   1030 <get_column_num@plt>
mov    %eax,%ebp
mov    %r15d,%edi
call   1060 <count_leading_whitespace@plt>
sub    %eax,%ebp
cmp    %ebp,%ebx
jl     11c0 <print_location+0x50>
lea    0xe17(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <puts@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\09\00"
@.str.1 = [3 x i8] c"^\0A\00"
define void @print_location(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i8* @get_line_from_index(i32 %5)
store i8* %6, i8** %3
%7 = call i32 @putchar(i8 signext 9)
%8 = load i8*, i8** %3
%9 = call i32 @errprint(i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %11
11: ; preds = %21, %1
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = call i32 @get_column_num(i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @count_leading_whitespace(i32 %15)
%17 = sub nsw i32 %14, %16
%18 = icmp slt i32 %12, %17
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = call i32 @putchar(i8 signext 32)
br label %21
21: ; preds = %19
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %11
24: ; preds = %11
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\09\00"
@str = [2 x i8] c"^\00"
define void @print_location(i32 %0) {
%2 = tail call i8* @get_line_from_index(i32 %0)
%3 = tail call i32 @putchar(i8 signext 9)
%4 = tail call i32 @errprint(i8* %2)
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @get_column_num(i32 %0)
%7 = tail call i32 @count_leading_whitespace(i32 %0)
%8 = icmp sgt i32 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %1, %9
%10 = phi i32 [ %12, %9 ], [ 0, %1 ]
%11 = tail call i32 @putchar(i8 signext 32)
%12 = add nuw nsw i32 %10, 1
%13 = tail call i32 @get_column_num(i32 %0)
%14 = tail call i32 @count_leading_whitespace(i32 %0)
%15 = sub nsw i32 %13, %14
%16 = icmp slt i32 %12, %15
br i1 %16, label %9, label %17
17: ; preds = %9, %1
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}