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

/* Variables and functions */
int do_tests();
int getopt(int, char **, char *);
scalar_t__ is32bits();
int ksft_exit_fail();
int ksft_exit_pass();
int /*<<< orphan*/ settime(long long);
long long time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int ret = 0;
  int opt, dangerous = 0;
  time_t start;
  while ((opt = getopt(argc, argv, "d")) != -1) {
    switch (opt) {
    case 'd':
      dangerous = 1;
    }
  }
  start = time(0);
  if (!settime((-0x7fffffffL))) {
    ret = -1;
    goto out;
  }
  if (!settime(((long long)((1ULL << 63) - 1)))) {
    ret = -1;
    goto out;
  }
  if (!is32bits() &&
      !settime((((long long)~((unsigned long long)1 << 63)) / 1000000000LL))) {
    ret = -1;
    goto out;
  }
  settime(1);
  ret = do_tests();
  if (ret)
    goto out;
  settime(0x7fffffffL - 600);
  ret = do_tests();
  if (ret)
    goto out;
  if (is32bits() && !dangerous)
    goto out;
  settime(0x7fffffffL - 10);
  ret = do_tests();
  if (ret)
    goto out;
  settime((((long long)~((unsigned long long)1 << 63)) / 1000000000LL) - 600);
  ret = do_tests();
