#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *, char *);
int main(void) {
  int i, carry, tmp;
  char *init, *current;
  init = (char *)malloc(10000001);
  current = (char *)malloc(10000001);
  scanf("%s %s", init, current);
  carry = 1;
  for (i = 0; current[i] != 0; i++) {
    tmp = (current[i] == init[i] ? 0 : 1) + carry;
    carry = tmp > 1;
    current[i] = (tmp == 1 ? '1' : '0') == init[i] ? '0' : '1';
  }
  printf("%s\n", current);
  free(init);
  free(current);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x989681,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x989681,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe86(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1224 <main+0xe4>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%ecx
mov    $0x30,%edx
mov    $0x31,%eax
cmp    $0x1,%ecx
cmove  %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
mov    $0x31,%eax
mov    $0x30,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118d <main+0x4d>
mov    -0x20(%rbp),%rsi
lea    0xdd7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x989681,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x989681,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1060 <scanf@plt>
mov    (%rbx),%dl
test   %dl,%dl
je     11bb <main+0x7b>
mov    $0x1,%ecx
xor    %eax,%eax
nopl   (%rax)
movsbl (%r14,%rax,1),%esi
xor    %edi,%edi
cmp    %sil,%dl
setne  %dil
add    %ecx,%edi
xor    %ecx,%ecx
cmp    $0x2,%edi
setae  %cl
xor    %edx,%edx
cmp    $0x1,%edi
sete   %dl
or     $0x30,%edx
cmp    %esi,%edx
sete   %dl
xor    $0x31,%dl
mov    %dl,(%rbx,%rax,1)
movzbl 0x1(%rbx,%rax,1),%edx
add    $0x1,%rax
test   %dl,%dl
jne    1180 <main+0x40>
lea    0xe44(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 10000001)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i64 @malloc(i32 10000001)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %4)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %29, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %25, %8 ], [ 0, %0 ]
%10 = phi i8 [ %27, %8 ], [ %6, %0 ]
%11 = phi i8* [ %26, %8 ], [ %4, %0 ]
%12 = phi i32 [ %20, %8 ], [ 1, %0 ]
%13 = getelementptr inbounds i8, i8* %2, i64 %9
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i8 %10, %14
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %12, %17
%19 = icmp ugt i32 %18, 1
%20 = zext i1 %19 to i32
%21 = icmp eq i32 %18, 1
%22 = select i1 %21, i32 49, i32 48
%23 = icmp eq i32 %22, %15
%24 = select i1 %23, i8 48, i8 49
store i8 %24, i8* %11
%25 = add nuw nsw i64 %9, 1
%26 = getelementptr inbounds i8, i8* %4, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %8
29: ; preds = %8, %0
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%31 = tail call i32 @free(i8* %2)
%32 = tail call i32 @free(i8* %4)
ret i32 0
}