#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 pow(int, int);
int /*<<< orphan*/ printElement(int);
int /*<<< orphan*/ printf(char *);
int main() {
  int n = 5;
  int twoPowerOfN = pow(2, n);
  int i, j;
  for (i = 0; i < twoPowerOfN; i++) {
    printf("\n{");
    for (j = 0; j < n; j++) {
      int mask = 1 << j;
      int value = i & mask;
      if (value != 0)
        printElement(value);
    }
    printf("}");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dd <main+0xad>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c3 <main+0x93>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b0 <main+0x80>
mov    -0x1c(%rbp),%edi
call   1040 <printElement@plt>
jmp    11b5 <main+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <main+0x4c>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <main+0x2d>
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x2,%edi
mov    $0x5,%esi
call   1060 <pow@plt>
test   %eax,%eax
jle    11c7 <main+0x87>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0xe9e(%rip),%r14
jmp    1181 <main+0x41>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x7d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
je     11c7 <main+0x87>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %ebp,%edi
and    $0x1,%edi
je     1195 <main+0x55>
call   1050 <printElement@plt>
mov    %ebp,%edi
and    $0x2,%edi
je     11a1 <main+0x61>
call   1050 <printElement@plt>
mov    %ebp,%edi
and    $0x4,%edi
je     11ad <main+0x6d>
call   1050 <printElement@plt>
mov    %ebp,%edi
and    $0x8,%edi
je     11b9 <main+0x79>
call   1050 <printElement@plt>
mov    %ebp,%edi
and    $0x10,%edi
je     1170 <main+0x30>
call   1050 <printElement@plt>
jmp    1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\0A{\00"
define i32 @main() {
%1 = tail call i32 @pow(i32 2, i32 5)
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %34
3: ; preds = %0, %30
%4 = phi i32 [ %32, %30 ], [ 0, %0 ]
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = and i32 %4, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @printElement(i32 %6)
br label %10
10: ; preds = %8, %3
%11 = and i32 %4, 2
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @printElement(i32 %11)
br label %15
15: ; preds = %13, %10
%16 = and i32 %4, 4
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @printElement(i32 %16)
br label %20
20: ; preds = %18, %15
%21 = and i32 %4, 8
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = tail call i32 @printElement(i32 %21)
br label %25
25: ; preds = %23, %20
%26 = and i32 %4, 16
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call i32 @printElement(i32 %26)
br label %30
30: ; preds = %28, %25
%31 = tail call i32 @putchar(i32 125)
%32 = add nuw nsw i32 %4, 1
%33 = icmp eq i32 %32, %1
br i1 %33, label %34, label %3
34: ; preds = %30, %0
%35 = tail call i32 @putchar(i32 10)
ret i32 0
}