#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*/ arg_cat(char **, char const *, size_t *);
size_t strcspn(char const *, char *);
int /*<<< orphan*/ strncat(char *, char const *, size_t);
void arg_cat_option(char *dest, size_t ndest, const char *shortopts,
                    const char *longopts, const char *datatype, int optvalue) {
  if (shortopts) {
    char option[3];
    option[0] = '-';
    option[1] = shortopts[0];
    option[2] = 0;
    arg_cat(&dest, option, &ndest);
    if (datatype) {
      arg_cat(&dest, " ", &ndest);
      if (optvalue) {
        arg_cat(&dest, "[", &ndest);
        arg_cat(&dest, datatype, &ndest);
        arg_cat(&dest, "]", &ndest);
      } else
        arg_cat(&dest, datatype, &ndest);
    }
  } else if (longopts) {
    size_t ncspn;
    arg_cat(&dest, "--", &ndest);
    ncspn = strcspn(longopts, ",");
    strncat(dest, longopts, (ncspn < ndest) ? ncspn : ndest);
    if (datatype) {
      arg_cat(&dest, "=", &ndest);
      if (optvalue) {
        arg_cat(&dest, "[", &ndest);
        arg_cat(&dest, datatype, &ndest);
        arg_cat(&dest, "]", &ndest);
      } else
        arg_cat(&dest, datatype, &ndest);
    }
  } else if (datatype) {
    if (optvalue) {
      arg_cat(&dest, "[", &ndest);
      arg_cat(&dest, datatype, &ndest);
      arg_cat(&dest, "]", &ndest);
    } else
      arg_cat(&dest, datatype, &ndest);
  }
}


