#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 BUFSIZ;
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ getpid();
int /*<<< orphan*/ pexit(char *);
int snprintf(char *, int, char *, char const *, long, char const *);
int write(int /*<<< orphan*/, char *, int);
void logInfo(const char *who, const char *message) {
  char buf[BUFSIZ];
  int size;
  size = snprintf(buf, BUFSIZ, "[%s %ld] %s\n", who, (long)getpid(), message);
  if (write(STDOUT_FILENO, buf, size) == -1) {
    pexit("write");
  }
}


x86 assembly (clang, -O0):
<logInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rdi
mov    %rax,%r8
mov    -0x10(%rbp),%r9
lea    0xe50(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,-0x24(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    11e2 <logInfo+0xa2>
lea    0xe30(%rip),%rdi
call   1060 <pexit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logInfo>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e80(%rip),%rax
mov    (%rax),%r12d
mov    %rsp,%rbx
mov    %r12,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe83(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rcx
mov    %rax,%r8
mov    %r14,%r9
call   1050 <snprintf@plt>
mov    0x2e58(%rip),%rcx
mov    (%rcx),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    11b5 <logInfo+0x75>
lea    0xe5d(%rip),%rdi
call   1060 <pexit@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [13 x i8] c"[%s %ld] %s\0A\00"
@STDOUT_FILENO = global i32 0
@.str.1 = [6 x i8] c"write\00"
define void @logInfo(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i8, i64 %9
store i64 %9, i64* %6
%12 = load i32, i32* @BUFSIZ
%13 = load i8*, i8** %3
%14 = call i64 (...) @getpid()
%15 = load i8*, i8** %4
%16 = call i32 @snprintf(i8* %11, i32 %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %13, i64 %14, i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* @STDOUT_FILENO
%18 = load i32, i32* %7
%19 = call i32 @write(i32 %17, i8* %11, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %2
%24 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [13 x i8] c"[%s %ld] %s\0A\00"
@STDOUT_FILENO = global i32 0
@.str.1 = [6 x i8] c"write\00"
define void @logInfo(i8* %0, i8* %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i64 (...) @getpid()
%7 = call i32 @snprintf(i8* %5, i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %6, i8* %1)
%8 = load i32, i32* @STDOUT_FILENO
%9 = call i32 @write(i32 %8, i8* %5, i32 %7)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
ret void
}