#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ quitnow(int);
int /*<<< orphan*/ stderr;
scalar_t__ strchr(char *, char);
int strtoul(char const *, char **, int /*<<< orphan*/);
void fdom_split(const char *fdom, const char **dom_r, int *qf_r, char *ownflags,
                int ownflags_l) {
  int qf;
  char *ep;
  qf = strtoul(fdom, &ep, 0);
  if (*ep == ',' && strchr(ep, '/')) {
    ep++;
    while (*ep != '/') {
      if (--ownflags_l <= 0) {
        fputs("too many flags\n", stderr);
        quitnow(3);
      }
      *ownflags++ = *ep++;
    }
  }
  if (*ep != '/') {
    *dom_r = fdom;
    *qf_r = 0;
  } else {
    *dom_r = ep + 1;
    *qf_r = qf;
  }
  *ownflags = 0;
}


x86 assembly (clang, -O0):
<fdom_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    120f <fdom_split+0xcf>
mov    -0x30(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     120f <fdom_split+0xcf>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     120a <fdom_split+0xca>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jg     11e3 <fdom_split+0xa3>
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
lea    0xe2c(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x3,%edi
call   1050 <quitnow@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11a2 <fdom_split+0x62>
jmp    120f <fdom_split+0xcf>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1239 <fdom_split+0xf9>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    1251 <fdom_split+0x111>
mov    -0x30(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdom_split>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%r12
lea    0x20(%rsp),%rsi
xor    %r13d,%r13d
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    0x20(%rsp),%rbp
mov    0x0(%rbp),%r15b
cmp    $0x2c,%r15b
mov    %eax,0x1c(%rsp)
jne    11f5 <fdom_split+0xb5>
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f1 <fdom_split+0xb1>
mov    0x1(%rbp),%al
add    $0x1,%rbp
mov    $0x2f,%r15b
jmp    11c2 <fdom_split+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,(%rbx)
add    $0x1,%rbx
movzbl 0x1(%rbp),%eax
add    $0x1,%rbp
add    $0xffffffff,%r14d
cmp    $0x2f,%al
je     11f5 <fdom_split+0xb5>
cmp    $0x1,%r14d
jg     11b0 <fdom_split+0x70>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    0xe24(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x3,%edi
call   1050 <quitnow@plt>
movzbl 0x0(%rbp),%eax
jmp    11b0 <fdom_split+0x70>
mov    0x0(%rbp),%r15b
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
add    $0x1,%rbp
cmp    $0x2f,%r15b
cmove  %rbp,%r12
cmove  0x1c(%rsp),%r13d
mov    %r12,(%rcx)
mov    %r13d,(%rax)
movb   $0x0,(%rbx)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"too many flags\0A\00"
@stderr = global i32 0
define void @fdom_split(i8* %0, i8** %1, i32* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = load i8*, i8** %6
%14 = call i32 @strtoul(i8* %13, i8** %12, i32 0)
store i32 %14, i32* %11
%15 = load i8*, i8** %12
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 44
br i1 %18, label %19, label %46
19: ; preds = %5
%20 = load i8*, i8** %12
%21 = call i64 @strchr(i8* %20, i8 signext 47)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %46
23: ; preds = %19
%24 = load i8*, i8** %12
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %12
br label %26
26: ; preds = %39, %23
%27 = load i8*, i8** %12
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 47
br i1 %30, label %31, label %45
31: ; preds = %26
%32 = load i32, i32* %10
%33 = add nsw i32 %32, -1
store i32 %33, i32* %10
%34 = icmp sle i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = call i32 @quitnow(i32 3)
br label %39
39: ; preds = %35, %31
%40 = load i8*, i8** %12
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %12
%42 = load i8, i8* %40
%43 = load i8*, i8** %9
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %9
store i8 %42, i8* %43
br label %26
45: ; preds = %26
br label %46
46: ; preds = %45, %19, %5
%47 = load i8*, i8** %12
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 47
br i1 %50, label %51, label %55
51: ; preds = %46
%52 = load i8*, i8** %6
%53 = load i8**, i8*** %7
store i8* %52, i8** %53
%54 = load i32*, i32** %8
store i32 0, i32* %54
br label %61
55: ; preds = %46
%56 = load i8*, i8** %12
%57 = getelementptr inbounds i8, i8* %56, i64 1
%58 = load i8**, i8*** %7
store i8* %57, i8** %58
%59 = load i32, i32* %11
%60 = load i32*, i32** %8
store i32 %59, i32* %60
br label %61
61: ; preds = %55, %51
%62 = load i8*, i8** %9
store i8 0, i8* %62
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"too many flags\0A\00"
@stderr = global i32 0
define void @fdom_split(i8* %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2, i8* nocapture writeonly %3, i32 %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = call i32 @strtoul(i8* %0, i8** %6, i32 0)
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 44
br i1 %11, label %12, label %39
12: ; preds = %5
%13 = tail call i64 @strchr(i8* %9, i8 signext 47)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i8, i8* %9
br label %39
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %9, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 47
br i1 %20, label %39, label %21
21: ; preds = %17, %33
%22 = phi i8 [ %37, %33 ], [ %19, %17 ]
%23 = phi i8* [ %36, %33 ], [ %3, %17 ]
%24 = phi i32 [ %26, %33 ], [ %4, %17 ]
%25 = phi i8* [ %35, %33 ], [ %18, %17 ]
%26 = add nsw i32 %24, -1
%27 = icmp slt i32 %24, 2
br i1 %27, label %28, label %33
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = tail call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = tail call i32 @quitnow(i32 3)
%32 = load i8, i8* %25
br label %33
33: ; preds = %28, %21
%34 = phi i8 [ %32, %28 ], [ %22, %21 ]
%35 = getelementptr inbounds i8, i8* %25, i64 1
%36 = getelementptr inbounds i8, i8* %23, i64 1
store i8 %34, i8* %23
%37 = load i8, i8* %35
%38 = icmp eq i8 %37, 47
br i1 %38, label %39, label %21
39: ; preds = %33, %17, %15, %5
%40 = phi i8 [ %16, %15 ], [ %10, %5 ], [ 47, %17 ], [ 47, %33 ]
%41 = phi i8* [ %9, %15 ], [ %9, %5 ], [ %18, %17 ], [ %35, %33 ]
%42 = phi i8* [ %3, %15 ], [ %3, %5 ], [ %3, %17 ], [ %36, %33 ]
%43 = icmp eq i8 %40, 47
%44 = getelementptr inbounds i8, i8* %41, i64 1
%45 = select i1 %43, i8* %44, i8* %0
%46 = select i1 %43, i32 %8, i32 0
store i8* %45, i8** %1
store i32 %46, i32* %2
store i8 0, i8* %42
ret void
}