#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 /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ write_error();
void timez() {
  struct timeval tv;
  do {
    if (!(gettimeofday(&tv, NULL) == 0)) {
      write_error();
      return;
    }
  } while (0);
  char *time = ctime(&tv.tv_sec);
  do {
    if (!(time != NULL)) {
      write_error();
      return;
    }
  } while (0);
  printf("%s", time);
}


x86 assembly (clang, -O0):
<timez>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
cmp    $0x0,%rax
je     116b <timez+0x2b>
mov    $0x0,%al
call   1060 <write_error@plt>
jmp    11a9 <timez+0x69>
jmp    1170 <timez+0x30>
lea    -0x8(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1194 <timez+0x54>
mov    $0x0,%al
call   1060 <write_error@plt>
jmp    11a9 <timez+0x69>
jmp    1199 <timez+0x59>
mov    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timez>:
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
test   %rax,%rax
je     1158 <timez+0x18>
xor    %eax,%eax
pop    %rcx
jmp    1060 <write_error@plt>
mov    %rsp,%rdi
call   1030 <ctime@plt>
test   %rax,%rax
je     1176 <timez+0x36>
lea    0xe94(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
pop    %rax
ret
xor    %eax,%eax
call   1060 <write_error@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [3 x i8] c"%s\00"
define void @timez() {
%1 = alloca %struct.timeval
%2 = alloca i8*
br label %3
3: ; preds = %0
%4 = call i64 @gettimeofday(%struct.timeval* %1, i32* null)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = call i32 (...) @write_error()
br label %21
8: ; preds = %3
br label %9
9: ; preds = %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%11 = call i8* @ctime(i32* %10)
store i8* %11, i8** %2
br label %12
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 (...) @write_error()
br label %21
17: ; preds = %12
br label %18
18: ; preds = %17
%19 = load i8*, i8** %2
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %15, %6
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [3 x i8] c"%s\00"
define void @timez() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i64 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 (...) @write_error()
br label %15
7: ; preds = %0
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = call i8* @ctime(i32* %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 (...) @write_error()
br label %15
13: ; preds = %7
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %15
15: ; preds = %11, %13, %5
ret void
}