#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;
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int snprintf(char *, int, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ vsnprintf(char *, int, char *, int /*<<< orphan*/);
void sysapi_print_in_green(char *msg, va_list ap) {
  char str[1024];
  int len;
  len = snprintf(str, sizeof(str), "[INFO:  ] ");
  vsnprintf(str + len, sizeof(str) - len, msg, ap);
  fprintf(stdout,
          "\x1B[32m"
          "%s"
          "\033[0m",
          str);
}


x86 assembly (clang, -O0):
<sysapi_print_in_green>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
lea    0xeab(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
movslq -0x414(%rbp),%rax
add    %rax,%rdi
movslq -0x414(%rbp),%rcx
mov    $0x400,%eax
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1030 <vsnprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xe66(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysapi_print_in_green>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xeb6(%rip),%rdx
mov    %rsp,%r14
mov    $0x400,%ebp
mov    %r14,%rdi
mov    $0x400,%esi
call   1040 <snprintf@plt>
cltq
lea    (%rsp,%rax,1),%rdi
sub    %eax,%ebp
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <vsnprintf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"[INFO: ] \00"
@stdout = global i32 0
@.str.1 = [12 x i8] c"\1B[32m%s\1B[0m\00"
define void @sysapi_print_in_green(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %6
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = sub i64 1024, %14
%16 = trunc i64 %15 to i32
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = call i32 @vsnprintf(i8* %12, i32 %16, i8* %17, i32 %18)
%20 = load i32, i32* @stdout
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"[INFO: ] \00"
@stdout = global i32 0
@.str.1 = [12 x i8] c"\1B[32m%s\1B[0m\00"
define void @sysapi_print_in_green(i8* nocapture %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %6
%8 = sub i32 1024, %5
%9 = call i32 @vsnprintf(i8* %7, i32 %8, i8* %0, i32 %1)
%10 = load i32, i32* @stdout
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret void
}