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

/* Variables and functions */
int /*<<< orphan*/ draw_string_at_position(char *, int /*<<< orphan*/ *, int,
                                           int, int const);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void add_timestamp_overlay(int width, int height, uint8_t *data) {
  const int width32 = ((width + 31) & ~31);
  char time_base[20];
  time_t rawtime;
  struct tm *timeinfo;
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  strftime(time_base, 20, "%Y-%m-%d %H:%M:%S", timeinfo);
  draw_string_at_position(time_base, data, width - (19 * (6)) - (3),
                          height - (11) - (3), width32);
}


x86 assembly (clang, -O0):
<add_timestamp_overlay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1f,%eax
and    $0xffffffe0,%eax
mov    %eax,-0x14(%rbp)
lea    -0x34(%rbp),%rdi
call   1050 <time@plt>
lea    -0x34(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0x14,%esi
lea    0xe78(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
sub    $0x72,%edx
sub    $0x3,%edx
mov    -0x8(%rbp),%ecx
sub    $0xb,%ecx
sub    $0x3,%ecx
mov    -0x14(%rbp),%r8d
call   1040 <draw_string_at_position@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_timestamp_overlay>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%ebx
lea    0x1f(%rbx),%ebp
and    $0xffffffe0,%ebp
lea    0xc(%rsp),%r12
mov    %r12,%rdi
call   1050 <time@plt>
mov    %r12,%rdi
call   1030 <localtime@plt>
lea    0xe8a(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x14,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
add    $0xffffff8b,%ebx
add    $0xfffffff2,%r15d
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
call   1040 <draw_string_at_position@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define void @add_timestamp_overlay(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [20 x i8]
%9 = alloca i32
%10 = alloca %struct.tm*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 31
%13 = and i32 %12, -32
store i32 %13, i32* %7
%14 = call i32 @time(i32* %9)
%15 = call %struct.tm* @localtime(i32* %9)
store %struct.tm* %15, %struct.tm** %10
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%17 = load %struct.tm*, %struct.tm** %10
%18 = call i32 @strftime(i8* %16, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%20 = load i32*, i32** %6
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 114
%23 = sub nsw i32 %22, 3
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 11
%26 = sub nsw i32 %25, 3
%27 = load i32, i32* %7
%28 = call i32 @draw_string_at_position(i8* %19, i32* %20, i32 %23, i32 %26, i32 %27)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define void @add_timestamp_overlay(i32 %0, i32 %1, i32* %2) {
%4 = alloca [20 x i8]
%5 = alloca i32
%6 = add nsw i32 %0, 31
%7 = and i32 %6, -32
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
%10 = call i32 @time(i32* %5)
%11 = call %struct.tm* @localtime(i32* %5)
%12 = call i32 @strftime(i8* %8, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
%13 = add nsw i32 %0, -117
%14 = add nsw i32 %1, -14
%15 = call i32 @draw_string_at_position(i8* %8, i32* %2, i32 %13, i32 %14, i32 %7)
ret void
}