#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 */
struct token {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ expandtab(char *, int, unsigned int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ update_token(struct token *, char, char *, char *,
                                int /*<<< orphan*/, int);
void parse_object(struct token *token, int *n_tabs, unsigned int tabstop) {
  char *value = malloc(512 * sizeof(char));
  *n_tabs += 1;
  value[0] = '{';
  value[1] = '\n';
  value[2] = '\0';
  if (*n_tabs > 0) {
    char tab_str[64];
    expandtab(tab_str, *n_tabs, tabstop);
    strncat(value, tab_str, 64);
  }
  update_token(token, '{', "\x1b[37m", value, 0, 1);
  free(value);
}


x86 assembly (clang, -O0):
<parse_object>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x7b,(%rax)
mov    -0x20(%rbp),%rax
movb   $0xa,0x1(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11c4 <parse_object+0x74>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
call   1070 <expandtab@plt>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1040 <strncat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x7b,%esi
lea    0xe28(%rip),%rdx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1050 <update_token@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_object>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r14
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    0x0(%rbp),%eax
lea    0x1(%rax),%esi
mov    %esi,0x0(%rbp)
movw   $0xa7b,(%rbx)
movb   $0x0,0x2(%rbx)
test   %eax,%eax
js     11a4 <parse_object+0x54>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15d,%edx
call   1070 <expandtab@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x40,%edx
call   1040 <strncat@plt>
lea    0xe55(%rip),%rdx
mov    %r14,%rdi
mov    $0x7b,%esi
mov    %rbx,%rcx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1050 <update_token@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.token = type { i32 }
@.str = [6 x i8] c"\1B[37m\00"
define void @parse_object(%struct.token* %0, i32* %1, i32 %2) {
%4 = alloca %struct.token*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [64 x i8]
store %struct.token* %0, %struct.token** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = call i8* @malloc(i32 512)
store i8* %9, i8** %7
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
store i32 %12, i32* %10
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i64 0
store i8 123, i8* %14
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 10, i8* %16
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 2
store i8 0, i8* %18
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %3
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%24 = load i32*, i32** %5
%25 = load i32, i32* %24
%26 = load i32, i32* %6
%27 = call i32 @expandtab(i8* %23, i32 %25, i32 %26)
%28 = load i8*, i8** %7
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%30 = call i32 @strncat(i8* %28, i8* %29, i32 64)
br label %31
31: ; preds = %22, %3
%32 = load %struct.token*, %struct.token** %4
%33 = load i8*, i8** %7
%34 = call i32 @update_token(%struct.token* %32, i8 signext 123, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %33, i32 0, i32 1)
%35 = load i8*, i8** %7
%36 = call i32 @free(i8* %35)
ret void
}

LLVM IR (-O2):
%struct.token = type { i32 }
@.str = [6 x i8] c"\1B[37m\00"
define void @parse_object(%struct.token* %0, i32* nocapture %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, 1
store i32 %7, i32* %1
store i8 123, i8* %5
%8 = getelementptr inbounds i8, i8* %5, i64 1
store i8 10, i8* %8
%9 = getelementptr inbounds i8, i8* %5, i64 2
store i8 0, i8* %9
%10 = icmp sgt i32 %6, -1
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%13 = call i32 @expandtab(i8* %12, i32 %7, i32 %2)
%14 = call i32 @strncat(i8* %5, i8* %12, i32 64)
br label %15
15: ; preds = %11, %3
%16 = call i32 @update_token(%struct.token* %0, i8 signext 123, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i32 0, i32 1)
%17 = call i32 @free(i8* %5)
ret void
}