#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*/ free(char *);
char *malloc(int);
int sprintf(char *, char *);
char *strdup(char *);
int strlen(char *);
char *up_nodes(int count) {
  char *path, *tmp;
  int i, ret, len, size;
  if (!count)
    return strdup("./");
  len = strlen("../");
  size = len * count;
  if (size >= 1000)
    return NULL;
  path = malloc(size + 1);
  if (!path)
    return NULL;
  tmp = path;
  for (i = 0; i < count; i++) {
    ret = sprintf(tmp, "../");
    if (ret < 0 || ret != len) {
      free(path);
      return NULL;
    }
    tmp += ret;
  }
  return path;
}


x86 assembly (clang, -O0):
<up_nodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    117a <up_nodes+0x2a>
lea    0xe95(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    1255 <up_nodes+0x105>
lea    0xe7f(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x3e8,-0x30(%rbp)
jl     11ad <up_nodes+0x5d>
movq   $0x0,-0x8(%rbp)
jmp    1255 <up_nodes+0x105>
mov    -0x30(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d4 <up_nodes+0x84>
movq   $0x0,-0x8(%rbp)
jmp    1255 <up_nodes+0x105>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    124d <up_nodes+0xfd>
mov    -0x20(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1060 <sprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1218 <up_nodes+0xc8>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     122e <up_nodes+0xde>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1255 <up_nodes+0x105>
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e3 <up_nodes+0x93>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<up_nodes>:
test   %edi,%edi
je     1196 <up_nodes+0x56>
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xeb0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
imul   %ebx,%edi
cmp    $0x3e7,%edi
jg     11aa <up_nodes+0x6a>
mov    %eax,%ebp
add    $0x1,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11aa <up_nodes+0x6a>
test   %ebx,%ebx
jle    11ac <up_nodes+0x6c>
mov    %rax,%rcx
nopl   0x0(%rax,%rax,1)
movl   $0x2f2e2e,(%rcx)
cmp    $0x3,%ebp
jne    11a2 <up_nodes+0x62>
add    $0x3,%rcx
add    $0xffffffff,%ebx
jne    1180 <up_nodes+0x40>
jmp    11ac <up_nodes+0x6c>
lea    0xe64(%rip),%rdi
jmp    1060 <strdup@plt>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"./\00"
@.str.1 = [4 x i8] c"../\00"
define i8* @up_nodes(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %1
%13 = call i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %2
br label %57
14: ; preds = %1
%15 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = load i32, i32* %3
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp sge i32 %19, 1000
br i1 %20, label %21, label %22
21: ; preds = %14
store i8* null, i8** %2
br label %57
22: ; preds = %14
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 1
%25 = call i8* @malloc(i32 %24)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %29, label %28
28: ; preds = %22
store i8* null, i8** %2
br label %57
29: ; preds = %22
%30 = load i8*, i8** %4
store i8* %30, i8** %5
store i32 0, i32* %6
br label %31
31: ; preds = %52, %29
%32 = load i32, i32* %6
%33 = load i32, i32* %3
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %55
35: ; preds = %31
%36 = load i8*, i8** %5
%37 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %35
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = icmp ne i32 %41, %42
br i1 %43, label %44, label %47
44: ; preds = %40, %35
%45 = load i8*, i8** %4
%46 = call i32 @free(i8* %45)
store i8* null, i8** %2
br label %57
47: ; preds = %40
%48 = load i32, i32* %7
%49 = load i8*, i8** %5
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %5
br label %52
52: ; preds = %47
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %31
55: ; preds = %31
%56 = load i8*, i8** %4
store i8* %56, i8** %2
br label %57
57: ; preds = %55, %44, %28, %21, %12
%58 = load i8*, i8** %2
ret i8* %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"./\00"
@.str.1 = [4 x i8] c"../\00"
define noalias i8* @up_nodes(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call dereferenceable_or_null(3) i8* @strdup(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
5: ; preds = %1
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = mul nsw i32 %6, %0
%8 = icmp sgt i32 %7, 999
br i1 %8, label %27, label %9
9: ; preds = %5
%10 = add nsw i32 %7, 1
%11 = tail call i8* @malloc(i32 %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %27, label %13
13: ; preds = %9
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %27
15: ; preds = %13
%16 = icmp eq i32 %6, 3
br label %17
17: ; preds = %15, %23
%18 = phi i8* [ %11, %15 ], [ %24, %23 ]
%19 = phi i32 [ 0, %15 ], [ %25, %23 ]
%20 = bitcast i8* %18 to i32*
store i32 3092014, i32* %20
br i1 %16, label %23, label %21
21: ; preds = %17
%22 = tail call i32 @free(i8* %11)
br label %27
23: ; preds = %17
%24 = getelementptr inbounds i8, i8* %18, i64 3
%25 = add nuw nsw i32 %19, 1
%26 = icmp eq i32 %25, %0
br i1 %26, label %27, label %17
27: ; preds = %23, %13, %9, %5, %21, %3
%28 = phi i8* [ null, %21 ], [ %4, %3 ], [ null, %5 ], [ null, %9 ], [ %11, %13 ], [ %11, %23 ]
ret i8* %28
}