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

/* Variables and functions */
int /*<<< orphan*/ os_freakout();
int os_system_time(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int *);
time_t time(time_t *tp) {
  time_t seconds;
  time_t milliseconds;
  int rc;
  if (os_system_time(&seconds, &milliseconds, &rc) == -1)
    os_freakout();
  if (rc != 0)
    return 0;
  if (tp != NULL)
    *tp = seconds;
  return seconds;
}


x86 assembly (clang, -O0):
<time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <os_system_time@plt>
cmp    $0xffffffff,%eax
jne    114d <time+0x2d>
mov    $0x0,%al
call   1040 <os_freakout@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1163 <time+0x43>
movl   $0x0,-0x4(%rbp)
jmp    117d <time+0x5d>
cmpq   $0x0,-0x10(%rbp)
je     1177 <time+0x57>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1030 <os_system_time@plt>
cmp    $0xffffffff,%eax
jne    1148 <time+0x28>
xor    %eax,%eax
call   1040 <os_freakout@plt>
xor    %eax,%eax
cmpl   $0x0,0x4(%rsp)
jne    115c <time+0x3c>
mov    0x8(%rsp),%eax
test   %rbx,%rbx
je     115c <time+0x3c>
mov    %eax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @time(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
%7 = call i32 @os_system_time(i32* %4, i32* %5, i32* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 (...) @os_freakout()
br label %11
11: ; preds = %9, %1
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %2
br label %23
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %4
%20 = load i32*, i32** %3
store i32 %19, i32* %20
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %4
store i32 %22, i32* %2
br label %23
23: ; preds = %21, %14
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @time(i32* writeonly %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 @os_system_time(i32* %2, i32* %3, i32* %4)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (...) @os_freakout()
br label %12
12: ; preds = %10, %1
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = icmp eq i32* %0, null
%17 = load i32, i32* %2
br i1 %16, label %19, label %18
18: ; preds = %15
store i32 %17, i32* %0
br label %19
19: ; preds = %15, %18, %12
%20 = phi i32 [ 0, %12 ], [ %17, %18 ], [ %17, %15 ]
ret i32 %20
}