#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 nth_position(int, int);
int /*<<< orphan*/ printf(char *);
void print_in_binary(int src[], size_t size) {
  int i, j;
  for (i = 0; i < size; i++) {
    for (j = 9; j >= 0; j--) {
      if (nth_position(src[i], j) == 1) {
        printf("1");
      } else {
        printf("0");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_in_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11bc <print_in_binary+0x9c>
movl   $0x9,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11a2 <print_in_binary+0x82>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x18(%rbp),%esi
call   1040 <nth_position@plt>
cmp    $0x1,%eax
jne    1183 <print_in_binary+0x63>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
jmp    118f <print_in_binary+0x6f>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <print_in_binary+0x74>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <print_in_binary+0x2c>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <print_in_binary+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_in_binary>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     128a <print_in_binary+0x16a>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%edi
mov    $0x9,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x8,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x7,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x6,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x5,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x4,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x3,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x2,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
mov    $0x1,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    (%r15,%rbx,4),%edi
xor    %esi,%esi
call   1040 <nth_position@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <print_in_binary+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @print_in_binary(i32* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %60, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %58, %4 ], [ 0, %2 ]
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = tail call i32 @nth_position(i32 %7, i32 9)
%9 = icmp eq i32 %8, 1
%10 = select i1 %9, i32 49, i32 48
%11 = tail call i32 @putchar(i32 %10)
%12 = load i32, i32* %6
%13 = tail call i32 @nth_position(i32 %12, i32 8)
%14 = icmp eq i32 %13, 1
%15 = select i1 %14, i32 49, i32 48
%16 = tail call i32 @putchar(i32 %15)
%17 = load i32, i32* %6
%18 = tail call i32 @nth_position(i32 %17, i32 7)
%19 = icmp eq i32 %18, 1
%20 = select i1 %19, i32 49, i32 48
%21 = tail call i32 @putchar(i32 %20)
%22 = load i32, i32* %6
%23 = tail call i32 @nth_position(i32 %22, i32 6)
%24 = icmp eq i32 %23, 1
%25 = select i1 %24, i32 49, i32 48
%26 = tail call i32 @putchar(i32 %25)
%27 = load i32, i32* %6
%28 = tail call i32 @nth_position(i32 %27, i32 5)
%29 = icmp eq i32 %28, 1
%30 = select i1 %29, i32 49, i32 48
%31 = tail call i32 @putchar(i32 %30)
%32 = load i32, i32* %6
%33 = tail call i32 @nth_position(i32 %32, i32 4)
%34 = icmp eq i32 %33, 1
%35 = select i1 %34, i32 49, i32 48
%36 = tail call i32 @putchar(i32 %35)
%37 = load i32, i32* %6
%38 = tail call i32 @nth_position(i32 %37, i32 3)
%39 = icmp eq i32 %38, 1
%40 = select i1 %39, i32 49, i32 48
%41 = tail call i32 @putchar(i32 %40)
%42 = load i32, i32* %6
%43 = tail call i32 @nth_position(i32 %42, i32 2)
%44 = icmp eq i32 %43, 1
%45 = select i1 %44, i32 49, i32 48
%46 = tail call i32 @putchar(i32 %45)
%47 = load i32, i32* %6
%48 = tail call i32 @nth_position(i32 %47, i32 1)
%49 = icmp eq i32 %48, 1
%50 = select i1 %49, i32 49, i32 48
%51 = tail call i32 @putchar(i32 %50)
%52 = load i32, i32* %6
%53 = tail call i32 @nth_position(i32 %52, i32 0)
%54 = icmp eq i32 %53, 1
%55 = select i1 %54, i32 49, i32 48
%56 = tail call i32 @putchar(i32 %55)
%57 = tail call i32 @putchar(i32 10)
%58 = add nuw i64 %5, 1
%59 = icmp eq i64 %58, %1
br i1 %59, label %60, label %4
60: ; preds = %4, %2
ret void
}