#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 scalar_t__ time_t;

/* Variables and functions */
int /*<<< orphan*/ Error(char *, int, char *, scalar_t__, scalar_t__,
                         scalar_t__);
scalar_t__ getnettime();
int /*<<< orphan*/ setnettime(scalar_t__);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int handlesettime(void *sender, int cargc, char **cargv) {
  time_t newtime;
  if (cargc > 0) {
    newtime = strtol(cargv[0], NULL, 10);
    Error("irc", 1, "Received settime: %lu (current time is %lu, offset %ld)",
          newtime, getnettime(), newtime - getnettime());
    setnettime(newtime);
  }
  return 0;
}


x86 assembly (clang, -O0):
<handlesettime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11c8 <handlesettime+0x88>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <getnettime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <getnettime@plt>
mov    -0x38(%rbp),%r9
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
sub    %rax,%r9
lea    0xe52(%rip),%rdi
mov    $0x1,%esi
lea    0xe4a(%rip),%rdx
call   1040 <Error@plt>
mov    -0x20(%rbp),%rdi
call   1060 <setnettime@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handlesettime>:
test   %esi,%esi
jle    119e <handlesettime+0x5e>
push   %r14
push   %rbx
push   %rax
mov    (%rdx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <getnettime@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <getnettime@plt>
mov    %rbx,%r9
sub    %rax,%r9
lea    0xe88(%rip),%rdi
lea    0xe85(%rip),%rdx
mov    $0x1,%esi
mov    %rbx,%rcx
mov    %r14,%r8
call   1040 <Error@plt>
mov    %rbx,%rdi
call   1060 <setnettime@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"irc\00"
@.str.1 = [56 x i8] c"Received settime: %lu (current time is %lu, offset %ld)\00"
define i32 @handlesettime(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %3
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i64 @strtol(i8* %13, i32* null, i32 10)
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = call i64 (...) @getnettime()
%17 = load i64, i64* %7
%18 = call i64 (...) @getnettime()
%19 = sub nsw i64 %17, %18
%20 = call i32 @Error(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i64 %15, i64 %16, i64 %19)
%21 = load i64, i64* %7
%22 = call i32 @setnettime(i64 %21)
br label %23
23: ; preds = %10, %3
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"irc\00"
@.str.1 = [56 x i8] c"Received settime: %lu (current time is %lu, offset %ld)\00"
define i32 @handlesettime(i8* nocapture readnone %0, i32 %1, i8** nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %13
5: ; preds = %3
%6 = load i8*, i8** %2
%7 = tail call i64 @strtol(i8* nocapture %6, i32* null, i32 10)
%8 = tail call i64 (...) @getnettime()
%9 = tail call i64 (...) @getnettime()
%10 = sub nsw i64 %7, %9
%11 = tail call i32 @Error(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i64 %7, i64 %8, i64 %10)
%12 = tail call i32 @setnettime(i64 %7)
br label %13
13: ; preds = %5, %3
ret i32 0
}