#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*/ CmdUseOnepackage(char *, char *);
int /*<<< orphan*/ diagnostics(int, char *, char *, ...);
int /*<<< orphan*/ free(char *);
char *getBraceParam();
char *getBracketParam();
char *strchr(char *, char);
char *strdup_noblanks(char *);
void CmdUsepackage(int code) {
  char *package, *package_with_spaces;
  char *options, *options_with_spaces;
  char *p, *comma;
  options = NULL;
  options_with_spaces = getBracketParam();
  package_with_spaces = getBraceParam();
  package = strdup_noblanks(package_with_spaces);
  free(package_with_spaces);
  if (options_with_spaces) {
    options = strdup_noblanks(options_with_spaces);
    free(options_with_spaces);
    diagnostics(2, "Package {%s} with options [%s]", package, options);
  } else
    diagnostics(2, "Package {%s} with no options", package);
  p = package;
  do {
    comma = strchr(p, ',');
    if (comma)
      *comma = '\0';
    CmdUseOnepackage(p, options);
    if (comma)
      p = comma + 1;
  } while (comma != NULL);
  if (options)
    free(options);
  free(package);
}


x86 assembly (clang, -O0):
<CmdUsepackage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1080 <getBracketParam@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <getBraceParam@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strdup_noblanks@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x28(%rbp)
je     11f0 <CmdUsepackage+0x80>
mov    -0x28(%rbp),%rdi
call   1040 <strdup_noblanks@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x2,%edi
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1070 <diagnostics@plt>
jmp    1207 <CmdUsepackage+0x97>
mov    -0x10(%rbp),%rdx
mov    $0x2,%edi
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1070 <diagnostics@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1233 <CmdUsepackage+0xc3>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <CmdUseOnepackage@plt>
cmpq   $0x0,-0x38(%rbp)
je     1257 <CmdUsepackage+0xe7>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    125c <CmdUsepackage+0xec>
cmpq   $0x0,-0x38(%rbp)
jne    120f <CmdUsepackage+0x9f>
cmpq   $0x0,-0x20(%rbp)
je     127b <CmdUsepackage+0x10b>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CmdUsepackage>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <getBracketParam@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1050 <getBraceParam@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strdup_noblanks@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     11d2 <CmdUsepackage+0x62>
mov    %r15,%rdi
call   1040 <strdup_noblanks@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xe42(%rip),%rsi
mov    $0x2,%edi
mov    %r14,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1070 <diagnostics@plt>
jmp    11eb <CmdUsepackage+0x7b>
lea    0xe46(%rip),%rsi
xor    %r12d,%r12d
mov    $0x2,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <diagnostics@plt>
mov    %r14,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %r14,%rbx
test   %rax,%rax
je     123b <CmdUsepackage+0xcb>
mov    %rax,%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%r15)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <CmdUseOnepackage@plt>
mov    %r15,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1210 <CmdUsepackage+0xa0>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <CmdUseOnepackage@plt>
test   %r12,%r12
je     1253 <CmdUsepackage+0xe3>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

LLVM IR (-O2):
@.str = [31 x i8] c"Package {%s} with options [%s]\00"
@.str.1 = [29 x i8] c"Package {%s} with no options\00"
define void @CmdUsepackage(i32 %0) {
%2 = tail call i8* (...) @getBracketParam()
%3 = tail call i8* (...) @getBraceParam()
%4 = tail call i8* @strdup_noblanks(i8* %3)
%5 = tail call i32 @free(i8* %3)
%6 = icmp eq i8* %2, null
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = tail call i8* @strdup_noblanks(i8* %2)
%9 = tail call i32 @free(i8* %2)
%10 = tail call i32 (i32, i8*, i8*, ...) @diagnostics(i32 2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %8)
br label %13
11: ; preds = %1
%12 = tail call i32 (i32, i8*, i8*, ...) @diagnostics(i32 2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %13
13: ; preds = %11, %7
%14 = phi i8* [ %8, %7 ], [ null, %11 ]
%15 = tail call i8* @strchr(i8* dereferenceable(1) %4, i8 signext 44)
%16 = icmp eq i8* %15, null
br i1 %16, label %24, label %17
17: ; preds = %13, %17
%18 = phi i8* [ %22, %17 ], [ %15, %13 ]
%19 = phi i8* [ %21, %17 ], [ %4, %13 ]
store i8 0, i8* %18
%20 = tail call i32 @CmdUseOnepackage(i8* %19, i8* %14)
%21 = getelementptr inbounds i8, i8* %18, i64 1
%22 = tail call i8* @strchr(i8* dereferenceable(1) %21, i8 signext 44)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %17
24: ; preds = %17, %13
%25 = phi i8* [ %4, %13 ], [ %21, %17 ]
%26 = tail call i32 @CmdUseOnepackage(i8* %25, i8* %14)
%27 = icmp eq i8* %14, null
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = tail call i32 @free(i8* %14)
br label %30
30: ; preds = %28, %24
%31 = tail call i32 @free(i8* %4)
ret void
}