#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__ connected();
int /*<<< orphan*/ pause_sync();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_disconnect();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ test_dir_eexist();
int /*<<< orphan*/ test_dir_nonexist();
int /*<<< orphan*/ test_mkdir_with_new_file();
int main(void) {
  int result = 0;
  while (!connected()) {
    printf("Waiting for tsumufs to mount.\n");
    sleep(1);
  }
  printf("Mounted.\n");
  sleep(1);
  pause_sync();
  sleep(1);
  if (!test_dir_eexist())
    result = 1;
  if (!test_dir_nonexist())
    result = 1;
  if (!test_mkdir_with_new_file())
    result = 1;
  printf("Disconnecting.\n");
  set_disconnect();
  while (connected()) {
    printf("Waiting for tsumufs to disconnect.\n");
    sleep(1);
  }
  if (!test_dir_eexist())
    result = 1;
  if (!test_dir_nonexist())
    result = 1;
  if (!test_mkdir_with_new_file())
    result = 1;
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <connected@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b3 <main+0x33>
jmp    11ce <main+0x4e>
lea    0xe46(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    1196 <main+0x16>
lea    0xe4a(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    $0x0,%al
call   1080 <pause_sync@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    $0x0,%al
call   10a0 <test_dir_eexist@plt>
cmp    $0x0,%eax
jne    120c <main+0x8c>
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1060 <test_dir_nonexist@plt>
cmp    $0x0,%eax
jne    1223 <main+0xa3>
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1040 <test_mkdir_with_new_file@plt>
cmp    $0x0,%eax
jne    123a <main+0xba>
movl   $0x1,-0x8(%rbp)
lea    0xde8(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1030 <set_disconnect@plt>
mov    $0x0,%al
call   1050 <connected@plt>
cmp    $0x0,%rax
je     1279 <main+0xf9>
lea    0xdd4(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    124d <main+0xcd>
mov    $0x0,%al
call   10a0 <test_dir_eexist@plt>
cmp    $0x0,%eax
jne    1290 <main+0x110>
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1060 <test_dir_nonexist@plt>
cmp    $0x0,%eax
jne    12a7 <main+0x127>
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1040 <test_mkdir_with_new_file@plt>
cmp    $0x0,%eax
jne    12be <main+0x13e>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1060 <connected@plt>
test   %rax,%rax
jne    11be <main+0x3e>
lea    0xea0(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1060 <connected@plt>
test   %rax,%rax
je     11a0 <main+0x20>
lea    0xe3b(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1080 <pause_sync@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   10a0 <test_dir_eexist@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1070 <test_dir_nonexist@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1040 <test_mkdir_with_new_file@plt>
mov    %eax,%ebx
lea    0xe00(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1030 <set_disconnect@plt>
xor    %eax,%eax
call   1060 <connected@plt>
test   %rax,%rax
je     124e <main+0xce>
lea    0xdf0(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1060 <connected@plt>
test   %rax,%rax
jne    1230 <main+0xb0>
test   %ebx,%ebx
sete   %r12b
test   %r14d,%r14d
sete   %bpl
test   %r15d,%r15d
sete   %r14b
xor    %eax,%eax
call   10a0 <test_dir_eexist@plt>
test   %eax,%eax
sete   %bl
xor    %eax,%eax
call   1070 <test_dir_nonexist@plt>
test   %eax,%eax
sete   %r15b
xor    %eax,%eax
call   1040 <test_mkdir_with_new_file@plt>
test   %eax,%eax
sete   %al
or     %r15b,%al
or     %r12b,%bl
or     %al,%bl
or     %bpl,%r14b
or     %bl,%r14b
movzbl %r14b,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Waiting for tsumufs to mount.\0A\00"
@.str.1 = [10 x i8] c"Mounted.\0A\00"
@.str.2 = [16 x i8] c"Disconnecting.\0A\00"
@.str.3 = [36 x i8] c"Waiting for tsumufs to disconnect.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %7, %0
%4 = call i64 (...) @connected()
%5 = icmp ne i64 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @sleep(i32 1)
br label %3
10: ; preds = %3
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @sleep(i32 1)
%13 = call i32 (...) @pause_sync()
%14 = call i32 @sleep(i32 1)
%15 = call i32 (...) @test_dir_eexist()
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %10
store i32 1, i32* %2
br label %18
18: ; preds = %17, %10
%19 = call i32 (...) @test_dir_nonexist()
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %18
store i32 1, i32* %2
br label %22
22: ; preds = %21, %18
%23 = call i32 (...) @test_mkdir_with_new_file()
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %22
store i32 1, i32* %2
br label %26
26: ; preds = %25, %22
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (...) @set_disconnect()
br label %29
29: ; preds = %32, %26
%30 = call i64 (...) @connected()
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @sleep(i32 1)
br label %29
35: ; preds = %29
%36 = call i32 (...) @test_dir_eexist()
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %35
store i32 1, i32* %2
br label %39
39: ; preds = %38, %35
%40 = call i32 (...) @test_dir_nonexist()
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %39
store i32 1, i32* %2
br label %43
43: ; preds = %42, %39
%44 = call i32 (...) @test_mkdir_with_new_file()
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %43
store i32 1, i32* %2
br label %47
47: ; preds = %46, %43
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@str = [9 x i8] c"Mounted.\00"
@str.4 = [15 x i8] c"Disconnecting.\00"
@str.5 = [35 x i8] c"Waiting for tsumufs to disconnect.\00"
@str.6 = [30 x i8] c"Waiting for tsumufs to mount.\00"
define i32 @main() {
%1 = tail call i64 (...) @connected()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %8
3: ; preds = %0, %3
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i64 (...) @connected()
%7 = icmp eq i64 %6, 0
br i1 %7, label %3, label %8
8: ; preds = %3, %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 (...) @pause_sync()
%12 = tail call i32 @sleep(i32 1)
%13 = tail call i32 (...) @test_dir_eexist()
%14 = tail call i32 (...) @test_dir_nonexist()
%15 = tail call i32 (...) @test_mkdir_with_new_file()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%17 = tail call i32 (...) @set_disconnect()
%18 = tail call i64 (...) @connected()
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %8, %20
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%22 = tail call i32 @sleep(i32 1)
%23 = tail call i64 (...) @connected()
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %20
25: ; preds = %20, %8
%26 = icmp eq i32 %15, 0
%27 = icmp eq i32 %13, 0
%28 = icmp eq i32 %14, 0
%29 = tail call i32 (...) @test_dir_eexist()
%30 = icmp eq i32 %29, 0
%31 = tail call i32 (...) @test_dir_nonexist()
%32 = icmp eq i32 %31, 0
%33 = tail call i32 (...) @test_mkdir_with_new_file()
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i1 true, i1 %32
%36 = select i1 %35, i1 true, i1 %30
%37 = select i1 %36, i1 true, i1 %26
%38 = select i1 %37, i1 true, i1 %28
%39 = select i1 %38, i1 true, i1 %27
%40 = zext i1 %39 to i32
ret i32 %40
}