#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 strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ update_token(struct token *, char, char *, char *, int,
                                int /*<<< orphan*/);
void parse_object_close(struct token *token, int *n_tabs,
                        unsigned int tabstop) {
  char *value = malloc(512 * sizeof(char));
  *n_tabs -= 1;
  value[0] = '\n';
  value[1] = '\0';
  if (*n_tabs > 0) {
    char tab_str[64];
    expandtab(tab_str, *n_tabs, tabstop);
    strncat(value, tab_str, 64);
  }
  char to_append[2] = {'}', '\0'};
  strncat(value, to_append, strlen(to_append));
  update_token(token, '}', "\x1b[37m", value, 1, 0);
  free(value);
}


x86 assembly (clang, -O0):
<parse_object_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x200,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11cf <parse_object_close+0x6f>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
call   1080 <expandtab@plt>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1050 <strncat@plt>
mov    0xe2a(%rip),%ax
mov    %ax,-0x62(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x62(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x62(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1050 <strncat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x7d,%esi
lea    0xdec(%rip),%rdx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1060 <update_token@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_object_close>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r14
mov    $0x200,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    0x0(%rbp),%eax
lea    -0x1(%rax),%esi
mov    %esi,0x0(%rbp)
movw   $0xa,(%rbx)
cmp    $0x2,%eax
jl     11b1 <parse_object_close+0x51>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15d,%edx
call   1080 <expandtab@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x40,%edx
call   1050 <strncat@plt>
movw   $0x7d,(%rsp)
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <strncat@plt>
lea    0xe2a(%rip),%rdx
mov    %r14,%rdi
mov    $0x7d,%esi
mov    %rbx,%rcx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1060 <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 }
@__const.parse_object_close.to_append = [2 x i8] c"}\00"
@.str = [6 x i8] c"\1B[37m\00"
define void @parse_object_close(%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]
%9 = alloca [2 x i8]
store %struct.token* %0, %struct.token** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = call i8* @malloc(i32 512)
store i8* %10, i8** %7
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %11
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 10, i8* %15
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 0, i8* %17
%18 = load i32*, i32** %5
%19 = load i32, i32* %18
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %3
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%23 = load i32*, i32** %5
%24 = load i32, i32* %23
%25 = load i32, i32* %6
%26 = call i32 @expandtab(i8* %22, i32 %24, i32 %25)
%27 = load i8*, i8** %7
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%29 = call i32 @strncat(i8* %27, i8* %28, i32 64)
br label %30
30: ; preds = %21, %3
%31 = bitcast [2 x i8]* %9 to i8*
%32 = load i8*, i8** %7
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = call i32 @strncat(i8* %32, i8* %33, i32 %35)
%37 = load %struct.token*, %struct.token** %4
%38 = load i8*, i8** %7
%39 = call i32 @update_token(%struct.token* %37, i8 signext 125, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %38, i32 1, i32 0)
%40 = load i8*, i8** %7
%41 = call i32 @free(i8* %40)
ret void
}

LLVM IR (-O2):
%struct.token = type { i32 }
@.str = [6 x i8] c"\1B[37m\00"
define void @parse_object_close(%struct.token* %0, i32* nocapture %1, i32 %2) {
%4 = alloca [64 x i8]
%5 = alloca i16
%6 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%7 = load i32, i32* %1
%8 = add nsw i32 %7, -1
store i32 %8, i32* %1
store i8 10, i8* %6
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8 0, i8* %9
%10 = icmp sgt i32 %7, 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 %8, i32 %2)
%14 = call i32 @strncat(i8* %6, i8* %12, i32 64)
br label %15
15: ; preds = %11, %3
%16 = bitcast i16* %5 to i8*
store i16 125, i16* %5
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @strncat(i8* %6, i8* %16, i32 %17)
%19 = call i32 @update_token(%struct.token* %0, i8 signext 125, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i32 1, i32 0)
%20 = call i32 @free(i8* %6)
ret void
}