#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 int /*<<< orphan*/ time_t;
typedef int /*<<< orphan*/ b;

/* Variables and functions */
int /*<<< orphan*/ _CLOSE(int);
int _OPEN(char *, int /*<<< orphan*/);
int /*<<< orphan*/ _PREAD(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ atol(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
time_t time(time_t *tp) {
  char b[20];
  int f;
  time_t t;
  memset(b, 0, sizeof(b));
  f = _OPEN("/dev/time", 0);
  if (f >= 0) {
    _PREAD(f, b, sizeof(b), 0);
    _CLOSE(f);
  }
  t = atol(b);
  if (tp)
    *tp = t;
  return t;
}


x86 assembly (clang, -O0):
<time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    0xe8d(%rip),%rdi
xor    %esi,%esi
call   1040 <_OPEN@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11a2 <time+0x52>
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1030 <_PREAD@plt>
mov    -0x24(%rbp),%edi
call   1060 <_CLOSE@plt>
lea    -0x20(%rbp),%rdi
call   1070 <atol@plt>
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c2 <time+0x72>
mov    -0x28(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    0xe91(%rip),%rdi
xor    %esi,%esi
call   1040 <_OPEN@plt>
test   %eax,%eax
js     1194 <time+0x44>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1030 <_PREAD@plt>
mov    %ebp,%edi
call   1060 <_CLOSE@plt>
mov    %rsp,%rdi
call   1070 <atol@plt>
test   %rbx,%rbx
je     11a3 <time+0x53>
mov    %eax,(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/time\00"
define i32 @time(i32* %0) {
%2 = alloca i32*
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 20)
%8 = call i32 @_OPEN(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %1
%12 = load i32, i32* %4
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%14 = call i32 @_PREAD(i32 %12, i8* %13, i32 20, i32 0)
%15 = load i32, i32* %4
%16 = call i32 @_CLOSE(i32 %15)
br label %17
17: ; preds = %11, %1
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%19 = call i32 @atol(i8* %18)
store i32 %19, i32* %5
%20 = load i32*, i32** %2
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* %5
%24 = load i32*, i32** %2
store i32 %23, i32* %24
br label %25
25: ; preds = %22, %17
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/time\00"
define i32 @time(i32* writeonly %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 20)
%5 = call i32 @_OPEN(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @_PREAD(i32 %5, i8* %3, i32 20, i32 0)
%9 = call i32 @_CLOSE(i32 %5)
br label %10
10: ; preds = %7, %1
%11 = call i32 @atol(i8* %3)
%12 = icmp eq i32* %0, null
br i1 %12, label %14, label %13
13: ; preds = %10
store i32 %11, i32* %0
br label %14
14: ; preds = %13, %10
ret i32 %11
}