#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*/ exit(int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void Walley_Print_Error(char *input_str, char *error_message,
                        int error_start_index) {
  printf("Error.. %s\n", error_message);
  printf("%s\n", input_str);
  char *empty = (char *)malloc(sizeof(char) * (error_start_index + 2));
  strcpy(empty, "");
  int i = 0;
  for (; i < error_start_index; i++) {
    empty[i] = ' ';
  }
  strcat(empty, "^");
  empty[error_start_index + 1] = 0;
  printf("%s\n", empty);
  exit(0);
}


x86 assembly (clang, -O0):
<Walley_Print_Error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d7 <Walley_Print_Error+0x87>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b1 <Walley_Print_Error+0x61>
mov    -0x20(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<Walley_Print_Error>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rdi,%rbx
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0x2(%r14),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
test   %r14d,%r14d
jle    11b5 <Walley_Print_Error+0x55>
mov    %r14d,%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <memset@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
movslq %r14d,%rax
movb   $0x0,0x1(%rax,%rbx,1)
lea    0xe35(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Error.. %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"^\00"
define void @Walley_Print_Error(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 2
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %22
22: ; preds = %31, %3
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = load i8*, i8** %7
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 32, i8* %30
br label %31
31: ; preds = %26
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %22
34: ; preds = %22
%35 = load i8*, i8** %7
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = load i8*, i8** %7
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %7
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [12 x i8] c"Error.. %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"^\00"
define void @Walley_Print_Error(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = add nsw i32 %2, 2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = zext i32 %2 to i64
br label %13
13: ; preds = %11, %3
%14 = tail call i32 @strcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = add nsw i32 %2, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %8, i64 %16
store i8 0, i8* %17
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%19 = tail call i32 @exit(i32 0)
unreachable
}