#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 */
struct option {
  int has_arg;
  scalar_t__ val;
  scalar_t__ name;
};

/* Variables and functions */
int /*<<< orphan*/ memcpy(struct option *, struct option const *, int);
#define optional_argument 129
#define required_argument 128
void append(char *shortopts, struct option *longopts,
            const struct option *src) {
  while (longopts->name)
    longopts++;
  memcpy(longopts, src, sizeof(struct option));
  while (*shortopts)
    shortopts++;
  *shortopts++ = (char)src->val;
  switch (src->has_arg) {
  case optional_argument:
    *shortopts++ = ':';
    *shortopts++ = ':';
    break;
  case required_argument:
    *shortopts++ = ':';
    break;
  }
  *shortopts = '\0';
}


x86 assembly (clang, -O0):
<append>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1144 <append+0x34>
mov    -0x10(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <append+0x14>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x18,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1174 <append+0x64>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1156 <append+0x46>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     11e1 <append+0xd1>
jmp    11a5 <append+0x95>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
jne    11f3 <append+0xe3>
jmp    11b8 <append+0xa8>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x3a,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x3a,(%rax)
jmp    11f3 <append+0xe3>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x3a,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
add    $0xffffffffffffffe8,%rsi
xchg   %ax,%ax
cmpq   $0x0,0x28(%rsi)
lea    0x18(%rsi),%rsi
jne    1120 <append+0x10>
mov    %rsi,%rdi
mov    %r14,%rsi
mov    $0x18,%edx
call   1030 <memcpy@plt>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <append+0x30>
mov    0x8(%r14),%al
mov    %al,-0x1(%rbx)
mov    (%r14),%eax
cmp    $0x81,%eax
je     116b <append+0x5b>
cmp    $0x80,%eax
jne    1181 <append+0x71>
mov    $0x2,%ecx
mov    %rbx,%rax
jmp    1177 <append+0x67>
lea    0x1(%rbx),%rax
movb   $0x3a,(%rbx)
mov    $0x3,%ecx
add    %rcx,%rbx
add    $0xffffffffffffffff,%rbx
movb   $0x3a,(%rax)
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.option = type { i32, i64, i64 }
define void @append(i8* %0, %struct.option* %1, %struct.option* %2) {
%4 = alloca i8*
%5 = alloca %struct.option*
%6 = alloca %struct.option*
store i8* %0, i8** %4
store %struct.option* %1, %struct.option** %5
store %struct.option* %2, %struct.option** %6
br label %7
7: ; preds = %12, %3
%8 = load %struct.option*, %struct.option** %5
%9 = getelementptr inbounds %struct.option, %struct.option* %8, i32 0, i32 2
%10 = load i64, i64* %9
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load %struct.option*, %struct.option** %5
%14 = getelementptr inbounds %struct.option, %struct.option* %13, i32 1
store %struct.option* %14, %struct.option** %5
br label %7
15: ; preds = %7
%16 = load %struct.option*, %struct.option** %5
%17 = load %struct.option*, %struct.option** %6
%18 = call i32 @memcpy(%struct.option* %16, %struct.option* %17, i32 24)
br label %19
19: ; preds = %23, %15
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
br label %19
26: ; preds = %19
%27 = load %struct.option*, %struct.option** %6
%28 = getelementptr inbounds %struct.option, %struct.option* %27, i32 0, i32 1
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i8
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
store i8 %30, i8* %31
%33 = load %struct.option*, %struct.option** %6
%34 = getelementptr inbounds %struct.option, %struct.option* %33, i32 0, i32 0
%35 = load i32, i32* %34
switch i32 %35, label %44 [
i32 129, label %36
i32 128, label %41
]
36: ; preds = %26
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
store i8 58, i8* %37
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
store i8 58, i8* %39
br label %44
41: ; preds = %26
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %4
store i8 58, i8* %42
br label %44
44: ; preds = %26, %41, %36
%45 = load i8*, i8** %4
store i8 0, i8* %45
ret void
}

LLVM IR (-O2):
%struct.option = type { i32, i64, i64 }
define void @append(i8* nocapture %0, %struct.option* %1, %struct.option* %2) {
br label %4
4: ; preds = %4, %3
%5 = phi %struct.option* [ %1, %3 ], [ %9, %4 ]
%6 = getelementptr inbounds %struct.option, %struct.option* %5, i64 0, i32 2
%7 = load i64, i64* %6
%8 = icmp eq i64 %7, 0
%9 = getelementptr inbounds %struct.option, %struct.option* %5, i64 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = tail call i32 @memcpy(%struct.option* %5, %struct.option* %2, i32 24)
br label %12
12: ; preds = %12, %10
%13 = phi i8* [ %0, %10 ], [ %16, %12 ]
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = getelementptr inbounds i8, i8* %13, i64 1
br i1 %15, label %17, label %12
17: ; preds = %12
%18 = getelementptr inbounds %struct.option, %struct.option* %2, i64 0, i32 1
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i8
store i8 %20, i8* %13
%21 = getelementptr inbounds %struct.option, %struct.option* %2, i64 0, i32 0
%22 = load i32, i32* %21
switch i32 %22, label %29 [
i32 129, label %23
i32 128, label %25
]
23: ; preds = %17
%24 = getelementptr inbounds i8, i8* %13, i64 2
store i8 58, i8* %16
br label %25
25: ; preds = %17, %23
%26 = phi i64 [ 3, %23 ], [ 2, %17 ]
%27 = phi i8* [ %24, %23 ], [ %16, %17 ]
%28 = getelementptr inbounds i8, i8* %13, i64 %26
store i8 58, i8* %27
br label %29
29: ; preds = %25, %17
%30 = phi i8* [ %16, %17 ], [ %28, %25 ]
store i8 0, i8* %30
ret void
}