#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *ipow(int, int const);
int /*<<< orphan*/ print_base(unsigned int, int const, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  unsigned int bits = 2;
  if (argc == 2) {
    int pbits = 0;
    pbits = atoi(argv[1]);
    if (pbits < 1) {
      fprintf(stderr, "Are you kidding me?\n");
      return 1;
    }
    bits = (unsigned int)pbits;
  } else if (argc > 2) {
    fprintf(stderr, "Too many arguments");
  }
  const int digits = ipow(2, bits);
  unsigned int c_wdontcare = ipow(3, digits);
  unsigned int c_wbinary = ipow(2, digits);
  unsigned int i;
  for (i = 0; i < c_wbinary; i++) {
    print_base(i, digits, 2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11b4 <main+0x74>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    11a9 <main+0x69>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1240 <main+0x100>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11d8 <main+0x98>
cmpl   $0x2,-0x8(%rbp)
jle    11d3 <main+0x93>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11d8 <main+0x98>
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1040 <ipow@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    $0x3,%edi
call   1040 <ipow@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    $0x2,%edi
call   1040 <ipow@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    1239 <main+0xf9>
mov    -0x28(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    $0x2,%edx
call   1060 <print_base@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120f <main+0xcf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1178 <main+0x38>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jg     1194 <main+0x54>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%r14d
jmp    11e6 <main+0xa6>
mov    $0x2,%ebx
jle    1194 <main+0x54>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x2,%edi
mov    %ebx,%esi
call   1040 <ipow@plt>
mov    %rax,%r15
mov    $0x3,%edi
mov    %r15d,%esi
call   1040 <ipow@plt>
mov    $0x2,%edi
mov    %r15d,%esi
call   1040 <ipow@plt>
mov    %rax,%rbp
xor    %r14d,%r14d
test   %ebp,%ebp
je     11e6 <main+0xa6>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x2,%edx
call   1060 <print_base@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    11d0 <main+0x90>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Are you kidding me?\0A\00"
@.str.1 = [19 x i8] c"Too many arguments\00"
define i32 @main(i32 %0, i8** %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
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2, i32* %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %26
14: ; preds = %2
store i32 0, i32* %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %55
24: ; preds = %14
%25 = load i32, i32* %7
store i32 %25, i32* %6
br label %33
26: ; preds = %2
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32, %24
%34 = load i32, i32* %6
%35 = call i8* @ipow(i32 2, i32 %34)
%36 = ptrtoint i8* %35 to i32
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = call i8* @ipow(i32 3, i32 %37)
%39 = ptrtoint i8* %38 to i32
store i32 %39, i32* %9
%40 = load i32, i32* %8
%41 = call i8* @ipow(i32 2, i32 %40)
%42 = ptrtoint i8* %41 to i32
store i32 %42, i32* %10
store i32 0, i32* %11
br label %43
43: ; preds = %51, %33
%44 = load i32, i32* %11
%45 = load i32, i32* %10
%46 = icmp ult i32 %44, %45
br i1 %46, label %47, label %54
47: ; preds = %43
%48 = load i32, i32* %11
%49 = load i32, i32* %8
%50 = call i32 @print_base(i32 %48, i32 %49, i32 2)
br label %51
51: ; preds = %47
%52 = load i32, i32* %11
%53 = add i32 %52, 1
store i32 %53, i32* %11
br label %43
54: ; preds = %43
store i32 0, i32* %3
br label %55
55: ; preds = %54, %21
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Are you kidding me?\0A\00"
@.str.1 = [19 x i8] c"Too many arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %32
12: ; preds = %2
%13 = icmp sgt i32 %0, 2
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %4, %12, %14
%18 = phi i32 [ 2, %14 ], [ 2, %12 ], [ %7, %4 ]
%19 = tail call i8* @ipow(i32 2, i32 %18)
%20 = ptrtoint i8* %19 to i64
%21 = trunc i64 %20 to i32
%22 = tail call i8* @ipow(i32 3, i32 %21)
%23 = tail call i8* @ipow(i32 2, i32 %21)
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %17, %27
%28 = phi i32 [ %30, %27 ], [ 0, %17 ]
%29 = tail call i32 @print_base(i32 %28, i32 %21, i32 2)
%30 = add nuw i32 %28, 1
%31 = icmp eq i32 %30, %25
br i1 %31, label %32, label %27
32: ; preds = %27, %17, %9
%33 = phi i32 [ 1, %9 ], [ 0, %17 ], [ 0, %27 ]
ret i32 %33
}