#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 */
struct timespec {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
scalar_t__ clock_settime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ perror(char *);
int setBackTime(struct timespec tpset) {
  if (clock_settime(CLOCK_REALTIME, &tpset) != 0) {
    perror("clock_settime() did not return success\n");
    perror("clock may not be reset properly\n");
    return 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setBackTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1030 <clock_settime@plt>
cmp    $0x0,%rax
je     116b <setBackTime+0x4b>
lea    0xeb2(%rip),%rdi
call   1040 <perror@plt>
lea    0xece(%rip),%rdi
call   1040 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1172 <setBackTime+0x52>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setBackTime>:
push   %rax
mov    %edi,(%rsp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_settime@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1141 <setBackTime+0x21>
pop    %rcx
ret
lea    0xeb8(%rip),%rdi
call   1040 <perror@plt>
lea    0xed4(%rip),%rdi
call   1040 <perror@plt>
mov    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [40 x i8] c"clock_settime() did not return success\0A\00"
@.str.1 = [33 x i8] c"clock may not be reset properly\0A\00"
define i32 @setBackTime(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i32 %0, i32* %4
%5 = load i32, i32* @CLOCK_REALTIME
%6 = call i64 @clock_settime(i32 %5, %struct.timespec* %3)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %2
br label %12
11: ; preds = %1
store i32 0, i32* %2
br label %12
12: ; preds = %11, %8
%13 = load i32, i32* %2
ret i32 %13
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [40 x i8] c"clock_settime() did not return success\0A\00"
@.str.1 = [33 x i8] c"clock may not be reset properly\0A\00"
define i32 @setBackTime(i32 %0) {
%2 = alloca %struct.timespec
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 %0, i32* %3
%4 = load i32, i32* @CLOCK_REALTIME
%5 = call i64 @clock_settime(i32 %4, %struct.timespec* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %1, %7
%11 = phi i32 [ 2, %7 ], [ 0, %1 ]
ret i32 %11
}