#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);
void printNum(int *a, int d) {
  int i;
  for (i = d - 1; i > 0; i--)
    if (a[i] != 0)
      break;
  for (; i >= 0; i--)
    printf("%lld", a[i]);
}


x86 assembly (clang, -O0):
<printNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    115c <printNum+0x4c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1149 <printNum+0x39>
jmp    115c <printNum+0x4c>
jmp    114e <printNum+0x3e>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <printNum+0x18>
jmp    1161 <printNum+0x51>
cmpl   $0x0,-0x10(%rbp)
jl     1190 <printNum+0x80>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1161 <printNum+0x51>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printNum>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    %esi,%eax
test   %esi,%esi
mov    $0x1,%edx
cmovle %esi,%edx
lea    -0x1(%rdx),%ecx
nopw   0x0(%rax,%rax,1)
cmp    $0x2,%eax
jl     1146 <printNum+0x36>
add    $0xffffffffffffffff,%rax
mov    %eax,%esi
cmpl   $0x0,(%r15,%rsi,4)
je     1130 <printNum+0x20>
mov    %eax,%ecx
jmp    114a <printNum+0x3a>
test   %edx,%edx
jle    1177 <printNum+0x67>
mov    %ecx,%ebx
lea    0xead(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
lea    0x1(%rbx),%eax
test   %eax,%eax
jg     1160 <printNum+0x50>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
define void @printNum(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sub nsw i32 %6, 1
store i32 %7, i32* %5
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
br label %23
19: ; preds = %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, -1
store i32 %22, i32* %5
br label %8
23: ; preds = %18, %8
br label %24
24: ; preds = %34, %23
%25 = load i32, i32* %5
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %5
%36 = add nsw i32 %35, -1
store i32 %36, i32* %5
br label %24
37: ; preds = %24
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
define void @printNum(i32* nocapture %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = call i32 @llvm.smin.i32(i32 %1, i32 1)
%5 = add i32 %4, -1
br label %6
6: ; preds = %11, %2
%7 = phi i64 [ %8, %11 ], [ %3, %2 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = and i64 %8, 4294967295
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %6, label %18
16: ; preds = %6
%17 = icmp sgt i32 %4, 0
br i1 %17, label %20, label %31
18: ; preds = %11
%19 = trunc i64 %8 to i32
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %5, %16 ], [ %19, %18 ]
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %20, %23
%24 = phi i64 [ %22, %20 ], [ %28, %23 ]
%25 = getelementptr inbounds i32, i32* %0, i64 %24
%26 = load i32, i32* %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = add nsw i64 %24, -1
%29 = trunc i64 %24 to i32
%30 = icmp sgt i32 %29, 0
br i1 %30, label %23, label %31
31: ; preds = %23, %16
ret void
}