#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 */
typedef int /*<<< orphan*/ mode;

/* Variables and functions */
scalar_t__ event_playback_active();
int /*<<< orphan*/ event_record(int, void *, int);
int /*<<< orphan*/ machine_trigger_reset_internal(unsigned int const);
scalar_t__ network_connected();
int /*<<< orphan*/ network_event_record(int, void *, int);
void machine_trigger_reset(const unsigned int mode) {
  if (event_playback_active())
    return;
  if (network_connected()) {
    network_event_record(8, (void *)&mode, sizeof(mode));
  } else {
    event_record(8, (void *)&mode, sizeof(mode));
    machine_trigger_reset_internal(mode);
  }
}


x86 assembly (clang, -O0):
<machine_trigger_reset>:
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     1171 <machine_trigger_reset+0x21>
jmp    11b5 <machine_trigger_reset+0x65>
mov    $0x0,%al
call   1060 <network_connected@plt>
cmp    $0x0,%rax
je     119a <machine_trigger_reset+0x4a>
lea    -0x4(%rbp),%rsi
mov    $0x8,%edi
mov    $0x4,%edx
call   1030 <network_event_record@plt>
jmp    11b5 <machine_trigger_reset+0x65>
lea    -0x4(%rbp),%rsi
mov    $0x8,%edi
mov    $0x4,%edx
call   1070 <event_record@plt>
mov    -0x4(%rbp),%edi
call   1040 <machine_trigger_reset_internal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<machine_trigger_reset>:
push   %rax
mov    %edi,0x4(%rsp)
xor    %eax,%eax
call   1050 <event_playback_active@plt>
test   %rax,%rax
je     1163 <machine_trigger_reset+0x13>
pop    %rax
ret
xor    %eax,%eax
call   1060 <network_connected@plt>
lea    0x4(%rsp),%rsi
mov    $0x8,%edi
mov    $0x4,%edx
test   %rax,%rax
je     1185 <machine_trigger_reset+0x35>
call   1030 <network_event_record@plt>
pop    %rax
ret
call   1070 <event_record@plt>
mov    0x4(%rsp),%edi
call   1040 <machine_trigger_reset_internal@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @machine_trigger_reset(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i64 (...) @event_playback_active()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %1
br label %17
6: ; preds = %1
%7 = call i64 (...) @network_connected()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = bitcast i32* %2 to i8*
%11 = call i32 @network_event_record(i32 8, i8* %10, i32 4)
br label %17
12: ; preds = %6
%13 = bitcast i32* %2 to i8*
%14 = call i32 @event_record(i32 8, i8* %13, i32 4)
%15 = load i32, i32* %2
%16 = call i32 @machine_trigger_reset_internal(i32 %15)
br label %17
17: ; preds = %5, %12, %9
ret void
}

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