#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 /*<<< orphan*/ file_system_detach_disk_internal(int);
scalar_t__ network_connected();
int /*<<< orphan*/ network_event_record(int, void *, int);
void file_system_detach_disk(int unit) {
  char event_data[2];
  if (event_playback_active()) {
    return;
  }
  event_data[0] = (char)unit;
  event_data[1] = 0;
  if (network_connected()) {
    network_event_record(6, (void *)event_data, 2);
    return;
  }
  file_system_detach_disk_internal(unit);
}


x86 assembly (clang, -O0):
<file_system_detach_disk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <event_playback_active@plt>
cmp    $0x0,%rax
je     1161 <file_system_detach_disk+0x21>
jmp    119c <file_system_detach_disk+0x5c>
mov    -0x4(%rbp),%eax
mov    %al,-0x6(%rbp)
movb   $0x0,-0x5(%rbp)
mov    $0x0,%al
call   1060 <network_connected@plt>
cmp    $0x0,%rax
je     1194 <file_system_detach_disk+0x54>
lea    -0x6(%rbp),%rsi
mov    $0x6,%edi
mov    $0x2,%edx
call   1030 <network_event_record@plt>
jmp    119c <file_system_detach_disk+0x5c>
mov    -0x4(%rbp),%edi
call   1040 <file_system_detach_disk_internal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_system_detach_disk>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <event_playback_active@plt>
test   %rax,%rax
jne    117c <file_system_detach_disk+0x3c>
mov    %bl,0xe(%rsp)
movb   $0x0,0xf(%rsp)
xor    %eax,%eax
call   1060 <network_connected@plt>
test   %rax,%rax
je     1182 <file_system_detach_disk+0x42>
lea    0xe(%rsp),%rsi
mov    $0x6,%edi
mov    $0x2,%edx
call   1030 <network_event_record@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    %ebx,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <file_system_detach_disk_internal@plt>

LLVM IR (-O0):
define void @file_system_detach_disk(i32 %0) {
%2 = alloca i32
%3 = alloca [2 x i8]
store i32 %0, i32* %2
%4 = call i64 (...) @event_playback_active()
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %20
7: ; preds = %1
%8 = load i32, i32* %2
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
store i8 %9, i8* %10
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
store i8 0, i8* %11
%12 = call i64 (...) @network_connected()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%16 = call i32 @network_event_record(i32 6, i8* %15, i32 2)
br label %20
17: ; preds = %7
%18 = load i32, i32* %2
%19 = call i32 @file_system_detach_disk_internal(i32 %18)
br label %20
20: ; preds = %17, %14, %6
ret void
}

LLVM IR (-O2):
define void @file_system_detach_disk(i32 %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = tail call i64 (...) @event_playback_active()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = trunc i32 %0 to i8
store i8 %7, i8* %3
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 0, i8* %8
%9 = tail call i64 (...) @network_connected()
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = call i32 @network_event_record(i32 6, i8* %3, i32 2)
br label %15
13: ; preds = %6
%14 = tail call i32 @file_system_detach_disk_internal(i32 %0)
br label %15
15: ; preds = %1, %13, %11
ret void
}