#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 *, long *);
int main() {
  long bin1, bin2;
  int i = 0, remainder = 0, sum[20];
  printf("Enter the first binary number: ");
  scanf("%ld", &bin1);
  printf("Enter the second binary number: ");
  scanf("%ld", &bin2);
  while (bin1 != 0 || bin2 != 0) {
    sum[i++] = (bin1 % 10 + bin2 % 10 + remainder) % 2;
    remainder = (bin1 % 10 + bin2 % 10 + remainder) / 2;
    bin1 = bin1 / 10;
    bin2 = bin2 / 10;
  }
  if (remainder != 0)
    sum[i++] = remainder;
  --i;
  printf("Sum of two binary numbers: ");
  while (i >= 0)
    printf("%d", sum[i--]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x71(%rbp)
jne    1197 <main+0x77>
cmpq   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    11a7 <main+0x87>
jmp    125c <main+0x13c>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x88(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    -0x88(%rbp),%rax
add    %rdx,%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %edx,%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x80(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    -0x80(%rbp),%rax
add    %rdx,%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    117c <main+0x5c>
cmpl   $0x0,-0x20(%rbp)
je     127a <main+0x15a>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jl     12bf <main+0x19f>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
mov    -0x70(%rbp,%rax,4),%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1291 <main+0x171>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee4(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rcx
mov    (%rsp),%rdx
mov    %rcx,%rax
or     %rdx,%rax
je     127d <main+0x15d>
xor    %r14d,%r14d
movabs $0x6666666666666667,%r8
66 66 66
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %rdx,%r10
mov    %rcx,%rbx
movslq %eax,%r9
mov    %rcx,%rax
imul   %r8
mov    %rdx,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rcx
add    %rax,%rcx
lea    (%rcx,%rcx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %rbx,%rdi
sub    %rax,%rdi
add    %r9,%rdi
mov    %r10,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %r10,%rsi
sub    %rax,%rsi
add    %rdi,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
add    %rsi,%rax
mov    %eax,%edi
and    $0xfffffffe,%edi
sub    %edi,%esi
mov    %esi,0x10(%rsp,%r14,4)
add    $0x1,%r14
sar    %rax
add    $0xfffffffffffffff6,%rbx
add    $0xfffffffffffffff6,%r10
cmp    $0xffffffffffffffed,%rbx
jb     1190 <main+0x70>
cmp    $0xffffffffffffffed,%r10
jb     1190 <main+0x70>
mov    %rcx,0x8(%rsp)
mov    %rdx,(%rsp)
test   %eax,%eax
je     1237 <main+0x117>
mov    %r14d,%ecx
add    $0x1,%r14d
mov    %eax,0x10(%rsp,%rcx,4)
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r14d,%r14d
jle    128b <main+0x16b>
mov    %r14d,%ebx
add    $0x1,%rbx
lea    0xe09(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1260 <main+0x140>
jmp    128b <main+0x16b>
lea    0xdc1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [32 x i8] c"Enter the first binary number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [33 x i8] c"Enter the second binary number: \00"
@.str.3 = [28 x i8] c"Sum of two binary numbers: \00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca [20 x i32]
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast [20 x i32]* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %1
%12 = load i64, i64* %2
%13 = icmp ne i64 %11, 0
%14 = icmp ne i64 %12, 0
%15 = select i1 %13, i1 true, i1 %14
br i1 %15, label %18, label %16
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %63
18: ; preds = %0, %18
%19 = phi i64 [ %31, %18 ], [ 0, %0 ]
%20 = phi i64 [ %33, %18 ], [ 0, %0 ]
%21 = phi i64 [ %34, %18 ], [ %11, %0 ]
%22 = phi i64 [ %35, %18 ], [ %12, %0 ]
%23 = srem i64 %21, 10
%24 = srem i64 %22, 10
%25 = shl i64 %20, 32
%26 = ashr exact i64 %25, 32
%27 = add nsw i64 %23, %26
%28 = add nsw i64 %27, %24
%29 = srem i64 %28, 2
%30 = trunc i64 %29 to i32
%31 = add nuw i64 %19, 1
%32 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %19
store i32 %30, i32* %32
%33 = sdiv i64 %28, 2
%34 = sdiv i64 %21, 10
%35 = sdiv i64 %22, 10
%36 = add i64 %21, -10
%37 = icmp ult i64 %36, -19
%38 = add i64 %22, -10
%39 = icmp ult i64 %38, -19
%40 = select i1 %37, i1 true, i1 %39
br i1 %40, label %18, label %41
41: ; preds = %18
%42 = trunc i64 %31 to i32
store i64 %34, i64* %1
store i64 %35, i64* %2
%43 = trunc i64 %33 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = add nuw nsw i32 %42, 1
%47 = and i64 %31, 4294967295
%48 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %47
store i32 %43, i32* %48
br label %49
49: ; preds = %45, %41
%50 = phi i32 [ %46, %45 ], [ %42, %41 ]
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp sgt i32 %50, 0
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = zext i32 %50 to i64
br label %55
55: ; preds = %53, %55
%56 = phi i64 [ %54, %53 ], [ %57, %55 ]
%57 = add nsw i64 %56, -1
%58 = and i64 %57, 4294967295
%59 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%62 = icmp ugt i64 %56, 1
br i1 %62, label %55, label %63
63: ; preds = %55, %16, %49
ret i32 0
}