#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*/ endOption(unsigned char **);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
int add_multiple_option(unsigned char *optionptr, unsigned char code,
                        char datalength, char *data1, char *data2,
                        char *data3) {
  endOption(&optionptr);
  optionptr[0] = code;
  if (code == 0xff)
    return 0;
  optionptr++;
  optionptr[0] = datalength;
  optionptr++;
  if (data1 != NULL) {
    memcpy(optionptr, data1, 0x04);
    optionptr += 0x04;
    if (data2 != NULL) {
      memcpy(optionptr, data2, 0x04);
      optionptr += 0x04;
      if (data3 != NULL) {
        memcpy(optionptr, data3, 0x04);
        optionptr += 0x04;
      }
    }
  }
  optionptr[0] = 0xff;
  return 0;
}


x86 assembly (clang, -O0):
<add_multiple_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %rdi,-0x10(%rbp)
mov    %dl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <endOption@plt>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movzbl -0x11(%rbp),%eax
cmp    $0xff,%eax
jne    1170 <add_multiple_option+0x50>
movl   $0x0,-0x4(%rbp)
jmp    1224 <add_multiple_option+0x104>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x12(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1216 <add_multiple_option+0xf6>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1211 <add_multiple_option+0xf1>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     120c <add_multiple_option+0xec>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    1211 <add_multiple_option+0xf1>
jmp    1216 <add_multiple_option+0xf6>
mov    -0x10(%rbp),%rax
movb   $0xff,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_multiple_option>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <endOption@plt>
mov    0x8(%rsp),%rax
mov    %bl,(%rax)
cmp    $0xff,%bl
je     11db <add_multiple_option+0xbb>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    %bpl,0x1(%rax)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
test   %r12,%r12
je     11d8 <add_multiple_option+0xb8>
mov    %r12,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdi
add    $0x4,%rdi
mov    %rdi,0x8(%rsp)
test   %r15,%r15
je     11d8 <add_multiple_option+0xb8>
mov    %r15,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdi
add    $0x4,%rdi
mov    %rdi,0x8(%rsp)
test   %r14,%r14
je     11d8 <add_multiple_option+0xb8>
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdi
add    $0x4,%rdi
mov    %rdi,0x8(%rsp)
movb   $0xff,(%rdi)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @add_multiple_option(i8* %0, i8 zeroext %1, i8 signext %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %8
store i8 %1, i8* %9
store i8 %2, i8* %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%14 = call i32 @endOption(i8** %8)
%15 = load i8, i8* %9
%16 = load i8*, i8** %8
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 %15, i8* %17
%18 = load i8, i8* %9
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 255
br i1 %20, label %21, label %22
21: ; preds = %6
store i32 0, i32* %7
br label %59
22: ; preds = %6
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %8
%25 = load i8, i8* %10
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i64 0
store i8 %25, i8* %27
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %8
%30 = load i8*, i8** %11
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %56
32: ; preds = %22
%33 = load i8*, i8** %8
%34 = load i8*, i8** %11
%35 = call i32 @memcpy(i8* %33, i8* %34, i32 4)
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 4
store i8* %37, i8** %8
%38 = load i8*, i8** %12
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %55
40: ; preds = %32
%41 = load i8*, i8** %8
%42 = load i8*, i8** %12
%43 = call i32 @memcpy(i8* %41, i8* %42, i32 4)
%44 = load i8*, i8** %8
%45 = getelementptr inbounds i8, i8* %44, i64 4
store i8* %45, i8** %8
%46 = load i8*, i8** %13
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %54
48: ; preds = %40
%49 = load i8*, i8** %8
%50 = load i8*, i8** %13
%51 = call i32 @memcpy(i8* %49, i8* %50, i32 4)
%52 = load i8*, i8** %8
%53 = getelementptr inbounds i8, i8* %52, i64 4
store i8* %53, i8** %8
br label %54
54: ; preds = %48, %40
br label %55
55: ; preds = %54, %32
br label %56
56: ; preds = %55, %22
%57 = load i8*, i8** %8
%58 = getelementptr inbounds i8, i8* %57, i64 0
store i8 -1, i8* %58
store i32 0, i32* %7
br label %59
59: ; preds = %56, %21
%60 = load i32, i32* %7
ret i32 %60
}

LLVM IR (-O2):
define i32 @add_multiple_option(i8* %0, i8 zeroext %1, i8 signext %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8*
store i8* %0, i8** %7
%8 = call i32 @endOption(i8** %7)
%9 = load i8*, i8** %7
store i8 %1, i8* %9
%10 = icmp eq i8 %1, -1
br i1 %10, label %33, label %11
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** %7
store i8 %2, i8* %13
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** %7
%16 = icmp eq i8* %3, null
br i1 %16, label %31, label %17
17: ; preds = %11
%18 = call i32 @memcpy(i8* %15, i8* %3, i32 4)
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 4
store i8* %20, i8** %7
%21 = icmp eq i8* %4, null
br i1 %21, label %31, label %22
22: ; preds = %17
%23 = call i32 @memcpy(i8* %20, i8* %4, i32 4)
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i64 4
store i8* %25, i8** %7
%26 = icmp eq i8* %5, null
br i1 %26, label %31, label %27
27: ; preds = %22
%28 = call i32 @memcpy(i8* %25, i8* %5, i32 4)
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 4
store i8* %30, i8** %7
br label %31
31: ; preds = %17, %27, %22, %11
%32 = phi i8* [ %20, %17 ], [ %30, %27 ], [ %25, %22 ], [ %15, %11 ]
store i8 -1, i8* %32
br label %33
33: ; preds = %6, %31
ret i32 0
}