#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*/ broadcast(char *, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int strlen(char *);
void *notify(void *arg) {
  char *file = (char *)arg;
  int len = strlen(file) + 2;
  char *str = malloc(sizeof(*str) * len);
  str[0] = 'C';
  memcpy(&str[1], file, len - 2);
  str[len - 1] = '\n';
  broadcast(str, len);
  free(str);
  return (void *)NULL;
}


x86 assembly (clang, -O0):
<notify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x43,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
sub    $0x2,%edx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <broadcast@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<notify>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0x2(%rbx),%r15d
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
movb   $0x43,(%rax)
lea    0x1(%rax),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
movslq %ebx,%rax
movb   $0xa,0x1(%rax,%rbp,1)
mov    %rbp,%rdi
mov    %r15d,%esi
call   1060 <broadcast@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @notify(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 %8, 2
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 67, i8* %16
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8*, i8** %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 2
%22 = call i32 @memcpy(i8* %18, i8* %19, i32 %21)
%23 = load i8*, i8** %5
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 10, i8* %27
%28 = load i8*, i8** %5
%29 = load i32, i32* %4
%30 = call i32 @broadcast(i8* %28, i32 %29)
%31 = load i8*, i8** %5
%32 = call i32 @free(i8* %31)
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @notify(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 2
%4 = tail call i8* @malloc(i32 %3)
store i8 67, i8* %4
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = tail call i32 @memcpy(i8* %5, i8* %0, i32 %2)
%7 = add nsw i32 %2, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
store i8 10, i8* %9
%10 = tail call i32 @broadcast(i8* %4, i32 %3)
%11 = tail call i32 @free(i8* %4)
ret i8* null
}