#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 fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char buffer[8192];
  char *bufptr;
  if (argc == 2) {
    strcpy(buffer, argv[1]);
    bufptr = buffer + strlen(buffer);
  } else {
    bufptr = buffer;
  }
  bufptr = bufptr + fread(bufptr, 1, 8191, stdin);
  *bufptr = '\0';
  fputs(buffer, stdout);
  for (bufptr = buffer; *bufptr != '\0'; bufptr++) {
    if (*(bufptr + 1) == ':') {
      *bufptr = 'd';
      break;
    }
  }
  fputs(buffer, stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11ac <main+0x6c>
lea    -0x2010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2020(%rbp)
lea    -0x2010(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2020(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2018(%rbp)
jmp    11ba <main+0x7a>
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2018(%rbp),%rax
mov    %rax,-0x2028(%rbp)
mov    -0x2018(%rbp),%rdi
mov    0x2e12(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1fff,%edx
call   1040 <fread@plt>
mov    %eax,%ecx
mov    -0x2028(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2018(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2010(%rbp),%rdi
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127c <main+0x13c>
mov    -0x2018(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3a,%eax
jne    1260 <main+0x120>
mov    -0x2018(%rbp),%rax
movb   $0x64,(%rax)
jmp    127c <main+0x13c>
jmp    1265 <main+0x125>
mov    -0x2018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2018(%rbp)
jmp    122a <main+0xea>
lea    -0x2010(%rbp),%rdi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
call   1060 <fputs@plt>
xor    %eax,%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2000,%rsp
cmp    $0x2,%edi
jne    116c <main+0x2c>
mov    0x8(%rsi),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbx
jmp    116f <main+0x2f>
mov    %rsp,%rbx
mov    0x2e72(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1fff,%edx
call   1040 <fread@plt>
cltq
movb   $0x0,(%rbx,%rax,1)
mov    0x2e41(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%rdi
call   1060 <fputs@plt>
mov    (%rsp),%cl
lea    0x1(%rsp),%rax
nopl   0x0(%rax)
test   %cl,%cl
je     11c4 <main+0x84>
movzbl (%rax),%ecx
add    $0x1,%rax
cmp    $0x3a,%cl
jne    11b0 <main+0x70>
movb   $0x64,-0x2(%rax)
mov    (%rbx),%esi
mov    %rsp,%rdi
call   1060 <fputs@plt>
xor    %eax,%eax
add    $0x2000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8192 x 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 eq i32 %8, 2
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcpy(i8* %11, i8* %14)
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
store i8* %20, i8** %7
br label %23
21: ; preds = %2
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
store i8* %22, i8** %7
br label %23
23: ; preds = %21, %10
%24 = load i8*, i8** %7
%25 = load i8*, i8** %7
%26 = load i32, i32* @stdin
%27 = call i32 @fread(i8* %25, i32 1, i32 8191, i32 %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %24, i64 %28
store i8* %29, i8** %7
%30 = load i8*, i8** %7
store i8 0, i8* %30
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* %31, i32 %32)
%34 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
store i8* %34, i8** %7
br label %35
35: ; preds = %49, %23
%36 = load i8*, i8** %7
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %52
40: ; preds = %35
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 58
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = load i8*, i8** %7
store i8 100, i8* %47
br label %52
48: ; preds = %40
br label %49
49: ; preds = %48
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
br label %35
52: ; preds = %46, %35
%53 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%54 = load i32, i32* @stdout
%55 = call i32 @fputs(i8* %53, i32 %54)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @strcpy(i8* %4, i8* %8)
%10 = call i32 @strlen(i8* %4)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %11
br label %13
13: ; preds = %2, %6
%14 = phi i8* [ %12, %6 ], [ %4, %2 ]
%15 = load i32, i32* @stdin
%16 = call i32 @fread(i8* %14, i32 1, i32 8191, i32 %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
store i8 0, i8* %18
%19 = load i32, i32* @stdout
%20 = call i32 @fputs(i8* %4, i32 %19)
%21 = load i8, i8* %4
br label %22
22: ; preds = %26, %13
%23 = phi i8 [ %21, %13 ], [ %28, %26 ]
%24 = phi i8* [ %4, %13 ], [ %27, %26 ]
%25 = icmp eq i8 %23, 0
br i1 %25, label %31, label %26
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %24, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 58
br i1 %29, label %30, label %22
30: ; preds = %26
store i8 100, i8* %24
br label %31
31: ; preds = %22, %30
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* %4, i32 %32)
ret i32 0
}