#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 *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_no_concurrent_coredumps();
int /*<<< orphan*/ test_no_concurrent_opens();
int /*<<< orphan*/ test_rotation();
int main(int argc, char **argv) {
  char *test_mount = argv[1];
  if (argc < 2) {
    fprintf(stderr, "Need to specify a mount to test!\n");
    exit(1);
  }
  if (chdir(test_mount) != 0) {
    perror("failed to chdir");
    exit(1);
  }
  printf("Testing...\n");
  test_no_concurrent_opens();
  test_no_concurrent_coredumps();
  test_rotation();
  printf("All tests passed!\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    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cb <main+0x4b>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
je     11f4 <main+0x74>
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <test_no_concurrent_opens@plt>
mov    $0x0,%al
call   1030 <test_no_concurrent_coredumps@plt>
mov    $0x0,%al
call   1080 <test_rotation@plt>
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
jle    11c5 <main+0x45>
mov    0x8(%rsi),%rdi
call   1050 <chdir@plt>
test   %rax,%rax
jne    11e4 <main+0x64>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10a0 <test_no_concurrent_opens@plt>
xor    %eax,%eax
call   1040 <test_no_concurrent_coredumps@plt>
xor    %eax,%eax
call   1080 <test_rotation@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe37(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Need to specify a mount to test!\0A\00"
@.str.1 = [16 x i8] c"failed to chdir\00"
@.str.2 = [12 x i8] c"Testing...\0A\00"
@.str.3 = [19 x i8] c"All tests passed!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
store i8* %9, i8** %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = call i64 @chdir(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 (...) @test_no_concurrent_opens()
%26 = call i32 (...) @test_no_concurrent_coredumps()
%27 = call i32 (...) @test_rotation()
%28 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Need to specify a mount to test!\0A\00"
@.str.1 = [16 x i8] c"failed to chdir\00"
@str = [11 x i8] c"Testing...\00"
@str.4 = [18 x i8] c"All tests passed!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @chdir(i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %8
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 (...) @test_no_concurrent_opens()
%19 = tail call i32 (...) @test_no_concurrent_coredumps()
%20 = tail call i32 (...) @test_rotation()
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}