#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char a[19];
  scanf("%s", a);
  int i;
  for (i = 0; i < strlen(a); i++) {
    if (a[0] == '9' && i == 0)
      continue;
    if ((9 - a[i] + '0') < (a[i] - '0')) {
      int x = 9 - a[i] + '0';
      a[i] = x + '0';
    }
  }
  for (i = 0; i < strlen(a); i++) {
    printf("%c", a[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11ee <main+0xbe>
movsbl -0x20(%rbp),%eax
cmp    $0x39,%eax
jne    118e <main+0x5e>
cmpl   $0x0,-0x24(%rbp)
jne    118e <main+0x5e>
jmp    11e0 <main+0xb0>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%ecx
mov    $0x9,%eax
sub    %ecx,%eax
add    $0x30,%eax
movslq -0x24(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
sub    $0x30,%ecx
cmp    %ecx,%eax
jge    11db <main+0xab>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%ecx
mov    $0x9,%eax
sub    %ecx,%eax
add    $0x30,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
jmp    11e0 <main+0xb0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1156 <main+0x26>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    1236 <main+0x106>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f5 <main+0xc5>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1199 <main+0x69>
xor    %ebx,%ebx
mov    %rsp,%r14
jmp    1173 <main+0x43>
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1199 <main+0x69>
cmpb   $0x39,(%rsp)
jne    117e <main+0x4e>
test   %rbx,%rbx
je     1160 <main+0x30>
movsbl (%rsp,%rbx,1),%eax
mov    $0x39,%ecx
sub    %eax,%ecx
lea    -0x30(%rax),%edx
cmp    %edx,%ecx
jge    1160 <main+0x30>
mov    $0x69,%cl
sub    %al,%cl
mov    %cl,(%rsp,%rbx,1)
jmp    1160 <main+0x30>
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11cc <main+0x9c>
xor    %ebx,%ebx
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11b0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [19 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %51, %0
%8 = load i32, i32* %3
%9 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %54
12: ; preds = %7
%13 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 57
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
br label %51
21: ; preds = %17, %12
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = sub nsw i32 9, %26
%28 = add nsw i32 %27, 48
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
%35 = icmp slt i32 %28, %34
br i1 %35, label %36, label %50
36: ; preds = %21
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = sub nsw i32 9, %41
%43 = add nsw i32 %42, 48
store i32 %43, i32* %4
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 48
%46 = trunc i32 %45 to i8
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 %48
store i8 %46, i8* %49
br label %50
50: ; preds = %36, %21
br label %51
51: ; preds = %50, %20
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %7
54: ; preds = %7
store i32 0, i32* %3
br label %55
55: ; preds = %67, %54
%56 = load i32, i32* %3
%57 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = icmp slt i32 %56, %58
br i1 %59, label %60, label %70
60: ; preds = %55
%61 = load i32, i32* %3
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %60
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %55
70: ; preds = %55
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [19 x i8]
%2 = getelementptr inbounds [19 x i8], [19 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %24, %0
%7 = call i32 @strlen(i8* %2)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %29, label %39
9: ; preds = %0, %24
%10 = phi i64 [ %25, %24 ], [ 0, %0 ]
%11 = load i8, i8* %2
%12 = icmp eq i8 %11, 57
%13 = icmp eq i64 %10, 0
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %24, label %15
15: ; preds = %9
%16 = getelementptr inbounds [19 x i8], [19 x i8]* %1, i64 0, i64 %10
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = sub nsw i32 57, %18
%20 = add nsw i32 %18, -48
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = sub i8 105, %17
store i8 %23, i8* %16
br label %24
24: ; preds = %15, %22, %9
%25 = add nuw nsw i64 %10, 1
%26 = call i32 @strlen(i8* %2)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %9, label %6
29: ; preds = %6, %29
%30 = phi i64 [ %35, %29 ], [ 0, %6 ]
%31 = getelementptr inbounds [19 x i8], [19 x i8]* %1, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 @putchar(i32 %33)
%35 = add nuw nsw i64 %30, 1
%36 = call i32 @strlen(i8* %2)
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %29, label %39
39: ; preds = %29, %6
%40 = call i32 @putchar(i32 10)
ret i32 0
}