#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 timeval {
  int tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
scalar_t__ settimeofday(struct timeval *, int /*<<< orphan*/);
int fb_hSetTime(int h, int m, int s) {
  struct timeval tv;
  gettimeofday(&tv, 0);
  tv.tv_sec -= (tv.tv_sec % 86400);
  tv.tv_sec += (h * 3600) + (m * 60) + s;
  if (settimeofday(&tv, 0))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<fb_hSetTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x18(%rbp)
imul   $0xe10,-0x8(%rbp),%eax
imul   $0x3c,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <settimeofday@plt>
cmp    $0x0,%rax
je     1186 <fb_hSetTime+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <fb_hSetTime+0x6d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fb_hSetTime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movslq (%rsp),%rax
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x10,%ecx
add    %edx,%ecx
imul   $0x15180,%ecx,%ecx
imul   $0xe10,%ebp,%edx
imul   $0x3c,%ebx,%esi
add    %edx,%esi
add    %r15d,%esi
add    %eax,%esi
sub    %eax,%ecx
add    %esi,%ecx
mov    %ecx,(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <settimeofday@plt>
neg    %rax
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define i32 @fb_hSetTime(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.timeval
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%11 = load i32, i32* %10
%12 = srem i32 %11, 86400
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%14 = load i32, i32* %13
%15 = sub nsw i32 %14, %12
store i32 %15, i32* %13
%16 = load i32, i32* %5
%17 = mul nsw i32 %16, 3600
%18 = load i32, i32* %6
%19 = mul nsw i32 %18, 60
%20 = add nsw i32 %17, %19
%21 = load i32, i32* %7
%22 = add nsw i32 %20, %21
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%24 = load i32, i32* %23
%25 = add nsw i32 %24, %22
store i32 %25, i32* %23
%26 = call i64 @settimeofday(%struct.timeval* %8, i32 0)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %3
store i32 -1, i32* %4
br label %30
29: ; preds = %3
store i32 0, i32* %4
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define i32 @fb_hSetTime(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %4 to i8*
%6 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%8 = load i32, i32* %7
%9 = srem i32 %8, 86400
%10 = mul nsw i32 %0, 3600
%11 = mul nsw i32 %1, 60
%12 = add i32 %11, %10
%13 = add i32 %12, %2
%14 = add i32 %13, %8
%15 = sub i32 %14, %9
store i32 %15, i32* %7
%16 = call i64 @settimeofday(%struct.timeval* %4, i32 0)
%17 = icmp ne i64 %16, 0
%18 = sext i1 %17 to i32
ret i32 %18
}