#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 */
int /*<<< orphan*/ RB_AUTOBOOT;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ getpid();
scalar_t__ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
scalar_t__ wdog_reset(int /*<<< orphan*/, char *);
void wdog_forced_reset(char *label) {
  if (!label || !label[0])
    label = "XBAD_LABEL";
  if (wdog_reset(getpid(), label)) {
    if (kill(1, SIGINT))
      reboot(RB_AUTOBOOT);
  }
}


x86 assembly (clang, -O0):
<wdog_forced_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1164 <wdog_forced_reset+0x24>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116f <wdog_forced_reset+0x2f>
lea    0xe95(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1050 <wdog_reset@plt>
cmp    $0x0,%rax
je     11bb <wdog_forced_reset+0x7b>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1040 <kill@plt>
cmp    $0x0,%rax
je     11b6 <wdog_forced_reset+0x76>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
jmp    11bb <wdog_forced_reset+0x7b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wdog_forced_reset>:
push   %rbx
test   %rdi,%rdi
je     114e <wdog_forced_reset+0xe>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
jne    1155 <wdog_forced_reset+0x15>
lea    0xeab(%rip),%rbx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <wdog_reset@plt>
test   %rax,%rax
je     1192 <wdog_forced_reset+0x52>
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1040 <kill@plt>
test   %rax,%rax
je     1192 <wdog_forced_reset+0x52>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
pop    %rbx
jmp    1060 <reboot@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"XBAD_LABEL\00"
@SIGINT = global i32 0
@RB_AUTOBOOT = global i32 0
define void @wdog_forced_reset(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %5, %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %11
11: ; preds = %10, %5
%12 = call i32 (...) @getpid()
%13 = load i8*, i8** %2
%14 = call i64 @wdog_reset(i32 %12, i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = load i32, i32* @SIGINT
%18 = call i64 @kill(i32 1, i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* @RB_AUTOBOOT
%22 = call i32 @reboot(i32 %21)
br label %23
23: ; preds = %20, %16
br label %24
24: ; preds = %23, %11
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"XBAD_LABEL\00"
@SIGINT = global i32 0
@RB_AUTOBOOT = global i32 0
define void @wdog_forced_reset(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %3, %1
br label %7
7: ; preds = %6, %3
%8 = phi i8* [ %0, %3 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %6 ]
%9 = tail call i32 (...) @getpid()
%10 = tail call i64 @wdog_reset(i32 %9, i8* %8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %7
%13 = load i32, i32* @SIGINT
%14 = tail call i64 @kill(i32 1, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* @RB_AUTOBOOT
%18 = tail call i32 @reboot(i32 %17)
br label %19
19: ; preds = %12, %16, %7
ret void
}