#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 */
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int /*<<< orphan*/);
scalar_t__ time(int /*<<< orphan*/ *);
int createPaths(char log_name_default[], char log_name_new[]) {
  int time_t = (int)time(NULL);
  char time_str[32];
  char cwd[1024];
  char tmp_cwd[1024];
  if (getcwd(cwd, sizeof(cwd)) == NULL)
    return 0;
  strncpy(tmp_cwd, cwd, strlen(cwd));
  sprintf(time_str, "%d", time_t);
  strcat(log_name_new, time_str);
  strcat(cwd, log_name_new);
  strncpy(log_name_new, cwd, strlen(cwd));
  strncpy(cwd, tmp_cwd, strlen(cwd));
  strcat(cwd, log_name_default);
  strncpy(log_name_default, cwd, strlen(cwd));
  return 1;
}


x86 assembly (clang, -O0):
<createPaths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x440(%rbp),%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
cmp    $0x0,%rax
jne    11a6 <createPaths+0x46>
movl   $0x0,-0x4(%rbp)
jmp    12db <createPaths+0x17b>
lea    -0x840(%rbp),%rax
mov    %rax,-0x880(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x878(%rbp)
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x880(%rbp),%rdi
mov    -0x878(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe0f(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x440(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x870(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x868(%rbp)
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x870(%rbp),%rdi
mov    -0x868(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    -0x440(%rbp),%rax
mov    %rax,-0x860(%rbp)
lea    -0x840(%rbp),%rax
mov    %rax,-0x858(%rbp)
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x860(%rbp),%rdi
mov    -0x858(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    -0x440(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x850(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x848(%rbp)
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x850(%rbp),%rdi
mov    -0x848(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x880,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createPaths>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%r13
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
test   %rax,%rax
je     1237 <createPaths+0xd7>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x420(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    0xe3c(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r13d,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @createPaths(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = call i64 @time(i32* null)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%13 = call i32* @getcwd(i8* %12, i32 1024)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %49
16: ; preds = %2
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @strncpy(i8* %17, i8* %18, i32 %20)
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* %6
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i8*, i8** %5
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = load i8*, i8** %5
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = call i32 @strncpy(i8* %31, i8* %32, i32 %34)
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = call i32 @strncpy(i8* %36, i8* %37, i32 %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = load i8*, i8** %4
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = load i8*, i8** %4
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = call i32 @strncpy(i8* %44, i8* %45, i32 %47)
store i32 1, i32* %3
br label %49
49: ; preds = %16, %15
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @createPaths(i8* %0, i8* %1) {
%3 = alloca [32 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = tail call i64 @time(i32* null)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = call i32* @getcwd(i8* %8, i32 1024)
%11 = icmp eq i32* %10, null
br i1 %11, label %26, label %12
12: ; preds = %2
%13 = trunc i64 %6 to i32
%14 = call i32 @strlen(i8* %8)
%15 = call i32 @strncpy(i8* %9, i8* %8, i32 %14)
%16 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%17 = call i32 @strcat(i8* %1, i8* %7)
%18 = call i32 @strcat(i8* %8, i8* %1)
%19 = call i32 @strlen(i8* %8)
%20 = call i32 @strncpy(i8* %1, i8* %8, i32 %19)
%21 = call i32 @strlen(i8* %8)
%22 = call i32 @strncpy(i8* %8, i8* %9, i32 %21)
%23 = call i32 @strcat(i8* %8, i8* %0)
%24 = call i32 @strlen(i8* %8)
%25 = call i32 @strncpy(i8* %0, i8* %8, i32 %24)
br label %26
26: ; preds = %2, %12
%27 = phi i32 [ 1, %12 ], [ 0, %2 ]
ret i32 %27
}