#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*/ assert(char *);
int /*<<< orphan*/ fatal(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ warnf(char *);
char *xstrdup(char const *);
unsigned parse_relax(const char *str) {
  char *copy = xstrdup(str);
  assert(copy);
  unsigned mask = 0;
  char *token = strtok(copy, ",");
  while (token != NULL) {
    if (strcmp(token, "prefer-explicit") == 0)
      mask |= (1 << 0);
    else if (strcmp(token, "locally-static") == 0)
      mask |= (1 << 1);
    else if (strcmp(token, "generic-static") == 0) {
      warnf("relax option 'generic-static' is deprecated: use "
            "'locally-static' instead");
      mask |= (1 << 1);
    } else if (strcmp(token, "universal-bound") == 0)
      mask |= (1 << 2);
    else if (strcmp(token, "pure-files") == 0)
      mask |= (1 << 3);
    else if (strcmp(token, "impure") == 0)
      mask |= (1 << 4);
    else
      fatal("invalid relax option '%s'", token);
    token = strtok(NULL, ",");
  }
  free(copy);
  return mask;
}


x86 assembly (clang, -O0):
<parse_relax>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <xstrdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <assert@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12f6 <parse_relax+0x186>
mov    -0x20(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e0 <parse_relax+0x70>
mov    -0x14(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12dd <parse_relax+0x16d>
mov    -0x20(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1208 <parse_relax+0x98>
mov    -0x14(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    12d8 <parse_relax+0x168>
mov    -0x20(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <parse_relax+0xcc>
lea    0xe07(%rip),%rdi
call   1040 <warnf@plt>
mov    -0x14(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    12d3 <parse_relax+0x163>
mov    -0x20(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1264 <parse_relax+0xf4>
mov    -0x14(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    12ce <parse_relax+0x15e>
mov    -0x20(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    128c <parse_relax+0x11c>
mov    -0x14(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    12c9 <parse_relax+0x159>
mov    -0x20(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b4 <parse_relax+0x144>
mov    -0x14(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x14(%rbp)
jmp    12c4 <parse_relax+0x154>
mov    -0x20(%rbp),%rsi
lea    0xddd(%rip),%rdi
call   1090 <fatal@plt>
jmp    12c9 <parse_relax+0x159>
jmp    12ce <parse_relax+0x15e>
jmp    12d3 <parse_relax+0x163>
jmp    12d8 <parse_relax+0x168>
jmp    12dd <parse_relax+0x16d>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd18(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    11ad <parse_relax+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_relax>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1050 <xstrdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
lea    0xe6e(%rip),%rsi
mov    %rbx,(%rsp)
mov    %rbx,%rdi
call   1080 <strtok@plt>
test   %rax,%rax
je     12a4 <parse_relax+0x134>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xe4f(%rip),%r15
lea    0xe46(%rip),%r12
lea    0xe51(%rip),%r13
lea    0xe59(%rip),%rbp
jmp    11e9 <parse_relax+0x79>
nopw   0x0(%rax,%rax,1)
or     $0x1,%ebx
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
mov    %rax,%r14
test   %rax,%rax
je     12a6 <parse_relax+0x136>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d0 <parse_relax+0x60>
mov    %r14,%rdi
mov    %r13,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1270 <parse_relax+0x100>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1278 <parse_relax+0x108>
mov    %r14,%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     128c <parse_relax+0x11c>
mov    %r14,%rdi
lea    0xe53(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1294 <parse_relax+0x124>
mov    %r14,%rdi
lea    0xe4a(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     129c <parse_relax+0x12c>
lea    0xe40(%rip),%rdi
mov    %r14,%rsi
call   1090 <fatal@plt>
jmp    11d3 <parse_relax+0x63>
nopl   0x0(%rax)
or     $0x2,%ebx
jmp    11d3 <parse_relax+0x63>
lea    0xdb1(%rip),%rdi
call   1040 <warnf@plt>
or     $0x2,%ebx
jmp    11d3 <parse_relax+0x63>
or     $0x4,%ebx
jmp    11d3 <parse_relax+0x63>
or     $0x8,%ebx
jmp    11d3 <parse_relax+0x63>
or     $0x10,%ebx
jmp    11d3 <parse_relax+0x63>
xor    %ebx,%ebx
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [16 x i8] c"prefer-explicit\00"
@.str.2 = [15 x i8] c"locally-static\00"
@.str.3 = [15 x i8] c"generic-static\00"
@.str.4 = [74 x i8] c"relax option 'generic-static' is deprecated: use 'locally-static' instead\00"
@.str.5 = [16 x i8] c"universal-bound\00"
@.str.6 = [11 x i8] c"pure-files\00"
@.str.7 = [7 x i8] c"impure\00"
@.str.8 = [26 x i8] c"invalid relax option '%s'\00"
define i32 @parse_relax(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @xstrdup(i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @assert(i8* %8)
store i32 0, i32* %4
%10 = load i8*, i8** %3
%11 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %5
br label %12
12: ; preds = %66, %1
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %68
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %4
%21 = or i32 %20, 1
store i32 %21, i32* %4
br label %66
22: ; preds = %15
%23 = load i8*, i8** %5
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %4
%28 = or i32 %27, 2
store i32 %28, i32* %4
br label %65
29: ; preds = %22
%30 = load i8*, i8** %5
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = call i32 @warnf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* %4
%36 = or i32 %35, 2
store i32 %36, i32* %4
br label %64
37: ; preds = %29
%38 = load i8*, i8** %5
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %4
%43 = or i32 %42, 4
store i32 %43, i32* %4
br label %63
44: ; preds = %37
%45 = load i8*, i8** %5
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* %4
%50 = or i32 %49, 8
store i32 %50, i32* %4
br label %62
51: ; preds = %44
%52 = load i8*, i8** %5
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i32, i32* %4
%57 = or i32 %56, 16
store i32 %57, i32* %4
br label %61
58: ; preds = %51
%59 = load i8*, i8** %5
%60 = call i32 @fatal(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %58, %55
br label %62
62: ; preds = %61, %48
br label %63
63: ; preds = %62, %41
br label %64
64: ; preds = %63, %33
br label %65
65: ; preds = %64, %26
br label %66
66: ; preds = %65, %19
%67 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %67, i8** %5
br label %12
68: ; preds = %12
%69 = load i8*, i8** %3
%70 = call i32 @free(i8* %69)
%71 = load i32, i32* %4
ret i32 %71
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [16 x i8] c"prefer-explicit\00"
@.str.2 = [15 x i8] c"locally-static\00"
@.str.3 = [15 x i8] c"generic-static\00"
@.str.4 = [74 x i8] c"relax option 'generic-static' is deprecated: use 'locally-static' instead\00"
@.str.5 = [16 x i8] c"universal-bound\00"
@.str.6 = [11 x i8] c"pure-files\00"
@.str.7 = [7 x i8] c"impure\00"
@.str.8 = [26 x i8] c"invalid relax option '%s'\00"
define i32 @parse_relax(i8* %0) {
%2 = tail call i8* @xstrdup(i8* %0)
%3 = tail call i32 @assert(i8* %2)
%4 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %45, label %6
6: ; preds = %1, %41
%7 = phi i8* [ %43, %41 ], [ %4, %1 ]
%8 = phi i32 [ %42, %41 ], [ 0, %1 ]
%9 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = or i32 %8, 1
br label %41
13: ; preds = %6
%14 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = or i32 %8, 2
br label %41
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i32 @warnf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0))
%23 = or i32 %8, 2
br label %41
24: ; preds = %18
%25 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = or i32 %8, 4
br label %41
29: ; preds = %24
%30 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = or i32 %8, 8
br label %41
34: ; preds = %29
%35 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = or i32 %8, 16
br label %41
39: ; preds = %34
%40 = tail call i32 @fatal(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %7)
br label %41
41: ; preds = %16, %27, %37, %39, %32, %21, %11
%42 = phi i32 [ %12, %11 ], [ %17, %16 ], [ %23, %21 ], [ %28, %27 ], [ %33, %32 ], [ %38, %37 ], [ %8, %39 ]
%43 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %6
45: ; preds = %41, %1
%46 = phi i32 [ 0, %1 ], [ %42, %41 ]
%47 = tail call i32 @free(i8* %2)
ret i32 %46
}