#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*/ putchar(char);
void printresult(int *res, int *j) {
  char *buffer = (char *)malloc(1000001 * sizeof(char));
  register int x = *j, i = 0, z = 0;
  int num = 0, rem = 0;
  while (x--) {
    z = 0;
    num = res[i];
    if (num == 0) {
      putchar('0');
      putchar('\n');
      i++;
    } else {
      while (num != 0) {
        rem = num % 10;
        buffer[z] = rem + '0';
        z++;
        num = num / 10;
      }
      while (z--) {
        putchar(buffer[z]);
      }
      putchar('\n');
      i++;
    }
  }
  free(buffer);
}


x86 assembly (clang, -O0):
<printresult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xf4241,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     125b <printresult+0x12b>
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    11c8 <printresult+0x98>
mov    $0x30,%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1256 <printresult+0x126>
jmp    11cd <printresult+0x9d>
cmpl   $0x0,-0x28(%rbp)
je     1214 <printresult+0xe4>
mov    -0x28(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
jmp    11cd <printresult+0x9d>
jmp    1219 <printresult+0xe9>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
je     1243 <printresult+0x113>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <putchar@plt>
jmp    1219 <printresult+0xe9>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1173 <printresult+0x43>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printresult>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0xf4241,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    (%r15),%r15d
test   %r15d,%r15d
je     1205 <printresult+0xd5>
xor    %r13d,%r13d
movabs $0x100000000,%rbp
jmp    118d <printresult+0x5d>
nopl   0x0(%rax)
mov    $0x30,%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r13
test   %r15d,%r15d
je     1205 <printresult+0xd5>
add    $0xffffffff,%r15d
mov    (%r14,%r13,4),%eax
test   %eax,%eax
je     1170 <printresult+0x40>
mov    %rbx,%rcx
movabs $0xffffffff00000000,%r12
ff ff ff
cs nopw 0x0(%rax,%rax,1)
add    %rbp,%r12
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rax
add    %esi,%eax
lea    (%rax,%rax,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%edi
sub    %esi,%edi
add    $0x30,%dil
mov    %dil,(%rcx)
add    $0x9,%edx
add    $0x1,%rcx
cmp    $0x13,%edx
jae    11b0 <printresult+0x80>
sar    $0x20,%r12
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%r12,1),%edi
call   1040 <putchar@plt>
add    $0xffffffffffffffff,%r12
jb     11f0 <printresult+0xc0>
jmp    117a <printresult+0x4a>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @printresult(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i64 @malloc(i32 1000001)
%4 = inttoptr i64 %3 to i8*
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %41, label %7
7: ; preds = %2, %37
%8 = phi i64 [ %39, %37 ], [ 0, %2 ]
%9 = phi i32 [ %10, %37 ], [ %5, %2 ]
%10 = add nsw i32 %9, -1
%11 = getelementptr inbounds i32, i32* %0, i64 %8
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %7
%15 = tail call i32 @putchar(i8 signext 48)
br label %37
16: ; preds = %19
%17 = shl i64 %20, 32
%18 = ashr exact i64 %17, 32
br label %30
19: ; preds = %7, %19
%20 = phi i64 [ %26, %19 ], [ 0, %7 ]
%21 = phi i32 [ %27, %19 ], [ %12, %7 ]
%22 = srem i32 %21, 10
%23 = trunc i32 %22 to i8
%24 = add nsw i8 %23, 48
%25 = getelementptr inbounds i8, i8* %4, i64 %20
store i8 %24, i8* %25
%26 = add nuw i64 %20, 1
%27 = sdiv i32 %21, 10
%28 = add i32 %21, 9
%29 = icmp ult i32 %28, 19
br i1 %29, label %16, label %19
30: ; preds = %16, %30
%31 = phi i64 [ %18, %16 ], [ %35, %30 ]
%32 = getelementptr inbounds i8, i8* %4, i64 %31
%33 = load i8, i8* %32
%34 = tail call i32 @putchar(i8 signext %33)
%35 = add nsw i64 %31, -1
%36 = icmp eq i64 %31, 0
br i1 %36, label %37, label %30
37: ; preds = %30, %14
%38 = tail call i32 @putchar(i8 signext 10)
%39 = add nuw nsw i64 %8, 1
%40 = icmp eq i32 %10, 0
br i1 %40, label %41, label %7
41: ; preds = %37, %2
%42 = tail call i32 @free(i8* %4)
ret void
}