#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 int32_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ WDIOC_SETTIMEOUT;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int32_t slFileDescT = open("/dev/watchdog", O_WRONLY);
  int32_t slTimeoutT = 45;
  ioctl(slFileDescT, WDIOC_SETTIMEOUT, &slTimeoutT);
  printf("The timeout was set to %d seconds\n", slTimeoutT);
  if (slFileDescT == -1) {
    perror("watchdog");
    exit(EXIT_FAILURE);
  }
  close(slFileDescT);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
movl   $0x2d,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0xc(%rbp),%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11d6 <main+0x76>
lea    0xe42(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
movl   $0x2d,0xc(%rsp)
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1040 <ioctl@plt>
mov    0xc(%rsp),%esi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
cmp    $0xffffffff,%ebx
je     11bd <main+0x5d>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe41(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/dev/watchdog\00"
@O_WRONLY = global i32 0
@WDIOC_SETTIMEOUT = global i32 0
@.str.1 = [35 x i8] c"The timeout was set to %d seconds\0A\00"
@.str.2 = [9 x i8] c"watchdog\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_WRONLY
%5 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
store i32 45, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* @WDIOC_SETTIMEOUT
%8 = call i32 @ioctl(i32 %6, i32 %7, i32* %3)
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %0
%18 = load i32, i32* %2
%19 = call i32 @close(i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"/dev/watchdog\00"
@O_WRONLY = global i32 0
@WDIOC_SETTIMEOUT = global i32 0
@.str.1 = [35 x i8] c"The timeout was set to %d seconds\0A\00"
@.str.2 = [9 x i8] c"watchdog\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @O_WRONLY
%3 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = bitcast i32* %1 to i8*
store i32 45, i32* %1
%5 = load i32, i32* @WDIOC_SETTIMEOUT
%6 = call i32 @ioctl(i32 %3, i32 %5, i32* %1)
%7 = load i32, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %3, -1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call i32 @close(i32 %3)
ret i32 0
}