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

/* Variables and functions */
int /*<<< orphan*/ _now(char *, int, char *);
char *getpromote(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char const *,
                            int);
void get_prefix(char *prefix, int len, const char *file, int line, int level) {
  memset(prefix, 0x0, len);
  char now[20];
  memset(now, 0, 20);
  _now(now, 20, "%Y-%m-%d %H:%M:%S");
  snprintf(prefix, len - 1, "[%s] %s [%s +%d] ", now, getpromote(level), file,
           line);
}


x86 assembly (clang, -O0):
<get_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    $0x14,%esi
lea    0xe78(%rip),%rdx
call   1030 <_now@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
call   1060 <getpromote@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%rcx
mov    %rax,%r8
mov    -0x18(%rbp),%r9
mov    -0x1c(%rbp),%eax
lea    0xe48(%rip),%rdx
mov    %eax,(%rsp)
call   1040 <snprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prefix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r12d
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
lea    0x10(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    0xe80(%rip),%rdx
mov    %r13,%rdi
mov    $0x14,%esi
call   1030 <_now@plt>
add    $0xffffffff,%ebp
mov    %r12d,%edi
call   1060 <getpromote@plt>
mov    %r15d,(%rsp)
lea    0xe6f(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r13,%rcx
mov    %rax,%r8
mov    %r14,%r9
call   1040 <snprintf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [18 x i8] c"[%s] %s [%s +%d] \00"
define void @get_prefix(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [20 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i32 @memset(i8* %12, i32 0, i32 %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 20)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%18 = call i32 @_now(i8* %17, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 1
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%23 = load i32, i32* %10
%24 = call i8* @getpromote(i32 %23)
%25 = load i8*, i8** %8
%26 = load i32, i32* %9
%27 = call i32 @snprintf(i8* %19, i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %24, i8* %25, i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [18 x i8] c"[%s] %s [%s +%d] \00"
define void @get_prefix(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca [20 x i8]
%7 = tail call i32 @memset(i8* %0, i32 0, i32 %1)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 20)
%10 = call i32 @_now(i8* %8, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = add nsw i32 %1, -1
%12 = call i8* @getpromote(i32 %4)
%13 = call i32 @snprintf(i8* %0, i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %12, i8* %2, i32 %3)
ret void
}