#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*/ audit_encode_value(char *, char const *, unsigned int);
scalar_t__ audit_value_needs_encoding(char const *, unsigned int);
int /*<<< orphan*/ snprintf(char *, unsigned int, char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
unsigned int strlen(char const *);
char *_get_commname(const char *comm, char *commname, unsigned int size) {
  unsigned int len;
  if (comm == NULL) {
    strcpy(commname, "\"?\"");
    return commname;
  }
  len = strlen(comm);
  if (audit_value_needs_encoding(comm, len))
    audit_encode_value(commname, comm, len);
  else
    snprintf(commname, size, "\"%s\"", comm);
  return commname;
}


x86 assembly (clang, -O0):
<_get_commname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118b <_get_commname+0x3b>
mov    -0x18(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e1 <_get_commname+0x91>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <audit_value_needs_encoding@plt>
cmp    $0x0,%rax
je     11c2 <_get_commname+0x72>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1070 <audit_encode_value@plt>
jmp    11d9 <_get_commname+0x89>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rcx
lea    0xe30(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_commname>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
test   %rdi,%rdi
je     118a <_get_commname+0x3a>
mov    %edx,%r15d
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <audit_value_needs_encoding@plt>
test   %rax,%rax
je     119b <_get_commname+0x4b>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1070 <audit_encode_value@plt>
jmp    11b0 <_get_commname+0x60>
lea    0xe6f(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
jmp    11b0 <_get_commname+0x60>
lea    0xe62(%rip),%rdx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rcx
call   1060 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\22?\22\00"
@.str.1 = [5 x i8] c"\22%s\22\00"
define i8* @_get_commname(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %6
store i8* %14, i8** %4
br label %34
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %8
%18 = load i8*, i8** %5
%19 = load i32, i32* %8
%20 = call i64 @audit_value_needs_encoding(i8* %18, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i8*, i8** %6
%24 = load i8*, i8** %5
%25 = load i32, i32* %8
%26 = call i32 @audit_encode_value(i8* %23, i8* %24, i32 %25)
br label %32
27: ; preds = %15
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = load i8*, i8** %5
%31 = call i32 @snprintf(i8* %28, i32 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %27, %22
%33 = load i8*, i8** %6
store i8* %33, i8** %4
br label %34
34: ; preds = %32, %11
%35 = load i8*, i8** %4
ret i8* %35
}

LLVM IR (-O2):
@.str = [4 x i8] c"\22?\22\00"
@.str.1 = [5 x i8] c"\22%s\22\00"
define i8* @_get_commname(i8* %0, i8* returned %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %15
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %0)
%9 = tail call i64 @audit_value_needs_encoding(i8* %0, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @audit_encode_value(i8* %1, i8* %0, i32 %8)
br label %15
13: ; preds = %7
%14 = tail call i32 @snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %11, %13, %5
ret i8* %1
}