#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_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ settimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ str_to_tv(char *, struct timeval *);
char *strerror(int /*<<< orphan*/);
char *tv_to_str(struct timeval *);
int main(int argc, char **argv) {
  struct timeval tv, otv;
  if (argc != 2) {
    fprintf(stderr,
            "%s: use \"%s <delta>\"\n"
            "   <delta> is a floating-point number of seconds\n",
            argv[0], argv[0]);
    exit(1);
  }
  if (str_to_tv(argv[1], &tv) < 0) {
    fprintf(stderr, "%s: not a time (float) number \"%s\"\n", argv[0], argv[1]);
    exit(1);
  }
  fprintf(stderr, "Requesting time-jump: %s seconds\n", tv_to_str(&tv));
  if (gettimeofday(&otv, NULL) < 0) {
    fprintf(stderr, "%s: gettimeofday(): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  otv.tv_sec += tv.tv_sec;
  otv.tv_usec += tv.tv_usec;
  if (otv.tv_usec > 1000 * 1000) {
    otv.tv_usec -= 1000 * 1000;
    otv.tv_sec++;
  }
  if (settimeofday(&otv, NULL) < 0) {
    fprintf(stderr, "%s: settimeofday(): %s\n", argv[0], strerror(errno));
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11bf <main+0x4f>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <str_to_tv@plt>
cmp    $0x0,%rax
jge    120a <main+0x9a>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <tv_to_str@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
cmp    $0x0,%rax
jge    1291 <main+0x121>
mov    0x2d8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0xf4240,-0x30(%rbp)
jle    12ca <main+0x15a>
mov    -0x30(%rbp),%eax
sub    $0xf4240,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <settimeofday@plt>
cmp    $0x0,%rax
jge    1328 <main+0x1b8>
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    %rax,%rcx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11b2 <main+0x42>
mov    0x8(%rbx),%rdi
lea    0x10(%rsp),%rsi
call   1040 <str_to_tv@plt>
mov    0x2e4b(%rip),%r14
mov    (%r14),%ebp
test   %rax,%rax
jns    11cd <main+0x5d>
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xe9c(%rip),%rsi
mov    %ebp,%edi
jmp    127b <main+0x10b>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rcx
lea    0xe3b(%rip),%rsi
mov    %rcx,%rdx
jmp    127b <main+0x10b>
lea    0x10(%rsp),%rdi
call   1030 <tv_to_str@plt>
lea    0xe8d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
test   %rax,%rax
jns    1216 <main+0xa6>
mov    (%r14),%ebp
mov    (%rbx),%rbx
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe79(%rip),%rsi
jmp    1273 <main+0x103>
mov    0x8(%rsp),%rax
add    0x18(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    (%rsp),%ecx
add    0x10(%rsp),%ecx
mov    %ecx,(%rsp)
cmp    $0xf4241,%ecx
jl     1249 <main+0xd9>
add    $0xfff0bdc0,%ecx
mov    %ecx,(%rsp)
add    $0x1,%rax
mov    %rax,0x8(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1070 <settimeofday@plt>
test   %rax,%rax
jns    128c <main+0x11c>
mov    (%r14),%ebp
mov    (%rbx),%rbx
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe32(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@stderr = global i32 0
@.str = [71 x i8] c"%s: use \22%s <delta>\22\0A <delta> is a floating-point number of seconds\0A\00"
@.str.1 = [36 x i8] c"%s: not a time (float) number \22%s\22\0A\00"
@.str.2 = [34 x i8] c"Requesting time-jump: %s seconds\0A\00"
@.str.3 = [24 x i8] c"%s: gettimeofday(): %s\0A\00"
@errno = global i32 0
@.str.4 = [24 x i8] c"%s: settimeofday(): %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @str_to_tv(i8* %23, %struct.timeval* %6)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %20
%37 = load i32, i32* @stderr
%38 = call i8* @tv_to_str(%struct.timeval* %6)
%39 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = call i64 @gettimeofday(%struct.timeval* %7, i32* null)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %51
42: ; preds = %36
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %46, i8* %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %36
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%53 = load i64, i64* %52
%54 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%55 = load i64, i64* %54
%56 = add nsw i64 %55, %53
store i64 %56, i64* %54
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%60 = load i32, i32* %59
%61 = add nsw i32 %60, %58
store i32 %61, i32* %59
%62 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%63 = load i32, i32* %62
%64 = icmp sgt i32 %63, 1000000
br i1 %64, label %65, label %72
65: ; preds = %51
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%67 = load i32, i32* %66
%68 = sub nsw i32 %67, 1000000
store i32 %68, i32* %66
%69 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%70 = load i64, i64* %69
%71 = add nsw i64 %70, 1
store i64 %71, i64* %69
br label %72
72: ; preds = %65, %51
%73 = call i64 @settimeofday(%struct.timeval* %7, i32* null)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %84
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 0
%79 = load i8*, i8** %78
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %79, i8* %81)
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %72
%85 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@stderr = global i32 0
@.str = [71 x i8] c"%s: use \22%s <delta>\22\0A <delta> is a floating-point number of seconds\0A\00"
@.str.1 = [36 x i8] c"%s: not a time (float) number \22%s\22\0A\00"
@.str.2 = [34 x i8] c"Requesting time-jump: %s seconds\0A\00"
@.str.3 = [24 x i8] c"%s: gettimeofday(): %s\0A\00"
@errno = global i32 0
@.str.4 = [24 x i8] c"%s: settimeofday(): %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @str_to_tv(i8* %15, %struct.timeval* %3)
%17 = icmp slt i64 %16, 0
%18 = load i32, i32* @stderr
br i1 %17, label %19, label %24
19: ; preds = %13
%20 = load i8*, i8** %1
%21 = load i8*, i8** %14
%22 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %13
%25 = call i8* @tv_to_str(%struct.timeval* %3)
%26 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i64 @gettimeofday(%struct.timeval* %4, i32* null)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %31, i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %24
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%38 = load i64, i64* %37
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%40 = load i64, i64* %39
%41 = add nsw i64 %40, %38
store i64 %41, i64* %39
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%45 = load i32, i32* %44
%46 = add nsw i32 %45, %43
store i32 %46, i32* %44
%47 = icmp sgt i32 %46, 1000000
br i1 %47, label %48, label %51
48: ; preds = %36
%49 = add nsw i32 %46, -1000000
store i32 %49, i32* %44
%50 = add nsw i64 %41, 1
store i64 %50, i64* %39
br label %51
51: ; preds = %48, %36
%52 = call i64 @settimeofday(%struct.timeval* %4, i32* null)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = load i8*, i8** %1
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %56, i8* %58)
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %51
%62 = call i32 @exit(i32 0)
unreachable
}