#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int strlen(char const *const);
void subunit_send_event(char const *const event, char const *const name,
                        char const *const details) {
  if (NULL == details) {
    fprintf(stdout, "%s: %s\n", event, name);
  } else {
    fprintf(stdout, "%s: %s [\n", event, name);
    fprintf(stdout, "%s", details);
    if (details[strlen(details) - 1] != '\n')
      fprintf(stdout, "\n");
    fprintf(stdout, "]\n");
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<subunit_send_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1174 <subunit_send_event+0x44>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1206 <subunit_send_event+0xd6>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11ef <subunit_send_event+0xbf>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subunit_send_event>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    0x2e9c(%rip),%r14
mov    (%r14),%edi
test   %rbx,%rbx
je     11a3 <subunit_send_event+0x73>
lea    0xeb5(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xeae(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1190 <subunit_send_event+0x60>
mov    (%r14),%edi
lea    0xe87(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xe7b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11b1 <subunit_send_event+0x81>
lea    0xe56(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fflush@plt>

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [8 x i8] c"%s: %s\0A\00"
@.str.1 = [10 x i8] c"%s: %s [\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c"]\0A\00"
define void @subunit_send_event(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
%5 = load i32, i32* @stdout
br i1 %4, label %6, label %8
6: ; preds = %3
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %24
8: ; preds = %3
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%10 = load i32, i32* @stdout
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = tail call i32 @strlen(i8* %2)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %2, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %21, label %18
18: ; preds = %8
%19 = load i32, i32* @stdout
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %18, %8
%22 = load i32, i32* @stdout
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %21, %6
%25 = load i32, i32* @stdout
%26 = tail call i32 @fflush(i32 %25)
ret void
}