x86 assembly (clang, -O0):
<arg_cat_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ff <arg_cat_option+0xcf>
movb   $0x2d,-0x2f(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x2e(%rbp)
movb   $0x0,-0x2d(%rbp)
lea    -0x2f(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
cmpq   $0x0,-0x28(%rbp)
je     11fa <arg_cat_option+0xca>
lea    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
cmpl   $0x0,-0x2c(%rbp)
je     11e4 <arg_cat_option+0xb4>
lea    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
lea    -0x8(%rbp),%rdi
lea    0xe2e(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
jmp    11f5 <arg_cat_option+0xc5>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
jmp    11fa <arg_cat_option+0xca>
jmp    136b <arg_cat_option+0x23b>
cmpq   $0x0,-0x20(%rbp)
je     12f8 <arg_cat_option+0x1c8>
lea    -0x8(%rbp),%rdi
lea    0xdf1(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
mov    -0x20(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1040 <strcspn@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    125d <arg_cat_option+0x12d>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1265 <arg_cat_option+0x135>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rdx
call   1030 <strncat@plt>
cmpq   $0x0,-0x28(%rbp)
je     12f3 <arg_cat_option+0x1c3>
lea    -0x8(%rbp),%rdi
lea    0xd7f(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
cmpl   $0x0,-0x2c(%rbp)
je     12dd <arg_cat_option+0x1ad>
lea    -0x8(%rbp),%rdi
lea    0xd58(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
lea    -0x8(%rbp),%rdi
lea    0xd35(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
jmp    12ee <arg_cat_option+0x1be>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
jmp    12f3 <arg_cat_option+0x1c3>
jmp    1366 <arg_cat_option+0x236>
cmpq   $0x0,-0x28(%rbp)
je     1361 <arg_cat_option+0x231>
cmpl   $0x0,-0x2c(%rbp)
je     134b <arg_cat_option+0x21b>
lea    -0x8(%rbp),%rdi
lea    0xcea(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
lea    -0x8(%rbp),%rdi
lea    0xcc7(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
jmp    135c <arg_cat_option+0x22c>
mov    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rdx
call   1050 <arg_cat@plt>
jmp    1361 <arg_cat_option+0x231>
jmp    1366 <arg_cat_option+0x236>
jmp    136b <arg_cat_option+0x23b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_cat_option>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r9d,%r14d
mov    %r8,%rbx
mov    %rdi,0x10(%rsp)
mov    %rsi,0x8(%rsp)
test   %rdx,%rdx
je     1183 <arg_cat_option+0x53>
movb   $0x2d,0x1d(%rsp)
mov    (%rdx),%al
mov    %al,0x1e(%rsp)
movb   $0x0,0x1f(%rsp)
lea    0x10(%rsp),%rdi
lea    0x1d(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <arg_cat@plt>
test   %rbx,%rbx
je     1238 <arg_cat_option+0x108>
lea    0xe7f(%rip),%rsi
jmp    11d9 <arg_cat_option+0xa9>
mov    %rcx,%rbp
test   %rcx,%rcx
je     1241 <arg_cat_option+0x111>
lea    0xe70(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1050 <arg_cat@plt>
lea    0xe5d(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcspn@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rdx
cmp    %rdx,%rax
cmovb  %rax,%rdx
mov    %rbp,%rsi
call   1030 <strncat@plt>
test   %rbx,%rbx
je     1238 <arg_cat_option+0x108>
lea    0xe32(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1050 <arg_cat@plt>
test   %r14d,%r14d
je     1226 <arg_cat_option+0xf6>
lea    0xe0e(%rip),%rsi
lea    0x10(%rsp),%rbp
lea    0x8(%rsp),%r14
mov    %rbp,%rdi
mov    %r14,%rdx
call   1050 <arg_cat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <arg_cat@plt>
lea    0xde6(%rip),%rsi
mov    %rbp,%rdi
mov    %r14,%rdx
jmp    1233 <arg_cat_option+0x103>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
call   1050 <arg_cat@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
test   %rbx,%rbx
jne    11e8 <arg_cat_option+0xb8>
jmp    1238 <arg_cat_option+0x108>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [2 x i8] c"]\00"
@.str.3 = [3 x i8] c"--\00"
@.str.4 = [2 x i8] c",\00"
@.str.5 = [2 x i8] c"=\00"
define void @arg_cat_option(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca [3 x i8]
%14 = alloca i64
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%15 = load i8*, i8** %9
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %42
17: ; preds = %6
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %13, i64 0, i64 0
store i8 45, i8* %18
%19 = load i8*, i8** %9
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %13, i64 0, i64 1
store i8 %21, i8* %22
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %13, i64 0, i64 2
store i8 0, i8* %23
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %13, i64 0, i64 0
%25 = call i32 @arg_cat(i8** %7, i8* %24, i64* %8)
%26 = load i8*, i8** %11
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %41
28: ; preds = %17
%29 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64* %8)
%30 = load i32, i32* %12
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%34 = load i8*, i8** %11
%35 = call i32 @arg_cat(i8** %7, i8* %34, i64* %8)
%36 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64* %8)
br label %40
37: ; preds = %28
%38 = load i8*, i8** %11
%39 = call i32 @arg_cat(i8** %7, i8* %38, i64* %8)
br label %40
40: ; preds = %37, %32
br label %41
41: ; preds = %40, %17
br label %94
42: ; preds = %6
%43 = load i8*, i8** %10
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %77
45: ; preds = %42
%46 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64* %8)
%47 = load i8*, i8** %10
%48 = call i64 @strcspn(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i64 %48, i64* %14
%49 = load i8*, i8** %7
%50 = load i8*, i8** %10
%51 = load i64, i64* %14
%52 = load i64, i64* %8
%53 = icmp ult i64 %51, %52
br i1 %53, label %54, label %56
54: ; preds = %45
%55 = load i64, i64* %14
br label %58
56: ; preds = %45
%57 = load i64, i64* %8
br label %58
58: ; preds = %56, %54
%59 = phi i64 [ %55, %54 ], [ %57, %56 ]
%60 = call i32 @strncat(i8* %49, i8* %50, i64 %59)
%61 = load i8*, i8** %11
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %76
63: ; preds = %58
%64 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i64* %8)
%65 = load i32, i32* %12
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %63
%68 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%69 = load i8*, i8** %11
%70 = call i32 @arg_cat(i8** %7, i8* %69, i64* %8)
%71 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64* %8)
br label %75
72: ; preds = %63
%73 = load i8*, i8** %11
%74 = call i32 @arg_cat(i8** %7, i8* %73, i64* %8)
br label %75
75: ; preds = %72, %67
br label %76
76: ; preds = %75, %58
br label %93
77: ; preds = %42
%78 = load i8*, i8** %11
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %92
80: ; preds = %77
%81 = load i32, i32* %12
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%85 = load i8*, i8** %11
%86 = call i32 @arg_cat(i8** %7, i8* %85, i64* %8)
%87 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64* %8)
br label %91
88: ; preds = %80
%89 = load i8*, i8** %11
%90 = call i32 @arg_cat(i8** %7, i8* %89, i64* %8)
br label %91
91: ; preds = %88, %83
br label %92
92: ; preds = %91, %77
br label %93
93: ; preds = %92, %76
br label %94
94: ; preds = %93, %41
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"[\00"
@.str.2 = [2 x i8] c"]\00"
@.str.3 = [3 x i8] c"--\00"
@.str.4 = [2 x i8] c",\00"
@.str.5 = [2 x i8] c"=\00"
define void @arg_cat_option(i8* %0, i64 %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca [3 x i8]
store i8* %0, i8** %7
store i64 %1, i64* %8
%10 = icmp eq i8* %2, null
br i1 %10, label %28, label %11
11: ; preds = %6
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
store i8 45, i8* %12
%13 = load i8, i8* %2
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 1
store i8 %13, i8* %14
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 2
store i8 0, i8* %15
%16 = call i32 @arg_cat(i8** %7, i8* %12, i64* %8)
%17 = icmp eq i8* %4, null
br i1 %17, label %27, label %18
18: ; preds = %11
%19 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64* %8)
%20 = icmp eq i32 %5, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%23 = call i32 @arg_cat(i8** %7, i8* %4, i64* %8)
%24 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64* %8)
br label %27
25: ; preds = %18
%26 = call i32 @arg_cat(i8** %7, i8* %4, i64* %8)
br label %27
27: ; preds = %21, %25, %11
br label %58
28: ; preds = %6
%29 = icmp eq i8* %3, null
br i1 %29, label %48, label %30
30: ; preds = %28
%31 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64* %8)
%32 = call i64 @strcspn(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%33 = load i8*, i8** %7
%34 = load i64, i64* %8
%35 = icmp ult i64 %32, %34
%36 = select i1 %35, i64 %32, i64 %34
%37 = call i32 @strncat(i8* %33, i8* %3, i64 %36)
%38 = icmp eq i8* %4, null
br i1 %38, label %58, label %39
39: ; preds = %30
%40 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i64* %8)
%41 = icmp eq i32 %5, 0
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%44 = call i32 @arg_cat(i8** %7, i8* %4, i64* %8)
%45 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64* %8)
br label %58
46: ; preds = %39
%47 = call i32 @arg_cat(i8** %7, i8* %4, i64* %8)
br label %58
48: ; preds = %28
%49 = icmp eq i8* %4, null
br i1 %49, label %58, label %50
50: ; preds = %48
%51 = icmp eq i32 %5, 0
br i1 %51, label %56, label %52
52: ; preds = %50
%53 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%54 = call i32 @arg_cat(i8** %7, i8* %4, i64* %8)
%55 = call i32 @arg_cat(i8** %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64* %8)
br label %58
56: ; preds = %50
%57 = call i32 @arg_cat(i8** %7, i8* %4, i64* %8)
br label %58
58: ; preds = %30, %46, %42, %52, %56, %48, %27
ret void
}