#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;
struct timeval {
  long tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int gettimeofday(struct timeval *, int /*<<< orphan*/);
int octave_gettimeofday_wrapper(time_t *sec, long *usec) {
  struct timeval tv;
  int status = gettimeofday(&tv, 0);
  if (status < 0) {
    *sec = 0;
    *usec = 0;
  } else {
    *sec = tv.tv_sec;
    *usec = tv.tv_usec;
  }
  return status;
}


x86 assembly (clang, -O0):
<octave_gettimeofday_wrapper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1152 <octave_gettimeofday_wrapper+0x42>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
jmp    1166 <octave_gettimeofday_wrapper+0x56>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<octave_gettimeofday_wrapper>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
test   %eax,%eax
js     113a <octave_gettimeofday_wrapper+0x2a>
mov    0x10(%rsp),%ecx
mov    %ecx,(%rbx)
mov    0x8(%rsp),%rcx
jmp    1142 <octave_gettimeofday_wrapper+0x32>
movl   $0x0,(%rbx)
xor    %ecx,%ecx
mov    %rcx,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
define i32 @octave_gettimeofday_wrapper(i32* %0, i64* %1) {
%3 = alloca i32*
%4 = alloca i64*
%5 = alloca %struct.timeval
%6 = alloca i32
store i32* %0, i32** %3
store i64* %1, i64** %4
%7 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32*, i32** %3
store i32 0, i32* %11
%12 = load i64*, i64** %4
store i64 0, i64* %12
br label %20
13: ; preds = %2
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%15 = load i32, i32* %14
%16 = load i32*, i32** %3
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%18 = load i64, i64* %17
%19 = load i64*, i64** %4
store i64 %18, i64* %19
br label %20
20: ; preds = %13, %10
%21 = load i32, i32* %6
ret i32 %21
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
define i32 @octave_gettimeofday_wrapper(i32* nocapture writeonly %0, i64* nocapture writeonly %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
store i32 0, i32* %0
br label %13
8: ; preds = %2
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%10 = load i32, i32* %9
store i32 %10, i32* %0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = load i64, i64* %11
br label %13
13: ; preds = %8, %7
%14 = phi i64 [ %12, %8 ], [ 0, %7 ]
store i64 %14, i64* %1
ret i32 %5
}