#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 tm {
  int dummy;
};
typedef int /*<<< orphan*/ output;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ strftime(char *, int, char const *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void sys_clock_currentTimeFormatted(const char *format, char *output) {
  time_t now;
  struct tm *tmp;
  time(&now);
  tmp = localtime(&now);
  if (tmp == NULL) {
    return;
  }
  if (strftime(output, sizeof(output), format, tmp) == 0) {
    return;
  }
}


x86 assembly (clang, -O0):
<sys_clock_currentTimeFormatted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1166 <sys_clock_currentTimeFormatted+0x36>
jmp    118b <sys_clock_currentTimeFormatted+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x8,%esi
call   1050 <strftime@plt>
cmp    $0x0,%rax
jne    118b <sys_clock_currentTimeFormatted+0x5b>
jmp    118b <sys_clock_currentTimeFormatted+0x5b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_clock_currentTimeFormatted>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     116c <sys_clock_currentTimeFormatted+0x3c>
mov    %r15,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1050 <strftime@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define void @sys_clock_currentTimeFormatted(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.tm*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i32 @time(i32* %5)
%8 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %8, %struct.tm** %6
%9 = load %struct.tm*, %struct.tm** %6
%10 = icmp eq %struct.tm* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
br label %19
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = load %struct.tm*, %struct.tm** %6
%16 = call i64 @strftime(i8* %13, i32 8, i8* %14, %struct.tm* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
br label %19
19: ; preds = %11, %18, %12
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define void @sys_clock_currentTimeFormatted(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @time(i32* %3)
%6 = call %struct.tm* @localtime(i32* %3)
%7 = icmp eq %struct.tm* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i64 @strftime(i8* %1, i32 8, i8* %0, %struct.tm* %6)
br label %10
10: ; preds = %8, %2
ret void
}