#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 *path_alloc(int *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int main(int argc, char **argv) {
  int size;
  char *path = path_alloc(&size);
  int i;
  for (i = 0; i < size; i += 256) {
    strcat(path, "/home/alex");
  }
  printf("path is: \n%s\nsize is %d\n", path, size);
  free(path);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <path_alloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1196 <main+0x56>
mov    -0x20(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x24(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x24(%rbp)
jmp    116a <main+0x2a>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1050 <path_alloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    1189 <main+0x49>
xor    %ebp,%ebp
lea    0xe9a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
add    $0x100,%ebp
mov    0xc(%rsp),%edx
cmp    %edx,%ebp
jl     1170 <main+0x30>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/home/alex\00"
@.str.1 = [25 x i8] c"path is: \0A%s\0Asize is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* @path_alloc(i32* %6)
store i8* %9, i8** %7
store i32 0, i32* %8
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i8*, i8** %7
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14
%18 = load i32, i32* %8
%19 = add nsw i32 %18, 256
store i32 %19, i32* %8
br label %10
20: ; preds = %10
%21 = load i8*, i8** %7
%22 = load i32, i32* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %22)
%24 = load i8*, i8** %7
%25 = call i32 @free(i8* %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"/home/alex\00"
@.str.1 = [25 x i8] c"path is: \0A%s\0Asize is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i8* @path_alloc(i32* %3)
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ 0, %2 ]
%10 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = add nuw nsw i32 %9, 256
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %8, label %14
14: ; preds = %8, %2
%15 = phi i32 [ %6, %2 ], [ %12, %8 ]
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %15)
%17 = call i32 @free(i8* %5)
ret i32 0
}