#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 alloc_failed();
char *realloc(char *, unsigned int);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strdup(char const *);
unsigned int strlen(char const *);
int fuse_opt_add_opt(char **opts, const char *opt) {
  char *newopts;
  if (!*opts)
    newopts = strdup(opt);
  else {
    unsigned oldlen = strlen(*opts);
    newopts = realloc(*opts, oldlen + 1 + strlen(opt) + 1);
    if (newopts) {
      newopts[oldlen] = ',';
      strcpy(newopts + oldlen + 1, opt);
    }
  }
  if (!newopts)
    return alloc_failed();
  *opts = newopts;
  return 0;
}


x86 assembly (clang, -O0):
<fuse_opt_add_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1180 <fuse_opt_add_opt+0x30>
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    11f3 <fuse_opt_add_opt+0xa3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%rdi
add    %eax,%esi
add    $0x1,%esi
call   1060 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ee <fuse_opt_add_opt+0x9e>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
movb   $0x2c,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11f3 <fuse_opt_add_opt+0xa3>
cmpq   $0x0,-0x20(%rbp)
jne    120d <fuse_opt_add_opt+0xbd>
mov    $0x0,%al
call   1050 <alloc_failed@plt>
mov    %eax,-0x4(%rbp)
jmp    121f <fuse_opt_add_opt+0xcf>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fuse_opt_add_opt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rdi
test   %rdi,%rdi
je     11a9 <fuse_opt_add_opt+0x59>
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    (%r15),%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%r12,%rax,1),%esi
add    $0x2,%esi
mov    %rbx,%rdi
call   1060 <realloc@plt>
test   %rax,%rax
je     11ca <fuse_opt_add_opt+0x7a>
mov    %rax,%rbx
mov    %r12d,%eax
movb   $0x2c,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    11b9 <fuse_opt_add_opt+0x69>
mov    %r14,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ca <fuse_opt_add_opt+0x7a>
mov    %rbx,(%r15)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <alloc_failed@plt>

LLVM IR (-O0):
define i32 @fuse_opt_add_opt(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
%8 = load i8**, i8*** %4
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %6
br label %42
14: ; preds = %2
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %7
%18 = load i8**, i8*** %4
%19 = load i8*, i8** %18
%20 = load i32, i32* %7
%21 = add i32 %20, 1
%22 = load i8*, i8** %5
%23 = call i32 @strlen(i8* %22)
%24 = add i32 %21, %23
%25 = add i32 %24, 1
%26 = call i8* @realloc(i8* %19, i32 %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %41
29: ; preds = %14
%30 = load i8*, i8** %6
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 44, i8* %33
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8*, i8** %5
%40 = call i32 @strcpy(i8* %38, i8* %39)
br label %41
41: ; preds = %29, %14
br label %42
42: ; preds = %41, %11
%43 = load i8*, i8** %6
%44 = icmp ne i8* %43, null
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = call i32 (...) @alloc_failed()
store i32 %46, i32* %3
br label %50
47: ; preds = %42
%48 = load i8*, i8** %6
%49 = load i8**, i8*** %4
store i8* %48, i8** %49
store i32 0, i32* %3
br label %50
50: ; preds = %47, %45
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
define i32 @fuse_opt_add_opt(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %3)
%7 = load i8*, i8** %0
%8 = tail call i32 @strlen(i8* %1)
%9 = add i32 %6, 2
%10 = add i32 %9, %8
%11 = tail call i8* @realloc(i8* %7, i32 %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %21, label %13
13: ; preds = %5
%14 = zext i32 %6 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
store i8 44, i8* %15
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i32 @strcpy(i8* %16, i8* %1)
br label %23
18: ; preds = %2
%19 = tail call i8* @strdup(i8* %1)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %5, %18
%22 = tail call i32 (...) @alloc_failed()
br label %25
23: ; preds = %13, %18
%24 = phi i8* [ %11, %13 ], [ %19, %18 ]
store i8* %24, i8** %0
br label %25
25: ; preds = %23, %21
%26 = phi i32 [ 0, %23 ], [ %22, %21 ]
ret i32 %26
}