#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*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int IsCopyright(char *orig, char *buffer) {
  char *pt;
  if (strstr(orig, "/* Copyright (C)") == NULL)
    return (0);
  if (strstr(orig, "2012") != NULL)
    return (0);
  if ((pt = strstr(orig, "2011")) == NULL)
    return (0);
  strncpy(buffer, orig, pt - orig);
  buffer[pt - orig] = '\0';
  if (pt[-1] == '-')
    strcat(buffer, "2012");
  else if (pt[-1] == ',') {
    buffer[(pt - orig) - 1] = '-';
    strcat(buffer, "2012");
  } else if (pt[-1] == ' ' && pt[strlen("2011")] == ' ') {
    strcat(buffer, "2011");
    strcat(buffer, ",");
    strcat(buffer, "2012");
  } else
    return (0);
  strcat(buffer, pt + strlen("2011"));
  return (1);
}


x86 assembly (clang, -O0):
<IsCopyright>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    1176 <IsCopyright+0x36>
movl   $0x0,-0x4(%rbp)
jmp    1311 <IsCopyright+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     119c <IsCopyright+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1311 <IsCopyright+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11c6 <IsCopyright+0x86>
movl   $0x0,-0x4(%rbp)
jmp    1311 <IsCopyright+0x1d1>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2d,%eax
jne    1219 <IsCopyright+0xd9>
mov    -0x18(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1050 <strcat@plt>
jmp    12dc <IsCopyright+0x19c>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2c,%eax
jne    1256 <IsCopyright+0x116>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
sub    $0x1,%rcx
movb   $0x2d,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
lea    0xdc5(%rip),%rsi
call   1050 <strcat@plt>
jmp    12d7 <IsCopyright+0x197>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    12c6 <IsCopyright+0x186>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xda0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    12c6 <IsCopyright+0x186>
mov    -0x18(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xd6f(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xd55(%rip),%rsi
call   1050 <strcat@plt>
jmp    12d2 <IsCopyright+0x192>
movl   $0x0,-0x4(%rbp)
jmp    1311 <IsCopyright+0x1d1>
jmp    12d7 <IsCopyright+0x197>
jmp    12dc <IsCopyright+0x19c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xd23(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rsi
call   1050 <strcat@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsCopyright>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeab(%rip),%rsi
call   1060 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1175 <IsCopyright+0x35>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1180 <IsCopyright+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     1175 <IsCopyright+0x35>
mov    %rax,%r14
mov    %rax,%r12
sub    %rbx,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%r12,1)
mov    -0x1(%r14),%al
cmp    $0x20,%al
je     11c8 <IsCopyright+0x88>
cmp    $0x2d,%al
je     11fb <IsCopyright+0xbb>
cmp    $0x2c,%al
jne    1175 <IsCopyright+0x35>
movb   $0x2d,-0x1(%r12,%r15,1)
jmp    11fb <IsCopyright+0xbb>
lea    0xe47(%rip),%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x20,(%r14,%rax,1)
jne    1175 <IsCopyright+0x35>
lea    0xe32(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcat@plt>
lea    0xe28(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcat@plt>
lea    0xe0f(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcat@plt>
lea    0xe05(%rip),%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    $0x1,%ebp
jmp    1175 <IsCopyright+0x35>

LLVM IR (-O0):
@.str = [17 x i8] c"/* Copyright (C)\00"
@.str.1 = [5 x i8] c"2012\00"
@.str.2 = [5 x i8] c"2011\00"
@.str.3 = [2 x i8] c",\00"
define i32 @IsCopyright(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i8* @strstr(i8* %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %94
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 0, i32* %3
br label %94
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = call i8* @strstr(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %18, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 0, i32* %3
br label %94
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = load i8*, i8** %4
%24 = load i8*, i8** %6
%25 = load i8*, i8** %4
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = call i32 @strncpy(i8* %22, i8* %23, i32 %29)
%31 = load i8*, i8** %5
%32 = load i8*, i8** %6
%33 = load i8*, i8** %4
%34 = ptrtoint i8* %32 to i64
%35 = ptrtoint i8* %33 to i64
%36 = sub i64 %34, %35
%37 = getelementptr inbounds i8, i8* %31, i64 %36
store i8 0, i8* %37
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i64 -1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 45
br i1 %42, label %43, label %46
43: ; preds = %21
%44 = load i8*, i8** %5
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %87
46: ; preds = %21
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 -1
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 44
br i1 %51, label %52, label %63
52: ; preds = %46
%53 = load i8*, i8** %5
%54 = load i8*, i8** %6
%55 = load i8*, i8** %4
%56 = ptrtoint i8* %54 to i64
%57 = ptrtoint i8* %55 to i64
%58 = sub i64 %56, %57
%59 = sub nsw i64 %58, 1
%60 = getelementptr inbounds i8, i8* %53, i64 %59
store i8 45, i8* %60
%61 = load i8*, i8** %5
%62 = call i32 @strcat(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %86
63: ; preds = %46
%64 = load i8*, i8** %6
%65 = getelementptr inbounds i8, i8* %64, i64 -1
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 32
br i1 %68, label %69, label %84
69: ; preds = %63
%70 = load i8*, i8** %6
%71 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 32
br i1 %76, label %77, label %84
77: ; preds = %69
%78 = load i8*, i8** %5
%79 = call i32 @strcat(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%80 = load i8*, i8** %5
%81 = call i32 @strcat(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%82 = load i8*, i8** %5
%83 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %85
84: ; preds = %69, %63
store i32 0, i32* %3
br label %94
85: ; preds = %77
br label %86
86: ; preds = %85, %52
br label %87
87: ; preds = %86, %43
%88 = load i8*, i8** %5
%89 = load i8*, i8** %6
%90 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %89, i64 %91
%93 = call i32 @strcat(i8* %88, i8* %92)
store i32 1, i32* %3
br label %94
94: ; preds = %87, %84, %20, %15, %10
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@.str = [17 x i8] c"/* Copyright (C)\00"
@.str.1 = [5 x i8] c"2012\00"
@.str.2 = [5 x i8] c"2011\00"
@.str.3 = [2 x i8] c",\00"
define i32 @IsCopyright(i8* %0, i8* %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %38, label %5
5: ; preds = %2
%6 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %38
8: ; preds = %5
%9 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %38, label %11
11: ; preds = %8
%12 = ptrtoint i8* %9 to i64
%13 = ptrtoint i8* %0 to i64
%14 = sub i64 %12, %13
%15 = trunc i64 %14 to i32
%16 = tail call i32 @strncpy(i8* %1, i8* %0, i32 %15)
%17 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 0, i8* %17
%18 = getelementptr inbounds i8, i8* %9, i64 -1
%19 = load i8, i8* %18
switch i8 %19, label %38 [
i8 45, label %32
i8 44, label %20
i8 32, label %23
]
20: ; preds = %11
%21 = add nsw i64 %14, -1
%22 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 45, i8* %22
br label %32
23: ; preds = %11
%24 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %9, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 32
br i1 %28, label %29, label %38
29: ; preds = %23
%30 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %11, %20, %29
%33 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %9, i64 %35
%37 = tail call i32 @strcat(i8* %1, i8* %36)
br label %38
38: ; preds = %23, %11, %8, %5, %2, %32
%39 = phi i32 [ 1, %32 ], [ 0, %2 ], [ 0, %5 ], [ 0, %8 ], [ 0, %11 ], [ 0, %23 ]
ret i32 %39
}