#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
scalar_t__ settimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int ac, char **av) {
  struct timeval tv;
  if (ac < 2) {
    fprintf(stderr, "Syntax addtime (delta_seconds)\n");
    return -1;
  }
  int delta = atoi(av[1]);
  if (gettimeofday(&tv, NULL) < 0) {
    perror("gettimeofday");
    return -2;
  }
  tv.tv_sec += delta;
  if (settimeofday(&tv, NULL) < 0) {
    perror("settimeofday");
    return -2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
jge    11d0 <main+0x80>
lea    0xe61(%rip),%rdi
call   1060 <perror@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    120f <main+0xbf>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <settimeofday@plt>
cmp    $0x0,%rax
jge    1208 <main+0xb8>
lea    0xe36(%rip),%rdi
call   1060 <perror@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    120f <main+0xbf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1174 <main+0x24>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    11a2 <main+0x52>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
test   %rax,%rax
js     11ab <main+0x5b>
add    %ebp,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <settimeofday@plt>
test   %rax,%rax
js     11b4 <main+0x64>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe6e(%rip),%rdi
jmp    11bb <main+0x6b>
lea    0xe72(%rip),%rdi
call   1060 <perror@plt>
mov    $0xfffffffe,%ebx
jmp    11a2 <main+0x52>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"Syntax addtime (delta_seconds)\0A\00"
@.str.1 = [13 x i8] c"gettimeofday\00"
@.str.2 = [13 x i8] c"settimeofday\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %7
%18 = call i64 @gettimeofday(%struct.timeval* %6, i32* null)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %3
br label %32
22: ; preds = %13
%23 = load i32, i32* %7
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%25 = load i32, i32* %24
%26 = add nsw i32 %25, %23
store i32 %26, i32* %24
%27 = call i64 @settimeofday(%struct.timeval* %6, i32* null)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 -2, i32* %3
br label %32
31: ; preds = %22
store i32 0, i32* %3
br label %32
32: ; preds = %31, %29, %20, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"Syntax addtime (delta_seconds)\0A\00"
@.str.1 = [13 x i8] c"gettimeofday\00"
@.str.2 = [13 x i8] c"settimeofday\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %25
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = call i64 @gettimeofday(%struct.timeval* %3, i32* null)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %25
17: ; preds = %9
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%19 = load i32, i32* %18
%20 = add nsw i32 %19, %12
store i32 %20, i32* %18
%21 = call i64 @settimeofday(%struct.timeval* %3, i32* null)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %15, %23, %17, %6
%26 = phi i32 [ -1, %6 ], [ -2, %15 ], [ -2, %23 ], [ 0, %17 ]
ret i32 %26
}