#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__ event_playback_active();
int file_system_attach_disk_internal(unsigned int, char const *);
int /*<<< orphan*/ network_attach_image(unsigned int, char const *);
scalar_t__ network_connected();
int file_system_attach_disk(unsigned int unit, const char *filename) {
  if (event_playback_active())
    return -1;
  if (network_connected()) {
    network_attach_image(unit, filename);
    return 0;
  }
  return file_system_attach_disk_internal(unit, filename);
}


x86 assembly (clang, -O0):
<file_system_attach_disk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <event_playback_active@plt>
cmp    $0x0,%rax
je     116c <file_system_attach_disk+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <file_system_attach_disk+0x64>
mov    $0x0,%al
call   1050 <network_connected@plt>
cmp    $0x0,%rax
je     1195 <file_system_attach_disk+0x55>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <network_attach_image@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <file_system_attach_disk+0x64>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <file_system_attach_disk_internal@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_system_attach_disk>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <event_playback_active@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    1172 <file_system_attach_disk+0x32>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <network_connected@plt>
mov    %ebp,%edi
mov    %r14,%rsi
test   %rax,%rax
je     1179 <file_system_attach_disk+0x39>
call   1060 <network_attach_image@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <file_system_attach_disk_internal@plt>

LLVM IR (-O0):
define i32 @file_system_attach_disk(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = call i64 (...) @event_playback_active()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %20
9: ; preds = %2
%10 = call i64 (...) @network_connected()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%15 = call i32 @network_attach_image(i32 %13, i8* %14)
store i32 0, i32* %3
br label %20
16: ; preds = %9
%17 = load i32, i32* %4
%18 = load i8*, i8** %5
%19 = call i32 @file_system_attach_disk_internal(i32 %17, i8* %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %16, %12, %8
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
define i32 @file_system_attach_disk(i32 %0, i8* %1) {
%3 = tail call i64 (...) @event_playback_active()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i64 (...) @network_connected()
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @network_attach_image(i32 %0, i8* %1)
br label %12
10: ; preds = %5
%11 = tail call i32 @file_system_attach_disk_internal(i32 %0, i8* %1)
br label %12
12: ; preds = %2, %10, %8
%13 = phi i32 [ 0, %8 ], [ %11, %10 ], [ -1, %2 ]
ret i32 %13
}