#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 errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, int, int,
                           int);
int getpid();
int /*<<< orphan*/ stderr;
void log_filter(int type, char *s1, char *s2, int socket_fd) {
  if (type != 42) {
    return;
  }
  fprintf(stderr, "ERROR: %s: %s (errno=%d pid=%d socket=%d)\n", s1, s2, errno,
          getpid(), socket_fd);
}


x86 assembly (clang, -O0):
<log_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x2a,-0x4(%rbp)
je     1145 <log_filter+0x25>
jmp    1198 <log_filter+0x78>
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8d
mov    %eax,%r9d
mov    -0x1c(%rbp),%eax
lea    0xe70(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_filter>:
cmp    $0x2a,%edi
jne    117e <log_filter+0x5e>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%r15d
mov    0x2e8e(%rip),%rax
mov    (%rax),%r12d
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ebp,(%rsp)
lea    0xea2(%rip),%rsi
mov    %r15d,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r12d,%r8d
mov    %eax,%r9d
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"ERROR: %s: %s (errno=%d pid=%d socket=%d)\0A\00"
@errno = global i32 0
define void @log_filter(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 42
br i1 %10, label %11, label %12
11: ; preds = %4
br label %20
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %6
%15 = load i8*, i8** %7
%16 = load i32, i32* @errno
%17 = call i32 (...) @getpid()
%18 = load i32, i32* %8
%19 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15, i32 %16, i32 %17, i32 %18)
br label %20
20: ; preds = %12, %11
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"ERROR: %s: %s (errno=%d pid=%d socket=%d)\0A\00"
@errno = global i32 0
define void @log_filter(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = icmp eq i32 %0, 42
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i32 (...) @getpid()
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i32 %8, i32 %9, i32 %3)
br label %11
11: ; preds = %4, %6
ret void
}