#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num1, num2, result = 0;
  int num3[100] = {0};
  int i = 0;
  printf("1st number: ");
  scanf("%d", &num1);
  printf("2nd number: ");
  scanf("%d", &num2);
  puts("Column1  Column2  Column3");
  puts("-----------------------");
  do {
    printf("%d\t|%d\t|", num1, num2);
    if (num1 % 2 == 1) {
      printf("+ %d", num2);
      num3[i] = num2;
      result += num3[i];
      i++;
    }
    num1 /= 2, num2 *= 2;
    printf("\n");
  } while (num1 != 0);
  printf("\nResult: ");
  for (i -= 1; i >= 0; i--) {
    printf("%d", num3[i]);
    if (i > 0)
      printf(" + ");
    else
      printf(" = ");
  }
  printf("%d\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1050 <memset@plt>
movl   $0x0,-0x1a4(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1237 <main+0xf7>
mov    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11ca <main+0x8a>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
cmpl   $0x0,-0x1a4(%rbp)
jl     12f3 <main+0x1b3>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x1a4(%rbp)
jle    12cc <main+0x18c>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12da <main+0x19a>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12df <main+0x19f>
mov    -0x1a4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1283 <main+0x143>
mov    -0x10(%rbp),%esi
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0x10(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed4(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%esi
lea    0xe7e(%rip),%r14
lea    0xe80(%rip),%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1205 <main+0xb5>
nopl   0x0(%rax,%rax,1)
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,0x8(%rsp)
add    %esi,%esi
mov    %esi,0xc(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%esi
test   %esi,%esi
je     124e <main+0xfe>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
mov    %eax,%edx
sub    %ecx,%edx
mov    0xc(%rsp),%esi
cmp    $0x1,%edx
jne    11e0 <main+0x90>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
movslq %ebx,%rbx
mov    %esi,0x10(%rsp,%rbx,4)
add    %esi,%ebp
add    $0x1,%ebx
mov    0x8(%rsp),%eax
jmp    11e0 <main+0x90>
lea    0xe05(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    12be <main+0x16e>
lea    -0x1(%rbx),%eax
mov    0x10(%rsp,%rax,4),%esi
lea    0xde9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%ebx
je     12b0 <main+0x160>
mov    %ebx,%ebx
add    $0xfffffffffffffffe,%rbx
lea    0xddd(%rip),%r14
lea    0xdc9(%rip),%r15
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
mov    0x10(%rsp,%rax,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
jb     1290 <main+0x140>
lea    0xdb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xda7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"1st number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"2nd number: \00"
@.str.3 = [26 x i8] c"Column1 Column2 Column3\00"
@.str.4 = [24 x i8] c"-----------------------\00"
@.str.5 = [9 x i8] c"%d\09|%d\09|\00"
@.str.6 = [5 x i8] c"+ %d\00"
@.str.8 = [10 x i8] c"\0AResult: \00"
@.str.9 = [4 x i8] c" + \00"
@.str.10 = [4 x i8] c" = \00"
@.str.11 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [100 x i32]* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32, i32* %1
br label %14
14: ; preds = %32, %0
%15 = phi i32 [ %13, %0 ], [ %40, %32 ]
%16 = phi i32 [ 0, %0 ], [ %35, %32 ]
%17 = phi i32 [ 0, %0 ], [ %36, %32 ]
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %15, i32 %18)
%20 = load i32, i32* %1
%21 = srem i32 %20, 2
%22 = icmp eq i32 %21, 1
%23 = load i32, i32* %2
br i1 %22, label %24, label %32
24: ; preds = %14
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%26 = load i32, i32* %2
%27 = sext i32 %17 to i64
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %27
store i32 %26, i32* %28
%29 = add nsw i32 %26, %16
%30 = add nsw i32 %17, 1
%31 = load i32, i32* %1
br label %32
32: ; preds = %14, %24
%33 = phi i32 [ %26, %24 ], [ %23, %14 ]
%34 = phi i32 [ %31, %24 ], [ %20, %14 ]
%35 = phi i32 [ %29, %24 ], [ %16, %14 ]
%36 = phi i32 [ %30, %24 ], [ %17, %14 ]
%37 = sdiv i32 %34, 2
store i32 %37, i32* %1
%38 = shl nsw i32 %33, 1
store i32 %38, i32* %2
%39 = call i32 @putchar(i32 10)
%40 = load i32, i32* %1
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %14
42: ; preds = %32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%44 = icmp sgt i32 %36, 0
br i1 %44, label %45, label %64
45: ; preds = %42
%46 = zext i32 %36 to i64
%47 = add nsw i64 %46, -1
%48 = and i64 %47, 4294967295
%49 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = icmp eq i32 %36, 1
br i1 %52, label %62, label %53
53: ; preds = %45, %53
%54 = phi i64 [ %56, %53 ], [ %47, %45 ]
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%56 = add nsw i64 %54, -1
%57 = and i64 %56, 4294967295
%58 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = icmp eq i64 %54, 1
br i1 %61, label %62, label %53
62: ; preds = %53, %45
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
br label %64
64: ; preds = %62, %42
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %35)
ret i32 0
}