#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*/ fflush(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ printf(char *, char *, char *, int, int, ...);
int /*<<< orphan*/ stdout;
void default_logger(int type, char *title, char *description, int socket_fd) {
  switch (type) {
  case 42:
    printf("ERROR: %s: %s (errno=%d pid=%d socket=%d)\n", title, description,
           errno, getpid(), socket_fd);
    break;
  default:
    printf("INFO: %s: %s (pid=%d socket=%d)\n", title, description, getpid(),
           socket_fd);
    break;
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<default_logger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x2a,%eax
jne    119f <default_logger+0x6f>
jmp    1157 <default_logger+0x27>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    %eax,%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d2 <default_logger+0xa2>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    %eax,%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<default_logger>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%rbp
cmp    $0x2a,%edi
jne    1175 <default_logger+0x45>
mov    0x2e94(%rip),%rax
mov    (%rax),%r15d
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea3(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
mov    %eax,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1195 <default_logger+0x65>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea8(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"ERROR: %s: %s (errno=%d pid=%d socket=%d)\0A\00"
@errno = global i32 0
@.str.1 = [33 x i8] c"INFO: %s: %s (pid=%d socket=%d)\0A\00"
@stdout = global i32 0
define void @default_logger(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
switch i32 %9, label %17 [
i32 42, label %10
]
10: ; preds = %4
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = load i32, i32* @errno
%14 = call i32 (...) @getpid()
%15 = load i32, i32* %8
%16 = call i32 (i8*, i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12, i32 %13, i32 %14, i32 %15)
br label %23
17: ; preds = %4
%18 = load i8*, i8** %6
%19 = load i8*, i8** %7
%20 = call i32 (...) @getpid()
%21 = load i32, i32* %8
%22 = call i32 (i8*, i8*, i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19, i32 %20, i32 %21)
br label %23
23: ; preds = %17, %10
%24 = load i32, i32* @stdout
%25 = call i32 @fflush(i32 %24)
ret void
}

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