#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 NAME_MAX;
int /*<<< orphan*/ free(char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strjoin(char *, char, char *, size_t);
size_t strlen(char *);
char *xmalloc(size_t);
char *xstrdup(char *);
char *swdepends(char *optslist) {
  if (!optslist)
    return NULL;
  size_t olen = strlen(optslist);
  if (!olen)
    return NULL;
  size_t blen = 2 * olen;
  char *buf = xmalloc(blen);
  buf[0] = 0;
  char name[NAME_MAX];
  char *wp, *we, *oe;
  oe = optslist + olen;
  wp = optslist;
  while (wp < oe) {
    while (*wp == ' ' || *wp == 0)
      wp++;
    we = wp;
    while (*we != ' ' && we < oe)
      we++;
    *we = 0;
    strcpy(name, wp);
    char *splitp = strchr(name, '+');
    if (splitp) {
      *splitp = 0;
      strjoin(buf, ' ', name, blen);
      *(splitp - 1) = *(splitp + 1);
      *(splitp + 1) = 0;
      strjoin(buf, ' ', name, blen);
    } else
      strjoin(buf, ' ', name, blen);
    wp = we;
  }
  free(optslist);
  char *ret = xstrdup(buf);
  return ret;
}


x86 assembly (clang, -O0):
<swdepends>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1194 <swdepends+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1384 <swdepends+0x214>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b9 <swdepends+0x49>
movq   $0x0,-0x8(%rbp)
jmp    1384 <swdepends+0x214>
mov    -0x18(%rbp),%rax
add    %rax,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <xmalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x50(%rbp),%rax
jae    135f <swdepends+0x1ef>
jmp    122b <swdepends+0xbb>
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x69(%rbp)
je     1250 <swdepends+0xe0>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    1260 <swdepends+0xf0>
jmp    1271 <swdepends+0x101>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    122b <swdepends+0xbb>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x6a(%rbp)
je     129c <swdepends+0x12c>
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
setb   %al
mov    %al,-0x6a(%rbp)
mov    -0x6a(%rbp),%al
test   $0x1,%al
jne    12ac <swdepends+0x13c>
jmp    12bd <swdepends+0x14d>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1279 <swdepends+0x109>
mov    -0x68(%rbp),%rdi
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x68(%rbp),%rdi
mov    $0x2b,%esi
call   1060 <strchr@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     133c <swdepends+0x1cc>
mov    -0x68(%rbp),%rdx
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x20,%esi
call   1090 <strjoin@plt>
mov    -0x68(%rbp),%rdx
mov    -0x58(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x58(%rbp),%rax
mov    %cl,-0x1(%rax)
mov    -0x58(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x20,%esi
call   1090 <strjoin@plt>
jmp    1352 <swdepends+0x1e2>
mov    -0x68(%rbp),%rdx
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x20,%esi
call   1090 <strjoin@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1218 <swdepends+0xa8>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1080 <xstrdup@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swdepends>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdi,%rdi
je     12cf <swdepends+0x15f>
mov    %rdi,%r14
call   1050 <strlen@plt>
test   %rax,%rax
je     12cf <swdepends+0x15f>
mov    %rax,%rbx
mov    %r14,-0x38(%rbp)
lea    (%rax,%rax,1),%rdi
mov    %rdi,-0x50(%rbp)
call   1070 <xmalloc@plt>
mov    %rax,%r14
mov    %rsp,-0x40(%rbp)
movb   $0x0,(%rax)
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
test   %rbx,%rbx
jle    12b8 <swdepends+0x148>
mov    -0x38(%rbp),%rsi
add    %rsi,%rbx
mov    %r14,-0x48(%rbp)
jmp    11f4 <swdepends+0x84>
nopl   (%rax)
add    $0x1,%rsi
mov    (%rsi),%al
test   $0xdf,%al
je     11f0 <swdepends+0x80>
cmp    %rbx,%rsi
setb   %r12b
mov    %rsi,%r15
cmp    $0x20,%al
je     123e <swdepends+0xce>
cmp    %rbx,%rsi
mov    -0x30(%rbp),%r13
jae    1242 <swdepends+0xd2>
lea    0x1(%rsi),%rax
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %rbx,%rax
setb   %r12b
lea    0x1(%rax),%r15
cmpb   $0x20,(%rax)
je     1238 <swdepends+0xc8>
cmp    %rbx,%rax
mov    %r15,%rax
jb     1220 <swdepends+0xb0>
add    $0xffffffffffffffff,%r15
jmp    1242 <swdepends+0xd2>
mov    -0x30(%rbp),%r13
movb   $0x0,(%r15)
mov    %r13,%rdi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    $0x2b,%esi
call   1060 <strchr@plt>
mov    %r13,%rdx
mov    %r14,%r13
test   %rax,%rax
mov    -0x50(%rbp),%rcx
je     129c <swdepends+0x12c>
mov    %rax,%r14
movb   $0x0,(%rax)
mov    %r13,%rdi
mov    $0x20,%esi
mov    -0x30(%rbp),%rdx
mov    %rcx,%r13
call   1090 <strjoin@plt>
mov    %r13,%rcx
mov    -0x48(%rbp),%r13
mov    -0x30(%rbp),%rdx
mov    0x1(%r14),%al
mov    %al,-0x1(%r14)
movb   $0x0,0x1(%r14)
mov    %r13,%rdi
mov    $0x20,%esi
call   1090 <strjoin@plt>
mov    %r15,%rsi
test   %r12b,%r12b
mov    %r13,%r14
jne    11f4 <swdepends+0x84>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1080 <xstrdup@plt>
mov    -0x40(%rbp),%rsp
jmp    12d1 <swdepends+0x161>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NAME_MAX = global i32 0
define i8* @swdepends(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %3
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %1
store i8* null, i8** %2
br label %109
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = call i64 @strlen(i8* %18)
store i64 %19, i64* %4
%20 = load i64, i64* %4
%21 = icmp ne i64 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %17
store i8* null, i8** %2
br label %109
23: ; preds = %17
%24 = load i64, i64* %4
%25 = mul i64 2, %24
store i64 %25, i64* %5
%26 = load i64, i64* %5
%27 = call i8* @xmalloc(i64 %26)
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 0, i8* %29
%30 = load i32, i32* @NAME_MAX
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
store i8* %32, i8** %7
%33 = alloca i8, i64 %31
store i64 %31, i64* %8
%34 = load i8*, i8** %3
%35 = load i64, i64* %4
%36 = getelementptr inbounds i8, i8* %34, i64 %35
store i8* %36, i8** %11
%37 = load i8*, i8** %3
store i8* %37, i8** %9
br label %38
38: ; preds = %100, %23
%39 = load i8*, i8** %9
%40 = load i8*, i8** %11
%41 = icmp ult i8* %39, %40
br i1 %41, label %42, label %102
42: ; preds = %38
br label %43
43: ; preds = %55, %42
%44 = load i8*, i8** %9
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 32
br i1 %47, label %53, label %48
48: ; preds = %43
%49 = load i8*, i8** %9
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 0
br label %53
53: ; preds = %48, %43
%54 = phi i1 [ true, %43 ], [ %52, %48 ]
br i1 %54, label %55, label %58
55: ; preds = %53
%56 = load i8*, i8** %9
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %9
br label %43
58: ; preds = %53
%59 = load i8*, i8** %9
store i8* %59, i8** %10
br label %60
60: ; preds = %71, %58
%61 = load i8*, i8** %10
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 32
br i1 %64, label %65, label %69
65: ; preds = %60
%66 = load i8*, i8** %10
%67 = load i8*, i8** %11
%68 = icmp ult i8* %66, %67
br label %69
69: ; preds = %65, %60
%70 = phi i1 [ false, %60 ], [ %68, %65 ]
br i1 %70, label %71, label %74
71: ; preds = %69
%72 = load i8*, i8** %10
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %10
br label %60
74: ; preds = %69
%75 = load i8*, i8** %10
store i8 0, i8* %75
%76 = load i8*, i8** %9
%77 = call i32 @strcpy(i8* %33, i8* %76)
%78 = call i8* @strchr(i8* %33, i8 signext 43)
store i8* %78, i8** %12
%79 = load i8*, i8** %12
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %96
81: ; preds = %74
%82 = load i8*, i8** %12
store i8 0, i8* %82
%83 = load i8*, i8** %6
%84 = load i64, i64* %5
%85 = call i32 @strjoin(i8* %83, i8 signext 32, i8* %33, i64 %84)
%86 = load i8*, i8** %12
%87 = getelementptr inbounds i8, i8* %86, i64 1
%88 = load i8, i8* %87
%89 = load i8*, i8** %12
%90 = getelementptr inbounds i8, i8* %89, i64 -1
store i8 %88, i8* %90
%91 = load i8*, i8** %12
%92 = getelementptr inbounds i8, i8* %91, i64 1
store i8 0, i8* %92
%93 = load i8*, i8** %6
%94 = load i64, i64* %5
%95 = call i32 @strjoin(i8* %93, i8 signext 32, i8* %33, i64 %94)
br label %100
96: ; preds = %74
%97 = load i8*, i8** %6
%98 = load i64, i64* %5
%99 = call i32 @strjoin(i8* %97, i8 signext 32, i8* %33, i64 %98)
br label %100
100: ; preds = %96, %81
%101 = load i8*, i8** %10
store i8* %101, i8** %9
br label %38
102: ; preds = %38
%103 = load i8*, i8** %3
%104 = call i32 @free(i8* %103)
%105 = load i8*, i8** %6
%106 = call i8* @xstrdup(i8* %105)
store i8* %106, i8** %13
%107 = load i8*, i8** %13
store i8* %107, i8** %2
%108 = load i8*, i8** %7
br label %109
109: ; preds = %102, %22, %16
%110 = load i8*, i8** %2
ret i8* %110
}

LLVM IR (-O2):
@NAME_MAX = global i32 0
define i8* @swdepends(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %49, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %49, label %6
6: ; preds = %3
%7 = shl i64 %4, 1
%8 = tail call i8* @xmalloc(i64 %7)
store i8 0, i8* %8
%9 = load i32, i32* @NAME_MAX
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = getelementptr inbounds i8, i8* %0, i64 %4
%14 = icmp sgt i64 %4, 0
br i1 %14, label %15, label %46
15: ; preds = %6, %24
%16 = phi i8* [ %25, %24 ], [ %0, %6 ]
%17 = load i8, i8* %16
switch i8 %17, label %18 [
i8 32, label %22
i8 0, label %22
]
18: ; preds = %15
%19 = icmp ne i8 %17, 32
%20 = icmp ult i8* %16, %13
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %26, label %33
22: ; preds = %15, %15
%23 = getelementptr inbounds i8, i8* %16, i64 1
br label %24
24: ; preds = %22, %44
%25 = phi i8* [ %23, %22 ], [ %34, %44 ]
br label %15
26: ; preds = %18, %26
%27 = phi i8* [ %28, %26 ], [ %16, %18 ]
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = icmp ne i8 %29, 32
%31 = icmp ult i8* %28, %13
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %26, label %33
33: ; preds = %26, %18
%34 = phi i8* [ %16, %18 ], [ %28, %26 ]
%35 = phi i1 [ %20, %18 ], [ %31, %26 ]
store i8 0, i8* %34
%36 = call i32 @strcpy(i8* %12, i8* %16)
%37 = call i8* @strchr(i8* %12, i8 signext 43)
%38 = icmp eq i8* %37, null
br i1 %38, label %44, label %39
39: ; preds = %33
store i8 0, i8* %37
%40 = call i32 @strjoin(i8* %8, i8 signext 32, i8* %12, i64 %7)
%41 = getelementptr inbounds i8, i8* %37, i64 1
%42 = load i8, i8* %41
%43 = getelementptr inbounds i8, i8* %37, i64 -1
store i8 %42, i8* %43
store i8 0, i8* %41
br label %44
44: ; preds = %33, %39
%45 = call i32 @strjoin(i8* %8, i8 signext 32, i8* %12, i64 %7)
br i1 %35, label %24, label %46
46: ; preds = %44, %6
%47 = call i32 @free(i8* %0)
%48 = call i8* @xstrdup(i8* %8)
br label %49
49: ; preds = %46, %3, %1
%50 = phi i8* [ null, %1 ], [ %48, %46 ], [ null, %3 ]
ret i8* %50
}