#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*/ LOG_DEBUG;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ execvp(char const *, char *const *);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *);
void cras_metrics_log_event(const char *event) {
  syslog(LOG_DEBUG, "Log event: %s", event);
  if (!fork()) {
    const char *argv[] = {"metrics_client", "-v", event, NULL};
    execvp(argv[0], (char *const *)argv);
    _exit(1);
  }
}


x86 assembly (clang, -O0):
<cras_metrics_log_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea0(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%eax
jne    11b2 <cras_metrics_log_event+0x72>
lea    0xe92(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <execvp@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cras_metrics_log_event>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
mov    %rbx,%rdx
call   1040 <syslog@plt>
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
je     1171 <cras_metrics_log_event+0x31>
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe96(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xe9a(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %rbx,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rsp,%rsi
call   1050 <execvp@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@LOG_DEBUG = global i32 0
@.str = [14 x i8] c"Log event: %s\00"
@.str.1 = [15 x i8] c"metrics_client\00"
@.str.2 = [3 x i8] c"-v\00"
define void @cras_metrics_log_event(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x i8*]
store i8* %0, i8** %2
%4 = load i32, i32* @LOG_DEBUG
%5 = load i8*, i8** %2
%6 = call i32 @syslog(i32 %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = call i32 (...) @fork()
%8 = icmp ne i32 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %1
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %2
store i8* %13, i8** %12
%14 = getelementptr inbounds i8*, i8** %12, i64 1
store i8* null, i8** %14
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%16 = load i8*, i8** %15
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%18 = call i32 @execvp(i8* %16, i8** %17)
%19 = call i32 @_exit(i32 1)
unreachable
20: ; preds = %1
ret void
}

LLVM IR (-O2):
@LOG_DEBUG = global i32 0
@.str = [14 x i8] c"Log event: %s\00"
@.str.1 = [15 x i8] c"metrics_client\00"
@.str.2 = [3 x i8] c"-v\00"
define void @cras_metrics_log_event(i8* %0) {
%2 = alloca [4 x i8*]
%3 = load i32, i32* @LOG_DEBUG
%4 = tail call i32 @syslog(i32 %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32 (...) @fork()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = bitcast [4 x i8*]* %2 to i8*
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %0, i8** %11
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
store i8* null, i8** %12
%13 = call i32 @execvp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %9)
%14 = call i32 @_exit(i32 1)
unreachable
15: ; preds = %1
ret void
}