#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 atoi(char *);
int /*<<< orphan*/ inplace_reverse(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main() {
  int calls;
  scanf("%d", &calls);
  int i;
  for (i = 0; i < calls; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    char str1[1000];
    char str2[1000];
    sprintf(str1, "%d", a);
    sprintf(str2, "%d", b);
    inplace_reverse(str1);
    inplace_reverse(str2);
    int d = atoi(str1);
    int c = atoi(str2);
    char sum[10000];
    sprintf(sum, "%d", d + c);
    inplace_reverse(sum);
    int t = atoi(sum);
    printf("%d\n", t);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2f20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1262 <main+0x112>
lea    0xe72(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe55(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x7f0(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe3f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x400(%rbp),%rdi
call   1070 <inplace_reverse@plt>
lea    -0x7f0(%rbp),%rdi
call   1070 <inplace_reverse@plt>
lea    -0x400(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x7f4(%rbp)
lea    -0x7f0(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x7f8(%rbp)
lea    -0x2f10(%rbp),%rdi
mov    -0x7f4(%rbp),%edx
add    -0x7f8(%rbp),%edx
lea    0xde4(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x2f10(%rbp),%rdi
call   1070 <inplace_reverse@plt>
lea    -0x2f10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x2f14(%rbp)
mov    -0x2f14(%rbp),%esi
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <main+0x2b>
mov    -0x4(%rbp),%eax
add    $0x2f20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2f08,%rsp
lea    0xe9b(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1237 <main+0xe7>
lea    0xe7d(%rip),%r13
lea    0x400(%rsp),%rbx
lea    0x10(%rsp),%rbp
lea    0x7f0(%rsp),%r14
xor    %r15d,%r15d
xchg   %ax,%ax
lea    0xe59(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <sprintf@plt>
mov    0x8(%rsp),%edx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <inplace_reverse@plt>
mov    %rbp,%rdi
call   1070 <inplace_reverse@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1050 <atoi@plt>
add    %eax,%r12d
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1070 <inplace_reverse@plt>
mov    %r14,%rdi
call   1050 <atoi@plt>
lea    0xde5(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%r15d
cmp    0x4(%rsp),%r15d
jl     11a0 <main+0x50>
xor    %eax,%eax
add    $0x2f08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10000 x i8]
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %13
13: ; preds = %44, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %47
17: ; preds = %13
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* %4
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* %5
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%26 = call i32 @inplace_reverse(i8* %25)
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%28 = call i32 @inplace_reverse(i8* %27)
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %8
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %9
%33 = getelementptr inbounds [10000 x i8], [10000 x i8]* %10, i64 0, i64 0
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = add nsw i32 %34, %35
%37 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [10000 x i8], [10000 x i8]* %10, i64 0, i64 0
%39 = call i32 @inplace_reverse(i8* %38)
%40 = getelementptr inbounds [10000 x i8], [10000 x i8]* %10, i64 0, i64 0
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %11
%42 = load i32, i32* %11
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %17
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %13
47: ; preds = %13
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca [10000 x i8]
%7 = bitcast i32* %1 to i8*
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %0
%12 = bitcast i32* %2 to i8*
%13 = bitcast i32* %3 to i8*
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
br label %17
17: ; preds = %11, %17
%18 = phi i32 [ 0, %11 ], [ %33, %17 ]
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%20 = load i32, i32* %2
%21 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @sprintf(i8* %15, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = call i32 @inplace_reverse(i8* %14)
%25 = call i32 @inplace_reverse(i8* %15)
%26 = call i32 @atoi(i8* %14)
%27 = call i32 @atoi(i8* %15)
%28 = add nsw i32 %27, %26
%29 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = call i32 @inplace_reverse(i8* %16)
%31 = call i32 @atoi(i8* %16)
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = add nuw nsw i32 %18, 1
%34 = load i32, i32* %1
%35 = icmp slt i32 %33, %34
br i1 %35, label %17, label %36
36: ; preds = %17, %0
ret i32 0
}