#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 */
typedef int /*<<< orphan*/ features;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
const char *get_optional_features(void) {
  static char features[1024];
  unsigned int numfeatures = 0;
  snprintf(features, sizeof(features), "Optional features available: ");
  if (numfeatures > 0) {
    strncat(features, ", ", sizeof(features) - strlen(features) - 1);
  }
  strncat(features, "CPU affinity setting",
          sizeof(features) - strlen(features) - 1);
  numfeatures++;
  if (numfeatures == 0) {
    strncat(features, "None", sizeof(features) - strlen(features) - 1);
  }
  return features;
}


x86 assembly (clang, -O0):
<get_optional_features>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0x2f0a(%rip),%rdi
mov    $0x400,%esi
lea    0xeae(%rip),%rdx
call   1040 <snprintf@plt>
cmpl   $0x0,-0x4(%rbp)
jbe    1191 <get_optional_features+0x61>
lea    0x2ee8(%rip),%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    $0x400,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0x2ecb(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1050 <strncat@plt>
lea    0x2eb8(%rip),%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    $0x400,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0x2e9b(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1050 <strncat@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1204 <get_optional_features+0xd4>
lea    0x2e75(%rip),%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    $0x400,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0x2e58(%rip),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strncat@plt>
lea    0x2e45(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_optional_features>:
push   %rbx
lea    0x2f18(%rip),%rbx
lea    0xec1(%rip),%rdx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x3ff,%edx
sub    %eax,%edx
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strncat@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_optional_features.features = internal global [1024 x i8] zeroinitializer
@.str = [30 x i8] c"Optional features available: \00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [21 x i8] c"CPU affinity setting\00"
@.str.3 = [5 x i8] c"None\00"
define i8* @get_optional_features() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* %1
%4 = icmp ugt i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = call i32 @strlen(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = sub i64 1024, %7
%9 = sub i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = call i32 @strncat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %5, %0
%13 = call i32 @strlen(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0))
%14 = sext i32 %13 to i64
%15 = sub i64 1024, %14
%16 = sub i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i32 @strncat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
%20 = add i32 %19, 1
store i32 %20, i32* %1
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %12
%24 = call i32 @strlen(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0))
%25 = sext i32 %24 to i64
%26 = sub i64 1024, %25
%27 = sub i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i32 @strncat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %23, %12
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0)
}

LLVM IR (-O2):
@get_optional_features.features = internal global [1024 x i8] zeroinitializer
@.str = [30 x i8] c"Optional features available: \00"
@.str.2 = [21 x i8] c"CPU affinity setting\00"
define i8* @get_optional_features() {
%1 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0))
%3 = sub i32 1023, %2
%4 = tail call i32 @strncat(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %3)
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_optional_features.features, i64 0, i64 0)
}