#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 base_to_10(char *, int);
int /*<<< orphan*/ printf(char *, int, int);
char *reverse(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int num, base;
  char str[20];
  scanf("%d%d", &num, &base);
  for (int i = 0; i < num; i++) {
    scanf("%s", str);
    printf("%d %d\n", base_to_10(str, base), base_to_10(reverse(str), base));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cc <main+0x8c>
lea    -0x20(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <base_to_10@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <reverse@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1050 <base_to_10@plt>
mov    -0x28(%rbp),%esi
mov    %eax,%edx
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116c <main+0x2c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c4 <main+0x84>
lea    0xe93(%rip),%r14
lea    0x10(%rsp),%r12
lea    0xe8a(%rip),%r15
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
mov    %r12,%rdi
call   1050 <base_to_10@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1030 <reverse@plt>
mov    0x8(%rsp),%esi
mov    %rax,%rdi
call   1050 <base_to_10@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jl     1180 <main+0x40>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
store i32 0, i32* %5
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 @base_to_10(i8* %14, i32 %15)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%18 = call i8* @reverse(i8* %17)
%19 = load i32, i32* %3
%20 = call i32 @base_to_10(i8* %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %20)
br label %22
22: ; preds = %11
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %7
25: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %11, %0
ret i32 0
11: ; preds = %0, %11
%12 = phi i32 [ %20, %11 ], [ 0, %0 ]
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = load i32, i32* %2
%15 = call i32 @base_to_10(i8* %6, i32 %14)
%16 = call i8* @reverse(i8* %6)
%17 = load i32, i32* %2
%18 = call i32 @base_to_10(i8* %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %18)
%20 = add nuw nsw i32 %12, 1
%21 = load i32, i32* %1
%22 = icmp slt i32 %20, %21
br i1 %22, label %11, label %10
}