#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*/ path;

/* Variables and functions */
int /*<<< orphan*/ S_IWRITE;
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ getcwd(char *, ...);
int /*<<< orphan*/ mkdir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char path[100];
  size_t size;
  getcwd(path, sizeof(path));
  printf("path=%s\n", path);
  mkdir("/temp1", S_IWRITE);
  chdir("/temp1");
  getcwd(path);
  printf("path=%s\n", path);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1060 <getcwd@plt>
lea    -0x70(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
call   1030 <mkdir@plt>
lea    0xe82(%rip),%rdi
call   1040 <chdir@plt>
lea    -0x70(%rbp),%rdi
mov    $0x0,%al
call   1060 <getcwd@plt>
lea    -0x70(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsp,%r15
mov    $0x64,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <getcwd@plt>
lea    0xe9e(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    0xe8c(%rip),%rbx
mov    %rbx,%rdi
call   1030 <mkdir@plt>
mov    %rbx,%rdi
call   1040 <chdir@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <getcwd@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"path=%s\0A\00"
@.str.1 = [7 x i8] c"/temp1\00"
@S_IWRITE = global i32 0
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 (i8*, ...) @getcwd(i8* %3, i64 100)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @S_IWRITE
%8 = call i32 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @chdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%11 = call i32 (i8*, ...) @getcwd(i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %12)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"path=%s\0A\00"
@.str.1 = [7 x i8] c"/temp1\00"
@S_IWRITE = global i32 0
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @getcwd(i8* %2, i64 100)
%4 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = load i32, i32* @S_IWRITE
%6 = call i32 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = call i32 @chdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @getcwd(i8* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}