#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 */
scalar_t__ chdir(char const *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ say(char *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void setup(const char *fs) {
  if (chdir(fs) < 0) {
    say("chdir: %s: %s\n", fs, strerror(errno));
    exit(1);
  }
  if (mkdir("dirconc", 0775) < 0) {
    say("mkdir: %s: %s\n", "dirconc", strerror(errno));
    exit(1);
  }
  if (chdir("dirconc") < 0) {
    say("chdir: %s: %s\n", "dirconc", strerror(errno));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
jge    11a1 <setup+0x51>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
lea    0xe6e(%rip),%rdi
call   1070 <say@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe67(%rip),%rdi
mov    $0x1fd,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jge    11e9 <setup+0x99>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edx
lea    0xe44(%rip),%rdi
lea    0xe35(%rip),%rsi
call   1070 <say@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe1f(%rip),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
jge    122c <setup+0xdc>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edx
lea    0xdea(%rip),%rdi
lea    0xdf2(%rip),%rsi
call   1070 <say@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup>:
push   %rbx
mov    %rdi,%rbx
call   1040 <chdir@plt>
test   %rax,%rax
js     1187 <setup+0x37>
lea    0xeaa(%rip),%rdi
mov    $0x1fd,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
js     11a1 <setup+0x51>
lea    0xe94(%rip),%rdi
call   1040 <chdir@plt>
test   %rax,%rax
js     11b8 <setup+0x68>
pop    %rbx
ret
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe64(%rip),%rdi
mov    %rbx,%rsi
jmp    11d4 <setup+0x84>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe61(%rip),%rdi
jmp    11cd <setup+0x7d>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe33(%rip),%rdi
lea    0xe3b(%rip),%rsi
mov    %eax,%edx
call   1070 <say@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"chdir: %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [8 x i8] c"dirconc\00"
@.str.2 = [15 x i8] c"mkdir: %s: %s\0A\00"
define void @setup(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @chdir(i8* %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = load i32, i32* @errno
%9 = call i32 @strerror(i32 %8)
%10 = call i32 @say(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = call i64 @mkdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 509)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = call i32 @strerror(i32 %16)
%18 = call i32 @say(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %12
%21 = call i64 @chdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* @errno
%25 = call i32 @strerror(i32 %24)
%26 = call i32 @say(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"chdir: %s: %s\0A\00"
@errno = global i32 0
@.str.1 = [8 x i8] c"dirconc\00"
@.str.2 = [15 x i8] c"mkdir: %s: %s\0A\00"
define void @setup(i8* %0) {
%2 = tail call i64 @chdir(i8* %0)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = tail call i32 @strerror(i32 %5)
%7 = tail call i32 @say(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = tail call i64 @mkdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 509)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* @errno
%14 = tail call i32 @strerror(i32 %13)
%15 = tail call i32 @say(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %9
%18 = tail call i64 @chdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* @errno
%22 = tail call i32 @strerror(i32 %21)
%23 = tail call i32 @say(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17
ret void
}