#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 chdir(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[], char *envp[]) {
  if (argc == 1) {
    chdir("rootfs/");
    return 0;
  }
  int res = chdir(argv[1]);
  if (res < 0) {
    printf("Path does not exist \n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    115c <main+0x3c>
lea    0xeb5(%rip),%rdi
call   1030 <chdir@plt>
movl   $0x0,-0x4(%rbp)
jmp    1189 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <chdir@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1182 <main+0x62>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
jne    1134 <main+0x14>
lea    0xed3(%rip),%rdi
call   1040 <chdir@plt>
jmp    114d <main+0x2d>
mov    0x8(%rsi),%rdi
call   1040 <chdir@plt>
test   %eax,%eax
jns    114d <main+0x2d>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"rootfs/\00"
@.str.1 = [22 x i8] c"Path does not exist \0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @chdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %23
13: ; preds = %3
%14 = load i8**, i8*** %6
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @chdir(i8* %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %13
store i32 0, i32* %4
br label %23
23: ; preds = %22, %11
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"rootfs/\00"
@str = [21 x i8] c"Path does not exist \00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @chdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %14
7: ; preds = %3
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @chdir(i8* %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %7, %12, %5
ret i32 0
}