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

/* Variables and functions */
int /*<<< orphan*/ ENOMEM;
scalar_t__ aspf(char **, int *, char *, int /*<<< orphan*/, int /*<<< orphan*/,
                int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
scalar_t__ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ np_uerror(int /*<<< orphan*/);
char *_ctl_get_date(char *name, void *a) {
  struct timeval tv;
  struct timezone tz;
  char *s = NULL;
  int len = 0;
  if (gettimeofday(&tv, &tz) < 0) {
    np_uerror(errno);
    goto error;
  }
  if (aspf(&s, &len, "%lu.%lu %d.%d\n", tv.tv_sec, tv.tv_usec,
           tz.tz_minuteswest, tz.tz_dsttime) < 0) {
    np_uerror(ENOMEM);
    goto error;
  }
  return s;
error:
  return NULL;
}


x86 assembly (clang, -O0):
<_ctl_get_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
jge    1179 <_ctl_get_date+0x49>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1040 <np_uerror@plt>
jmp    11c8 <_ctl_get_date+0x98>
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x28(%rbp),%eax
lea    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    0xe6a(%rip),%rdx
mov    %eax,(%rsp)
call   1050 <aspf@plt>
cmp    $0x0,%rax
jge    11bb <_ctl_get_date+0x8b>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1040 <np_uerror@plt>
jmp    11c8 <_ctl_get_date+0x98>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d0 <_ctl_get_date+0xa0>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ctl_get_date>:
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <gettimeofday@plt>
test   %rax,%rax
js     1193 <_ctl_get_date+0x63>
mov    0x20(%rsp),%r8d
mov    0x24(%rsp),%ecx
mov    0x18(%rsp),%eax
mov    0x1c(%rsp),%r9d
mov    %eax,(%rsp)
lea    0xe8b(%rip),%rdx
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <aspf@plt>
test   %rax,%rax
js     119c <_ctl_get_date+0x6c>
mov    0x10(%rsp),%rax
add    $0x28,%rsp
ret
mov    0x2e3e(%rip),%rax
jmp    11a3 <_ctl_get_date+0x73>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1040 <np_uerror@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32, i32 }
@errno = global i32 0
@.str = [15 x i8] c"%lu.%lu %d.%d\0A\00"
@ENOMEM = global i32 0
define i8* @_ctl_get_date(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.timeval
%7 = alloca %struct.timezone
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %8
store i32 0, i32* %9
%10 = call i64 @gettimeofday(%struct.timeval* %6, %struct.timezone* %7)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @errno
%14 = call i32 @np_uerror(i32 %13)
br label %31
15: ; preds = %2
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.timezone, %struct.timezone* %7, i32 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.timezone, %struct.timezone* %7, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i64 @aspf(i8** %8, i32* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19, i32 %21, i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %15
%27 = load i32, i32* @ENOMEM
%28 = call i32 @np_uerror(i32 %27)
br label %31
29: ; preds = %15
%30 = load i8*, i8** %8
store i8* %30, i8** %3
br label %32
31: ; preds = %26, %12
store i8* null, i8** %3
br label %32
32: ; preds = %31, %29
%33 = load i8*, i8** %3
ret i8* %33
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32, i32 }
@errno = global i32 0
@.str = [15 x i8] c"%lu.%lu %d.%d\0A\00"
@ENOMEM = global i32 0
define i8* @_ctl_get_date(i8* nocapture readnone %0, i8* nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timezone
%5 = alloca i8*
%6 = alloca i32
%7 = bitcast %struct.timeval* %3 to i8*
%8 = bitcast %struct.timezone* %4 to i8*
%9 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%10 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%11 = call i64 @gettimeofday(%struct.timeval* %3, %struct.timezone* %4)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @errno
%15 = tail call i32 @np_uerror(i32 %14)
br label %32
16: ; preds = %2
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.timezone, %struct.timezone* %4, i64 0, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.timezone, %struct.timezone* %4, i64 0, i32 0
%24 = load i32, i32* %23
%25 = call i64 @aspf(i8** %5, i32* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20, i32 %22, i32 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %16
%28 = load i32, i32* @ENOMEM
%29 = call i32 @np_uerror(i32 %28)
br label %32
30: ; preds = %16
%31 = load i8*, i8** %5
br label %32
32: ; preds = %13, %27, %30
%33 = phi i8* [ %31, %30 ], [ null, %27 ], [ null, %13 ]
ret i8* %33
}