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

/* Variables and functions */
int LOG_DAEMON;
int LOG_INFO;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ syslog(int, char *);
void get_now(struct timeval *time, unsigned short debug) {
  if (gettimeofday(time, NULL) != 0) {
    if (debug > 0) {
      fprintf(stderr, "Can't get current time.\n");
    } else {
      syslog(LOG_DAEMON | LOG_INFO,
             "gettimeofday() failed. Can't get current time.");
    }
  }
  return;
}


x86 assembly (clang, -O0):
<get_now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
je     11a4 <get_now+0x74>
movzwl -0xa(%rbp),%eax
cmp    $0x0,%eax
jle    1181 <get_now+0x51>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
jmp    119f <get_now+0x6f>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    0x2e3f(%rip),%rax
or     (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1050 <syslog@plt>
jmp    11a4 <get_now+0x74>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_now>:
push   %rbx
mov    %esi,%ebx
xor    %esi,%esi
call   1030 <gettimeofday@plt>
test   %rax,%rax
je     115a <get_now+0x2a>
test   %bx,%bx
je     115c <get_now+0x2c>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
pop    %rbx
jmp    1040 <fprintf@plt>
pop    %rbx
ret
mov    0x2e85(%rip),%rax
mov    0x2e66(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
lea    0xea4(%rip),%rsi
pop    %rbx
jmp    1050 <syslog@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [25 x i8] c"Can't get current time.\0A\00"
@LOG_DAEMON = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [47 x i8] c"gettimeofday() failed. Can't get current time.\00"
define void @get_now(%struct.timeval* %0, i16 zeroext %1) {
%3 = alloca %struct.timeval*
%4 = alloca i16
store %struct.timeval* %0, %struct.timeval** %3
store i16 %1, i16* %4
%5 = load %struct.timeval*, %struct.timeval** %3
%6 = call i64 @gettimeofday(%struct.timeval* %5, i32* null)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %2
%9 = load i16, i16* %4
%10 = zext i16 %9 to i32
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %20
15: ; preds = %8
%16 = load i32, i32* @LOG_DAEMON
%17 = load i32, i32* @LOG_INFO
%18 = or i32 %16, %17
%19 = call i32 @syslog(i32 %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %15, %12
br label %21
21: ; preds = %20, %2
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [25 x i8] c"Can't get current time.\0A\00"
@LOG_DAEMON = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [47 x i8] c"gettimeofday() failed. Can't get current time.\00"
define void @get_now(%struct.timeval* nocapture %0, i16 zeroext %1) {
%3 = tail call i64 @gettimeofday(%struct.timeval* %0, i32* null)
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = icmp eq i16 %1, 0
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %15
10: ; preds = %5
%11 = load i32, i32* @LOG_DAEMON
%12 = load i32, i32* @LOG_INFO
%13 = or i32 %12, %11
%14 = tail call i32 @syslog(i32 %13, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %7, %10, %2
ret void
}