#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 *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  char *dcopref;
  char *delim;
  if ((argc != 2) || (argv[1][0] == '-')) {
    fprintf(stderr, "Usage: dcopobject <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 = delim + 1;
  dcopref[strlen(dcopref) - 1] = 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    128c <main+0x13c>
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    126a <main+0x11a>
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    126a <main+0x11a>
mov    -0x18(%rbp),%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1228 <main+0xd8>
jmp    126a <main+0x11a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    128c <main+0x13c>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xda8(%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   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1162 <main+0x12>
mov    0x8(%rsi),%rbx
cmpb   $0x2d,(%rbx)
jne    117b <main+0x2b>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11f6 <main+0xa6>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11dc <main+0x8c>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x29,-0x1(%rax,%rbx,1)
jne    11dc <main+0x8c>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11dc <main+0x8c>
mov    %rax,%r14
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,(%rax,%r14,1)
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    11fb <main+0xab>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: dcopobject <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 %61
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 %57
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 %57
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 %57
46: ; preds = %40
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %48, i8** %6
%49 = load i8*, i8** %6
%50 = load i8*, i8** %6
%51 = call i32 @strlen(i8* %50)
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %49, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %6
%56 = call i32 @puts(i8* %55)
store i32 0, i32* %3
br label %61
57: ; preds = %45, %39, %28
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %6
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %59)
store i32 1, i32* %3
br label %61
61: ; preds = %57, %46, %18
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: dcopobject <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 %35
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 %32
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 %32
22: ; preds = %15
%23 = tail call i8* @strchr(i8* %6, i8 signext 44)
%24 = icmp eq i8* %23, null
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %23, i64 1
%27 = tail call i32 @strlen(i8* %26)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8 0, i8* %30
%31 = tail call i32 @puts(i8* %26)
br label %35
32: ; preds = %22, %15, %12
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %35
35: ; preds = %32, %25, %9
%36 = phi i32 [ 1, %9 ], [ 1, %32 ], [ 0, %25 ]
ret i32 %36
}