#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*/ EXIT_FAILURE;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ WDIOC_KEEPALIVE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  int wdt_file = open("/dev/watchdog", O_WRONLY);
  if (wdt_file == -1) {
    perror("WDT konnte nicht gestartet werden.");
    exit(EXIT_FAILURE);
  }
  while (1) {
    ioctl(wdt_file, WDIOC_KEEPALIVE, 0);
    sleep(10);
  }
  close(wdt_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    119b <main+0x4b>
lea    0xe86(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11a0 <main+0x50>
mov    -0x8(%rbp),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
jmp    11a0 <main+0x50>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    0xe9c(%rip),%rdi
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     1198 <main+0x48>
mov    %eax,%ebx
mov    0x2e71(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r14),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <ioctl@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
jmp    1180 <main+0x30>
lea    0xe6f(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/dev/watchdog\00"
@O_WRONLY = global i32 0
@.str.1 = [35 x i8] c"WDT konnte nicht gestartet werden.\00"
@EXIT_FAILURE = global i32 0
@WDIOC_KEEPALIVE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @O_WRONLY
%4 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
br label %12
12: ; preds = %11, %12
%13 = load i32, i32* %2
%14 = load i32, i32* @WDIOC_KEEPALIVE
%15 = call i32 @ioctl(i32 %13, i32 %14, i32 0)
%16 = call i32 @sleep(i32 10)
br label %12
}

LLVM IR (-O2):
@.str = [14 x i8] c"/dev/watchdog\00"
@O_WRONLY = global i32 0
@.str.1 = [35 x i8] c"WDT konnte nicht gestartet werden.\00"
@EXIT_FAILURE = global i32 0
@WDIOC_KEEPALIVE = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %0, %8
%9 = load i32, i32* @WDIOC_KEEPALIVE
%10 = tail call i32 @ioctl(i32 %2, i32 %9, i32 0)
%11 = tail call i32 @sleep(i32 10)
br label %8
}