#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 *, ...);
void printBinaryRepresentations(int n) {
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      printf("%d", ((1 << j) & i) >> j);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printBinaryRepresentations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jge    1196 <printBinaryRepresentations+0x86>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117a <printBinaryRepresentations+0x6a>
mov    -0xc(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
and    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
sar    %cl,%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <printBinaryRepresentations+0x30>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <printBinaryRepresentations+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBinaryRepresentations>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x1f,%edi
jne    1136 <printBinaryRepresentations+0x16>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r12d
mov    $0x1,%eax
mov    $0x1,%r15d
mov    %r12d,%ecx
shl    %cl,%r15d
cmp    $0x2,%r15d
cmovl  %eax,%r15d
lea    0xea7(%rip),%r14
xor    %ebx,%ebx
jmp    1172 <printBinaryRepresentations+0x52>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r15d,%ebx
je     112d <printBinaryRepresentations+0xd>
test   %r12d,%r12d
jle    1160 <printBinaryRepresentations+0x40>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x1,%esi
mov    %ebp,%ecx
shl    %cl,%esi
and    %ebx,%esi
shr    %cl,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1180 <printBinaryRepresentations+0x60>
jmp    1160 <printBinaryRepresentations+0x40>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @printBinaryRepresentations(i32 %0) {
%2 = icmp eq i32 %0, 31
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = shl nuw nsw i32 1, %0
%5 = icmp sgt i32 %0, 0
%6 = call i32 @llvm.smax.i32(i32 %4, i32 1)
br label %7
7: ; preds = %3, %10
%8 = phi i32 [ 0, %3 ], [ %12, %10 ]
br i1 %5, label %14, label %10
9: ; preds = %10, %1
ret void
10: ; preds = %14, %7
%11 = tail call i32 @putchar(i32 10)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, %6
br i1 %13, label %9, label %7
14: ; preds = %7, %14
%15 = phi i32 [ %20, %14 ], [ 0, %7 ]
%16 = shl nuw i32 1, %15
%17 = and i32 %16, %8
%18 = lshr i32 %17, %15
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i32 %15, 1
%21 = icmp eq i32 %20, %0
br i1 %21, label %10, label %14
}