#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_USER;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char const *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void error_exit(char *errorMsg, const char *parm) {
  char *msg = errorMsg;
  if (parm) {
    msg = malloc(strlen(errorMsg) + strlen(parm) + 1);
    strcpy(msg, errorMsg);
    strcat(msg, parm);
  }
  syslog(LOG_USER, msg);
  if (parm)
    free(msg);
  exit(1);
}


x86 assembly (clang, -O0):
<error_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d7 <error_exit+0x67>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1070 <syslog@plt>
cmpq   $0x0,-0x10(%rbp)
je     11fd <error_exit+0x8d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<error_exit>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
jne    119b <error_exit+0x2b>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1070 <syslog@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rsi,%r12
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    (%r15,%rax,1),%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1070 <syslog@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@LOG_USER = global i32 0
define void @error_exit(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = add nsw i64 %11, %13
%15 = add nsw i64 %14, 1
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = load i8*, i8** %3
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %5
%21 = load i8*, i8** %4
%22 = call i32 @strcat(i8* %20, i8* %21)
br label %23
23: ; preds = %9, %2
%24 = load i32, i32* @LOG_USER
%25 = load i8*, i8** %5
%26 = call i32 @syslog(i32 %24, i8* %25)
%27 = load i8*, i8** %4
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
br label %32
32: ; preds = %29, %23
%33 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@LOG_USER = global i32 0
define void @error_exit(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @LOG_USER
%6 = tail call i32 @syslog(i32 %5, i8* %0)
br label %18
7: ; preds = %2
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = tail call i64 @strlen(i8* %1)
%10 = add i64 %8, 1
%11 = add i64 %10, %9
%12 = tail call i8* @malloc(i64 %11)
%13 = tail call i32 @strcpy(i8* %12, i8* %0)
%14 = tail call i32 @strcat(i8* %12, i8* %1)
%15 = load i32, i32* @LOG_USER
%16 = tail call i32 @syslog(i32 %15, i8* %12)
%17 = tail call i32 @free(i8* %12)
br label %18
18: ; preds = %4, %7
%19 = tail call i32 @exit(i32 1)
unreachable
}