out:
  settime(start);
  if (ret)
    return ksft_exit_fail();
  return ksft_exit_pass();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5e(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11d0 <main+0x60>
mov    -0x18(%rbp),%eax
sub    $0x64,%eax
jne    11cb <main+0x5b>
jmp    11c4 <main+0x54>
movl   $0x1,-0x1c(%rbp)
jmp    1194 <main+0x24>
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,-0x28(%rbp)
mov    $0xffffffff80000001,%rdi
call   1070 <settime@plt>
cmp    $0x0,%eax
jne    11fc <main+0x8c>
movl   $0xffffffff,-0x14(%rbp)
jmp    12f7 <main+0x187>
movabs $0x7fffffffffffffff,%rdi
ff ff 7f
call   1070 <settime@plt>
cmp    $0x0,%eax
jne    1220 <main+0xb0>
movl   $0xffffffff,-0x14(%rbp)
jmp    12f7 <main+0x187>
mov    $0x0,%al
call   1050 <is32bits@plt>
cmp    $0x0,%rax
jne    1255 <main+0xe5>
movabs $0x225c17d04,%rdi
call   1070 <settime@plt>
cmp    $0x0,%eax
jne    1255 <main+0xe5>
movl   $0xffffffff,-0x14(%rbp)
jmp    12f7 <main+0x187>
mov    $0x1,%edi
call   1070 <settime@plt>
mov    $0x0,%al
call   1090 <do_tests@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1278 <main+0x108>
jmp    12f7 <main+0x187>
mov    $0x7ffffda7,%edi
call   1070 <settime@plt>
mov    $0x0,%al
call   1090 <do_tests@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     129b <main+0x12b>
jmp    12f7 <main+0x187>
mov    $0x0,%al
call   1050 <is32bits@plt>
cmp    $0x0,%rax
je     12bb <main+0x14b>
cmpl   $0x0,-0x1c(%rbp)
jne    12bb <main+0x14b>
jmp    12f7 <main+0x187>
mov    $0x7ffffff5,%edi
call   1070 <settime@plt>
mov    $0x0,%al
call   1090 <do_tests@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12de <main+0x16e>
jmp    12f7 <main+0x187>
movabs $0x225c17aac,%rdi
call   1070 <settime@plt>
mov    $0x0,%al
call   1090 <do_tests@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <settime@plt>
cmpl   $0x0,-0x14(%rbp)
je     1319 <main+0x1a9>
mov    $0x0,%al
call   1040 <ksft_exit_fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1323 <main+0x1b3>
mov    $0x0,%al
call   1030 <ksft_exit_pass@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r15d,%r15d
lea    0xe7a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0x64,%eax
je     11a9 <main+0x39>
cmp    $0xffffffff,%eax
jne    1190 <main+0x20>
jmp    11ae <main+0x3e>
mov    $0x1,%r15b
jmp    1190 <main+0x20>
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rbx
mov    $0xffffffff80000001,%rdi
call   1070 <settime@plt>
test   %eax,%eax
je     122b <main+0xbb>
movabs $0x7fffffffffffffff,%rdi
ff ff 7f
call   1070 <settime@plt>
test   %eax,%eax
je     122b <main+0xbb>
xor    %eax,%eax
call   1050 <is32bits@plt>
test   %rax,%rax
jne    1201 <main+0x91>
movabs $0x225c17aac,%rdi
add    $0x258,%rdi
call   1070 <settime@plt>
test   %eax,%eax
je     122b <main+0xbb>
mov    $0x1,%edi
call   1070 <settime@plt>
xor    %eax,%eax
call   1090 <do_tests@plt>
test   %eax,%eax
jne    122b <main+0xbb>
mov    $0x7ffffda7,%edi
call   1070 <settime@plt>
xor    %eax,%eax
call   1090 <do_tests@plt>
test   %eax,%eax
je     1244 <main+0xd4>
mov    %rbx,%rdi
call   1070 <settime@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ksft_exit_fail@plt>
xor    %eax,%eax
call   1050 <is32bits@plt>
test   %rax,%rax
sete   %al
or     %r15b,%al
test   $0x1,%al
je     1293 <main+0x123>
mov    $0x7ffffff5,%edi
call   1070 <settime@plt>
xor    %eax,%eax
call   1090 <do_tests@plt>
test   %eax,%eax
jne    122b <main+0xbb>
movabs $0x225c17aac,%rdi
call   1070 <settime@plt>
xor    %eax,%eax
call   1090 <do_tests@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <settime@plt>
test   %ebp,%ebp
jne    1233 <main+0xc3>
jmp    129b <main+0x12b>
mov    %rbx,%rdi
call   1070 <settime@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ksft_exit_pass@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %8
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %7
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %7
switch i32 %16, label %18 [
i32 100, label %17
]
17: ; preds = %15
store i32 1, i32* %8
br label %18
18: ; preds = %17, %15
br label %10
19: ; preds = %10
%20 = call i64 @time(i32 0)
store i64 %20, i64* %9
%21 = call i32 @settime(i64 -2147483647)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
store i32 -1, i32* %6
br label %63
24: ; preds = %19
%25 = call i32 @settime(i64 9223372036854775807)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24
store i32 -1, i32* %6
br label %63
28: ; preds = %24
%29 = call i64 (...) @is32bits()
%30 = icmp ne i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = call i32 @settime(i64 9223372036)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31
store i32 -1, i32* %6
br label %63
35: ; preds = %31, %28
%36 = call i32 @settime(i64 1)
%37 = call i32 (...) @do_tests()
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %35
br label %63
41: ; preds = %35
%42 = call i32 @settime(i64 2147483047)
%43 = call i32 (...) @do_tests()
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
br label %63
47: ; preds = %41
%48 = call i64 (...) @is32bits()
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i32, i32* %8
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %50
br label %63
54: ; preds = %50, %47
%55 = call i32 @settime(i64 2147483637)
%56 = call i32 (...) @do_tests()
store i32 %56, i32* %6
%57 = load i32, i32* %6
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %54
br label %63
60: ; preds = %54
%61 = call i32 @settime(i64 9223371436)
%62 = call i32 (...) @do_tests()
store i32 %62, i32* %6
br label %63
63: ; preds = %60, %59, %53, %46, %40, %34, %27, %23
%64 = load i64, i64* %9
%65 = call i32 @settime(i64 %64)
%66 = load i32, i32* %6
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 (...) @ksft_exit_fail()
store i32 %69, i32* %3
br label %72
70: ; preds = %63
%71 = call i32 (...) @ksft_exit_pass()
store i32 %71, i32* %3
br label %72
72: ; preds = %70, %68
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = phi i1 [ false, %2 ], [ true, %5 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %5 [
i32 -1, label %7
i32 100, label %3
]
7: ; preds = %5
%8 = tail call i64 @time(i32 0)
%9 = tail call i32 @settime(i64 -2147483647)
%10 = icmp eq i32 %9, 0
br i1 %10, label %38, label %11
11: ; preds = %7
%12 = tail call i32 @settime(i64 9223372036854775807)
%13 = icmp eq i32 %12, 0
br i1 %13, label %38, label %14
14: ; preds = %11
%15 = tail call i64 (...) @is32bits()
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i32 @settime(i64 9223372036)
%19 = icmp eq i32 %18, 0
br i1 %19, label %38, label %20
20: ; preds = %17, %14
%21 = tail call i32 @settime(i64 1)
%22 = tail call i32 (...) @do_tests()
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = tail call i32 @settime(i64 2147483047)
%26 = tail call i32 (...) @do_tests()
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = tail call i64 (...) @is32bits()
%30 = icmp eq i64 %29, 0
%31 = or i1 %30, %4
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = tail call i32 @settime(i64 %8)
br label %47
34: ; preds = %28
%35 = tail call i32 @settime(i64 2147483637)
%36 = tail call i32 (...) @do_tests()
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %20, %24, %34, %7, %11, %17
%39 = tail call i32 @settime(i64 %8)
br label %45
40: ; preds = %34
%41 = tail call i32 @settime(i64 9223371436)
%42 = tail call i32 (...) @do_tests()
%43 = tail call i32 @settime(i64 %8)
%44 = icmp eq i32 %42, 0
br i1 %44, label %47, label %45
45: ; preds = %38, %40
%46 = tail call i32 (...) @ksft_exit_fail()
br label %49
47: ; preds = %32, %40
%48 = tail call i32 (...) @ksft_exit_pass()
br label %49
49: ; preds = %47, %45
%50 = phi i32 [ %46, %45 ], [ %48, %47 ]
ret i32 %50
}