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

/* Variables and functions */
char *get_formatted_time();
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *, int,
                            char *);
int /*<<< orphan*/ vsnprintf(char *, int, char const *, int /*<<< orphan*/);
void generate_infomsg(char buf[512], const char *format, const char *file,
                      int line, va_list ap) {
  char userMsg[512];
  vsnprintf(userMsg, 512, format, ap);
  snprintf(buf, 512, "%s INFO[%s:%d] %s\n", get_formatted_time(), file, line,
           userMsg);
}


x86 assembly (clang, -O0):
<generate_infomsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    $0x200,%esi
call   1030 <vsnprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x228(%rbp)
mov    $0x0,%al
call   1050 <get_formatted_time@plt>
mov    -0x228(%rbp),%rdi
mov    %rax,%rcx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
lea    -0x220(%rbp),%rax
mov    $0x200,%esi
lea    0xe63(%rip),%rdx
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_infomsg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%rdx
mov    %rdi,%rbp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    %r8d,%ecx
call   1030 <vsnprintf@plt>
xor    %eax,%eax
call   1050 <get_formatted_time@plt>
mov    %r15,(%rsp)
lea    0xe90(%rip),%rdx
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rax,%rcx
mov    %rbx,%r8
mov    %r14d,%r9d
call   1040 <snprintf@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%s INFO[%s:%d] %s\0A\00"
define void @generate_infomsg(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [512 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%13 = load i8*, i8** %7
%14 = load i32, i32* %10
%15 = call i32 @vsnprintf(i8* %12, i32 512, i8* %13, i32 %14)
%16 = load i8*, i8** %6
%17 = call i8* (...) @get_formatted_time()
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%21 = call i32 @snprintf(i8* %16, i32 512, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18, i32 %19, i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"%s INFO[%s:%d] %s\0A\00"
define void @generate_infomsg(i8* %0, i8* nocapture %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%8 = call i32 @vsnprintf(i8* %7, i32 512, i8* %1, i32 %4)
%9 = tail call i8* (...) @get_formatted_time()
%10 = call i32 @snprintf(i8* %0, i32 512, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %2, i32 %3, i8* %7)
ret void
}