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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char const *,
                           ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, int,
                            char const *);
int /*<<< orphan*/ stderr;
void rsb2_eventmgr_handle(const char *func, const char *file, int line,
                          const char *name, const char *descr) {
  char loc[256];
  snprintf(loc, sizeof(loc), "%-16.16s %4d %s", file, line, func);
  if (descr && *descr) {
    fprintf(stderr, "event    %-50.50s|%s,%s\n", loc, name, descr);
  } else {
    fprintf(stderr, "event    %-50.50s|%s\n", loc, name);
  }
}


x86 assembly (clang, -O0):
<rsb2_eventmgr_handle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    -0x8(%rbp),%r9
mov    $0x100,%esi
lea    0xea3(%rip),%rdx
call   1030 <snprintf@plt>
cmpq   $0x0,-0x28(%rbp)
je     11a8 <rsb2_eventmgr_handle+0x88>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a8 <rsb2_eventmgr_handle+0x88>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11ca <rsb2_eventmgr_handle+0xaa>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsb2_eventmgr_handle>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %edx,%r8d
mov    %rsi,%rcx
mov    %rdi,%r9
lea    0xec0(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1030 <snprintf@plt>
test   %rbx,%rbx
je     1179 <rsb2_eventmgr_handle+0x59>
cmpb   $0x0,(%rbx)
je     1179 <rsb2_eventmgr_handle+0x59>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1196 <rsb2_eventmgr_handle+0x76>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%-16.16s %4d %s\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"event %-50.50s|%s,%s\0A\00"
@.str.2 = [22 x i8] c"event %-50.50s|%s\0A\00"
define void @rsb2_eventmgr_handle(i8* %0, i8* %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [256 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%13 = load i8*, i8** %7
%14 = load i32, i32* %8
%15 = load i8*, i8** %6
%16 = call i32 @snprintf(i8* %12, i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14, i8* %15)
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %30
19: ; preds = %5
%20 = load i8*, i8** %10
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%27 = load i8*, i8** %9
%28 = load i8*, i8** %10
%29 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %27, i8* %28)
br label %35
30: ; preds = %19, %5
%31 = load i32, i32* @stderr
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%33 = load i8*, i8** %9
%34 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %30, %24
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"%-16.16s %4d %s\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"event %-50.50s|%s,%s\0A\00"
@.str.2 = [22 x i8] c"event %-50.50s|%s\0A\00"
define void @rsb2_eventmgr_handle(i8* %0, i8* %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i8* %0)
%9 = icmp eq i8* %4, null
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %3, i8* %4)
br label %19
16: ; preds = %10, %5
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %3)
br label %19
19: ; preds = %16, %13
ret void
}