#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 const *);
int /*<<< orphan*/ perror(char *);
int setenv(char *, char const *, int);
void setEd_Wd(const char *Ed, const char *Wd) {
  {{if ((setenv("EDITOR", Ed, 1)) == -1){perror("setenv failed");
}
}
}
;
{{if ((chdir(Wd)) == -1){perror("chdir failed");
}
}
}
;
}


x86 assembly (clang, -O0):
<setEd_Wd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0xffffffff,%eax
jne    116a <setEd_Wd+0x3a>
lea    0xea2(%rip),%rdi
call   1050 <perror@plt>
mov    -0x10(%rbp),%rdi
call   1040 <chdir@plt>
cmp    $0xffffffff,%eax
jne    1188 <setEd_Wd+0x58>
lea    0xe92(%rip),%rdi
call   1050 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setEd_Wd>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xec2(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0xffffffff,%eax
je     115c <setEd_Wd+0x2c>
mov    %rbx,%rdi
call   1040 <chdir@plt>
cmp    $0xffffffff,%eax
je     116a <setEd_Wd+0x3a>
pop    %rbx
ret
lea    0xea4(%rip),%rdi
call   1050 <perror@plt>
jmp    114d <setEd_Wd+0x1d>
lea    0xea4(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"EDITOR\00"
@.str.1 = [14 x i8] c"setenv failed\00"
@.str.2 = [13 x i8] c"chdir failed\00"
define void @setEd_Wd(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i32 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5, i32 1)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = load i8*, i8** %4
%12 = call i32 @chdir(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"EDITOR\00"
@.str.1 = [14 x i8] c"setenv failed\00"
@.str.2 = [13 x i8] c"chdir failed\00"
define void @setEd_Wd(i8* %0, i8* %1) {
%3 = tail call i32 @setenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i32 1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @chdir(i8* %1)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
ret void
}