#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*/ b;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
char *luaL_opt_lstr(int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ lua_error(char *);
int /*<<< orphan*/ lua_pushstring(char *);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void io_date(void) {
  char b[256];
  char *s = (luaL_opt_lstr((1), ("%c"), NULL));
  struct tm *tm;
  time_t t;
  time(&t);
  tm = localtime(&t);
  if (strftime(b, sizeof(b), s, tm))
    lua_pushstring(b);
  else
    lua_error("invalid `date' format");
}


x86 assembly (clang, -O0):
<io_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    $0x1,%edi
lea    0xe89(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <luaL_opt_lstr@plt>
mov    %rax,-0x108(%rbp)
lea    -0x114(%rbp),%rdi
call   1050 <time@plt>
lea    -0x114(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x110(%rbp)
lea    -0x100(%rbp),%rdi
mov    -0x108(%rbp),%rdx
mov    -0x110(%rbp),%rcx
mov    $0x100,%esi
call   1070 <strftime@plt>
cmp    $0x0,%rax
je     11e0 <io_date+0x80>
lea    -0x100(%rbp),%rdi
call   1080 <lua_pushstring@plt>
jmp    11ec <io_date+0x8c>
lea    0xe1c(%rip),%rdi
call   1060 <lua_error@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_date>:
push   %r14
push   %rbx
sub    $0x118,%rsp
lea    0xe8f(%rip),%rsi
mov    $0x1,%edi
xor    %edx,%edx
call   1040 <luaL_opt_lstr@plt>
mov    %rax,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
test   %rax,%rax
je     11bb <io_date+0x5b>
lea    0x10(%rsp),%rdi
call   1080 <lua_pushstring@plt>
jmp    11c7 <io_date+0x67>
lea    0xe41(%rip),%rdi
call   1060 <lua_error@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%c\00"
@.str.1 = [22 x i8] c"invalid `date' format\00"
define void @io_date() {
%1 = alloca [256 x i8]
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = call i8* @luaL_opt_lstr(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
store i8* %5, i8** %2
%6 = call i32 @time(i32* %4)
%7 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %7, %struct.tm** %3
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = load %struct.tm*, %struct.tm** %3
%11 = call i64 @strftime(i8* %8, i32 256, i8* %9, %struct.tm* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%15 = call i32 @lua_pushstring(i8* %14)
br label %18
16: ; preds = %0
%17 = call i32 @lua_error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%c\00"
@.str.1 = [22 x i8] c"invalid `date' format\00"
define void @io_date() {
%1 = alloca [256 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = tail call i8* @luaL_opt_lstr(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* null)
%5 = bitcast i32* %2 to i8*
%6 = call i32 @time(i32* %2)
%7 = call %struct.tm* @localtime(i32* %2)
%8 = call i64 @strftime(i8* %3, i32 256, i8* %4, %struct.tm* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @lua_pushstring(i8* %3)
br label %14
12: ; preds = %0
%13 = call i32 @lua_error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
ret void
}