#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int);
void err_chdir(int err) {
  fprintf(stderr, "error: chdir(2) failed to change directory - %d\n", err);
  fprintf(stderr, "       errno is: %d\n", err);
  ;
  fprintf(stderr, "       %s\n", strerror(err));
  ;
  fflush(stderr);
}


x86 assembly (clang, -O0):
<err_chdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x8(%rbp),%edi
mov    %rax,%rdx
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_chdir>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    0x2ea3(%rip),%r14
mov    (%r14),%edi
lea    0xeb9(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xed7(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%ebp
mov    %ebx,%edi
call   1050 <strerror@plt>
lea    0xed2(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"error: chdir(2) failed to change directory - %d\0A\00"
@.str.1 = [21 x i8] c" errno is: %d\0A\00"
@.str.2 = [11 x i8] c" %s\0A\00"
define void @err_chdir(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @stderr
%4 = load i32, i32* %2
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @stderr
%7 = load i32, i32* %2
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stderr
%10 = load i32, i32* %2
%11 = call i8* @strerror(i32 %10)
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stderr
%14 = call i32 @fflush(i32 %13)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"error: chdir(2) failed to change directory - %d\0A\00"
@.str.1 = [21 x i8] c" errno is: %d\0A\00"
@.str.2 = [11 x i8] c" %s\0A\00"
define void @err_chdir(i32 %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%6 = load i32, i32* @stderr
%7 = tail call i8* @strerror(i32 %0)
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @stderr
%10 = tail call i32 @fflush(i32 %9)
ret void
}