#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*/ init_id(char *, int);
int parent(int);
char *strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *make_path(char *buf, int i) {
  char temp[32];
  init_id(buf, i);
  while (i = parent(i), i >= 0) {
    (void)strcpy(temp, buf);
    init_id(buf, i);
    (void)strcat(strcat(buf, "->"), temp);
  }
  return buf;
}


x86 assembly (clang, -O0):
<make_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <init_id@plt>
mov    -0xc(%rbp),%edi
call   1030 <parent@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11aa <make_path+0x6a>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <init_id@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strcat@plt>
mov    %rax,%rdi
lea    -0x30(%rbp),%rsi
call   1060 <strcat@plt>
jmp    115b <make_path+0x1b>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_path>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <init_id@plt>
mov    %ebp,%edi
call   1030 <parent@plt>
test   %eax,%eax
js     11c0 <make_path+0x70>
mov    %eax,%ebp
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <init_id@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
movw   $0x3e2d,(%rbx,%rax,1)
movb   $0x0,0x2(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %ebp,%edi
call   1030 <parent@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1180 <make_path+0x30>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"->\00"
define i8* @make_path(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [32 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i32 @init_id(i8* %6, i32 %7)
br label %9
9: ; preds = %14, %2
%10 = load i32, i32* %4
%11 = call i32 @parent(i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = call i32 @init_id(i8* %18, i32 %19)
%21 = load i8*, i8** %3
%22 = call i8* @strcat(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%24 = call i8* @strcat(i8* %22, i8* %23)
br label %9
25: ; preds = %9
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"->\00"
define i8* @make_path(i8* returned %0, i32 %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @init_id(i8* %0, i32 %1)
%6 = call i32 @parent(i32 %1)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %17
8: ; preds = %2, %8
%9 = phi i32 [ %15, %8 ], [ %6, %2 ]
%10 = call i32 @strcpy(i8* %4, i8* %0)
%11 = call i32 @init_id(i8* %0, i32 %9)
%12 = call i64 @strlen(i8* dereferenceable(1) %0)
%13 = getelementptr i8, i8* %0, i64 %12
%14 = call i8* @strcat(i8* dereferenceable(1) %0, i8* %4)
%15 = call i32 @parent(i32 %9)
%16 = icmp sgt i32 %15, -1
br i1 %16, label %8, label %17
17: ; preds = %8, %2
ret i8* %0
}