#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ puts(char const *);
int /*<<< orphan*/ stderr;
char *strchr(char const *, char);
int strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
int main(int argc, char *argv[]) {
  const char *dcopref;
  char *delim;
  if ((argc != 2) || (argv[1][0] == '-')) {
    fprintf(stderr, "Usage: dcopclient <dcopref>\n");
    return 1;
  }
  dcopref = argv[1];
  if (strncmp(dcopref, "DCOPRef(", 8) != 0)
    goto bad_ref;
  if (dcopref[strlen(dcopref) - 1] != ')')
    goto bad_ref;
  delim = strchr(dcopref, ',');
  if (!delim)
    goto bad_ref;
  dcopref += 8;
  *delim = 0;
  puts(dcopref);
  return 0;
bad_ref:
  fprintf(stderr, "Error: '%s' is not a valid DCOP reference.\n", dcopref);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1184 <main+0x34>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11a7 <main+0x57>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1272 <main+0x122>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11d7 <main+0x87>
jmp    1250 <main+0x100>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x29,%eax
je     1206 <main+0xb6>
jmp    1250 <main+0x100>
mov    -0x18(%rbp),%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1228 <main+0xd8>
jmp    1250 <main+0x100>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1272 <main+0x122>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    115f <main+0xf>
mov    0x8(%rsi),%rbx
cmpb   $0x2d,(%rbx)
jne    1178 <main+0x28>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11e1 <main+0x91>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11c7 <main+0x77>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x29,-0x1(%rax,%rbx,1)
jne    11c7 <main+0x77>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11c7 <main+0x77>
add    $0x8,%rbx
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: dcopclient <dcopref>\0A\00"
@.str.1 = [9 x i8] c"DCOPRef(\00"
@.str.2 = [44 x i8] c"Error: '%s' is not a valid DCOP reference.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %18, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 45
br i1 %17, label %18, label %21
18: ; preds = %10, %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %56
21: ; preds = %10
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = call i64 @strncmp(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %21
br label %52
29: ; preds = %21
%30 = load i8*, i8** %6
%31 = load i8*, i8** %6
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 41
br i1 %38, label %39, label %40
39: ; preds = %29
br label %52
40: ; preds = %29
%41 = load i8*, i8** %6
%42 = call i8* @strchr(i8* %41, i8 signext 44)
store i8* %42, i8** %7
%43 = load i8*, i8** %7
%44 = icmp ne i8* %43, null
br i1 %44, label %46, label %45
45: ; preds = %40
br label %52
46: ; preds = %40
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 8
store i8* %48, i8** %6
%49 = load i8*, i8** %7
store i8 0, i8* %49
%50 = load i8*, i8** %6
%51 = call i32 @puts(i8* %50)
store i32 0, i32* %3
br label %56
52: ; preds = %45, %39, %28
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %6
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %54)
store i32 1, i32* %3
br label %56
56: ; preds = %52, %46, %18
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: dcopclient <dcopref>\0A\00"
@.str.1 = [9 x i8] c"DCOPRef(\00"
@.str.2 = [44 x i8] c"Error: '%s' is not a valid DCOP reference.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
br i1 %8, label %9, label %12
9: ; preds = %4, %2
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %31
12: ; preds = %4
%13 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = tail call i32 @strlen(i8* %6)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %6, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 41
br i1 %21, label %22, label %28
22: ; preds = %15
%23 = tail call i8* @strchr(i8* %6, i8 signext 44)
%24 = icmp eq i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %6, i64 8
store i8 0, i8* %23
%27 = tail call i32 @puts(i8* %26)
br label %31
28: ; preds = %22, %15, %12
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %31
31: ; preds = %28, %25, %9
%32 = phi i32 [ 1, %9 ], [ 1, %28 ], [ 0, %25 ]
ret i32 %32
}