#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 gray(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  if (argc > 2) {
    printf("Shit.");
    return 1;
  }
  char *end;
  int size = (int)strtol(argv[1], &end, 10);
  if (size > 32) {
    printf("More Shit.");
    return 1;
  }
  int num = 0;
  int tmp;
  while (num++ < (0x1 << size) - 1) {
    int x = gray(num);
    tmp = -1;
    char out[33];
    while (tmp++ < size) {
      out[size - tmp - 1] = (((x >> tmp) & 0x1) ? '1' : '0');
    }
    out[size] = '\0';
    printf("%s\n", out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    116a <main+0x3a>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0x11e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jle    11a7 <main+0x77>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0x11e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1247 <main+0x117>
mov    -0x20(%rbp),%edi
call   1040 <gray@plt>
mov    %eax,-0x28(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
cmp    -0x1c(%rbp),%eax
jge    1227 <main+0xf7>
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
sar    %cl,%edx
and    $0x1,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x1c(%rbp),%eax
sub    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x50(%rbp,%rax,1)
jmp    11e2 <main+0xb2>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rsi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ae <main+0x7e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
cmp    $0x3,%edi
jl     115f <main+0x1f>
lea    0xf28(%rip),%rdi
jmp    1184 <main+0x44>
mov    0x8(%rsi),%rdi
lea    0x80(%rsp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%rbx
cmp    $0x20,%ebx
jle    11a2 <main+0x62>
lea    0xefc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%r12d
mov    %ebx,%ecx
shl    %cl,%r12d
xor    %eax,%eax
cmp    $0xfffffffe,%r12d
jg     1190 <main+0x50>
movabs $0xfffffffe00000000,%r15
ff ff ff
mov    $0xfffffffe,%r8d
lea    (%rbx,%r8,1),%rax
mov    %rax,0x8(%rsp)
mov    %rbx,%rcx
shl    $0x20,%rcx
movslq %ebx,%rax
mov    %rax,0x40(%rsp)
lea    0x1(%rbx),%rbp
neg    %r12d
mov    %ebp,%r14d
lea    -0x1(%r14),%rdx
lea    -0x1(%rbx),%esi
mov    %esi,%edi
sub    %edx,%edi
cmp    %esi,%edi
setg   %al
shr    $0x20,%rdx
setne  %dl
or     %al,%dl
mov    %dl,0x7(%rsp)
mov    %rbp,0x38(%rsp)
and    $0xf,%ebp
mov    %r14,%rax
mov    %rbp,0x30(%rsp)
sub    %rbp,%rax
mov    %rax,0x10(%rsp)
add    $0xffffffffffffffff,%rax
mov    %rax,0x28(%rsp)
movabs $0xffffffff00000000,%rax
ff ff ff
add    %rcx,%rax
mov    %rax,0x20(%rsp)
lea    (%rbx,%r8,1),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,0x18(%rsp)
mov    $0x1,%ebp
movabs $0xfffffff000000000,%r13
ff ff ff
mov    %rbx,0x48(%rsp)
jmp    1285 <main+0x145>
nopw   0x0(%rax,%rax,1)
mov    0x40(%rsp),%rax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0x50(%rsp),%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
mov    0x48(%rsp),%rbx
je     1510 <main+0x3d0>
mov    %ebp,%edi
call   1050 <gray@plt>
test   %ebx,%ebx
js     1260 <main+0x120>
cmp    $0x10,%r14d
setb   %cl
or     0x7(%rsp),%cl
je     12b0 <main+0x170>
mov    $0xffffffffffffffff,%rdx
xor    %ecx,%ecx
jmp    147a <main+0x33a>
nopl   0x0(%rax,%rax,1)
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm8
mov    0x20(%rsp),%rcx
mov    0x10(%rsp),%rdx
movdqa 0xd63(%rip),%xmm9
movdqa 0xd4b(%rip),%xmm2
movdqa 0xd33(%rip),%xmm3
movdqa 0xd1b(%rip),%xmm4
movdqa 0xd52(%rip),%xmm10
movdqa 0xd59(%rip),%xmm11
pxor   %xmm12,%xmm12
movdqa 0xd5b(%rip),%xmm13
movdqa 0xd62(%rip),%xmm14
xchg   %ax,%ax
movdqa %xmm9,%xmm5
pslld  $0x17,%xmm5
paddd  %xmm10,%xmm5
cvttps2dq %xmm5,%xmm5
pshufd $0xf5,%xmm5,%xmm6
pmuludq %xmm11,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pmuludq %xmm11,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm5
movdqa %xmm2,%xmm6
pslld  $0x17,%xmm6
paddd  %xmm10,%xmm6
cvttps2dq %xmm6,%xmm6
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm11,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pmuludq %xmm11,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm6
movdqa %xmm3,%xmm7
pslld  $0x17,%xmm7
paddd  %xmm10,%xmm7
cvttps2dq %xmm7,%xmm7
pshufd $0xf5,%xmm7,%xmm0
pmuludq %xmm11,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm7
movdqa %xmm4,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm10,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm11,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
pand   %xmm8,%xmm0
pand   %xmm8,%xmm7
pand   %xmm8,%xmm6
pand   %xmm8,%xmm5
pcmpeqd %xmm12,%xmm5
pcmpeqd %xmm12,%xmm6
packssdw %xmm6,%xmm5
pcmpeqd %xmm12,%xmm7
pcmpeqd %xmm12,%xmm0
packssdw %xmm0,%xmm7
packsswb %xmm7,%xmm5
paddb  %xmm13,%xmm5
mov    %rcx,%rsi
sar    $0x20,%rsi
movdqa %xmm5,%xmm0
punpcklbw %xmm12,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
punpckhbw %xmm12,%xmm5
pshufd $0x4e,%xmm5,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm0,%xmm1
movdqu %xmm1,0x41(%rsp,%rsi,1)
paddd  %xmm14,%xmm9
paddd  %xmm14,%xmm2
paddd  %xmm14,%xmm3
paddd  %xmm14,%xmm4
add    %r13,%rcx
add    $0xfffffffffffffff0,%rdx
jne    1310 <main+0x1d0>
mov    0x28(%rsp),%rdx
mov    0x10(%rsp),%rcx
cmpq   $0x0,0x30(%rsp)
je     1260 <main+0x120>
mov    0x38(%rsp),%rdi
sub    %ecx,%edi
lea    0x1(%rcx),%rsi
test   $0x1,%dil
je     14a8 <main+0x368>
bt     %ecx,%eax
mov    $0x31,%cl
adc    $0xff,%cl
mov    0x8(%rsp),%rdi
sub    %edx,%edi
add    $0x1,%rdx
movslq %edi,%rdi
mov    %cl,0x50(%rsp,%rdi,1)
mov    %rsi,%rcx
cmp    %rsi,%r14
je     1260 <main+0x120>
mov    0x18(%rsp),%rsi
sub    %edx,%esi
shl    $0x20,%rsi
mov    0x8(%rsp),%rbx
sub    %edx,%ebx
shl    $0x20,%rbx
nopw   0x0(%rax,%rax,1)
bt     %ecx,%eax
mov    $0x31,%dl
adc    $0xff,%dl
mov    %rbx,%rdi
sar    $0x20,%rdi
mov    %dl,0x50(%rsp,%rdi,1)
lea    0x1(%rcx),%edx
movzbl %dl,%edx
bt     %edx,%eax
mov    $0x31,%dl
adc    $0xff,%dl
mov    %rsi,%rdi
sar    $0x20,%rdi
mov    %dl,0x50(%rsp,%rdi,1)
add    $0x2,%rcx
add    %r15,%rsi
add    %r15,%rbx
cmp    %rcx,%r14
jne    14d0 <main+0x390>
jmp    1260 <main+0x120>
xor    %eax,%eax
jmp    1190 <main+0x50>

LLVM IR (-O0):
@.str = [6 x i8] c"Shit.\00"
@.str.1 = [11 x i8] c"More Shit.\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [33 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %64
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strtol(i8* %19, i8** %6, i32 10)
%21 = trunc i64 %20 to i32
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 32
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %64
26: ; preds = %16
store i32 0, i32* %8
br label %27
27: ; preds = %57, %26
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
%30 = load i32, i32* %7
%31 = shl i32 1, %30
%32 = sub nsw i32 %31, 1
%33 = icmp slt i32 %28, %32
br i1 %33, label %34, label %63
34: ; preds = %27
%35 = load i32, i32* %8
%36 = call i32 @gray(i32 %35)
store i32 %36, i32* %10
store i32 -1, i32* %9
br label %37
37: ; preds = %42, %34
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
%40 = load i32, i32* %7
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %57
42: ; preds = %37
%43 = load i32, i32* %10
%44 = load i32, i32* %9
%45 = ashr i32 %43, %44
%46 = and i32 %45, 1
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 49, i32 48
%50 = trunc i32 %49 to i8
%51 = load i32, i32* %7
%52 = load i32, i32* %9
%53 = sub nsw i32 %51, %52
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [33 x i8], [33 x i8]* %11, i64 0, i64 %55
store i8 %50, i8* %56
br label %37
57: ; preds = %37
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [33 x i8], [33 x i8]* %11, i64 0, i64 %59
store i8 0, i8* %60
%61 = getelementptr inbounds [33 x i8], [33 x i8]* %11, i64 0, i64 0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %61)
br label %27
63: ; preds = %27
store i32 0, i32* %3
br label %64
64: ; preds = %63, %24, %14
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [6 x i8] c"Shit.\00"
@.str.1 = [11 x i8] c"More Shit.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [33 x i8]
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %124
8: ; preds = %2
%9 = bitcast i8** %3 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strtol(i8* %11, i8** %3, i32 10)
%13 = trunc i64 %12 to i32
%14 = icmp sgt i32 %13, 32
br i1 %14, label %40, label %15
15: ; preds = %8
%16 = shl nsw i32 -1, %13
%17 = icmp slt i32 %16, -1
br i1 %17, label %18, label %122
18: ; preds = %15
%19 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%20 = icmp sgt i32 %13, -1
%21 = add i64 %12, 4294967294
%22 = shl i64 %12, 32
%23 = ashr exact i64 %22, 32
%24 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 %23
%25 = add i64 %12, 1
%26 = sub i32 0, %16
%27 = and i64 %25, 4294967295
%28 = add nsw i64 %27, -1
%29 = add i32 %13, -1
%30 = icmp ult i64 %27, 16
%31 = trunc i64 %28 to i32
%32 = sub i32 %29, %31
%33 = icmp sgt i32 %32, %29
%34 = icmp ugt i64 %28, 4294967295
%35 = or i1 %33, %34
%36 = and i64 %25, 15
%37 = sub nsw i64 %27, %36
%38 = add nsw i64 %37, -1
%39 = icmp eq i64 %36, 0
br label %42
40: ; preds = %8
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %122
42: ; preds = %18, %118
%43 = phi i32 [ 1, %18 ], [ %120, %118 ]
%44 = tail call i32 @gray(i32 %43)
br i1 %20, label %45, label %118
45: ; preds = %42
%46 = select i1 %30, i1 true, i1 %35
br i1 %46, label %69, label %47
47: ; preds = %45
%48 = insertelement <16 x i32> poison, i32 %44, i64 0
%49 = shufflevector <16 x i32> %48, <16 x i32> poison, <16 x i32> zeroinitializer
br label %50
50: ; preds = %50, %47
%51 = phi i64 [ 0, %47 ], [ %65, %50 ]
%52 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %47 ], [ %66, %50 ]
%53 = add i64 %51, 4294967295
%54 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %52
%55 = and <16 x i32> %54, %49
%56 = icmp eq <16 x i32> %55, zeroinitializer
%57 = select <16 x i1> %56, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%58 = sub i64 %21, %53
%59 = shl i64 %58, 32
%60 = ashr exact i64 %59, 32
%61 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 %60
%62 = shufflevector <16 x i8> %57, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%63 = getelementptr inbounds i8, i8* %61, i64 -15
%64 = bitcast i8* %63 to <16 x i8>*
store <16 x i8> %62, <16 x i8>* %64
%65 = add nuw i64 %51, 16
%66 = add <16 x i32> %52, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%67 = icmp eq i64 %65, %37
br i1 %67, label %68, label %50
68: ; preds = %50
br i1 %39, label %118, label %69
69: ; preds = %45, %68
%70 = phi i64 [ -1, %45 ], [ %38, %68 ]
%71 = phi i64 [ 0, %45 ], [ %37, %68 ]
%72 = sub i64 %25, %71
%73 = add nsw i64 %71, 1
%74 = and i64 %72, 1
%75 = icmp eq i64 %74, 0
br i1 %75, label %88, label %76
76: ; preds = %69
%77 = add nsw i64 %70, 1
%78 = trunc i64 %71 to i32
%79 = shl nuw i32 1, %78
%80 = and i32 %79, %44
%81 = icmp eq i32 %80, 0
%82 = select i1 %81, i8 48, i8 49
%83 = sub i64 %21, %70
%84 = shl i64 %83, 32
%85 = ashr exact i64 %84, 32
%86 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 %85
store i8 %82, i8* %86
%87 = add nuw nsw i64 %71, 1
br label %88
88: ; preds = %76, %69
%89 = phi i64 [ %70, %69 ], [ %77, %76 ]
%90 = phi i64 [ %71, %69 ], [ %87, %76 ]
%91 = icmp eq i64 %27, %73
br i1 %91, label %118, label %92
92: ; preds = %88, %92
%93 = phi i64 [ %105, %92 ], [ %89, %88 ]
%94 = phi i64 [ %116, %92 ], [ %90, %88 ]
%95 = xor i64 %93, -1
%96 = trunc i64 %94 to i32
%97 = shl nuw i32 1, %96
%98 = and i32 %97, %44
%99 = icmp eq i32 %98, 0
%100 = select i1 %99, i8 48, i8 49
%101 = sub i64 %21, %93
%102 = shl i64 %101, 32
%103 = ashr exact i64 %102, 32
%104 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 %103
store i8 %100, i8* %104
%105 = add nsw i64 %93, 2
%106 = trunc i64 %94 to i32
%107 = add i32 %106, 1
%108 = shl nuw i32 1, %107
%109 = and i32 %108, %44
%110 = icmp eq i32 %109, 0
%111 = select i1 %110, i8 48, i8 49
%112 = add i64 %21, %95
%113 = shl i64 %112, 32
%114 = ashr exact i64 %113, 32
%115 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 %114
store i8 %111, i8* %115
%116 = add nuw nsw i64 %94, 2
%117 = icmp eq i64 %116, %27
br i1 %117, label %118, label %92
118: ; preds = %88, %92, %68, %42
store i8 0, i8* %24
%119 = call i32 @puts(i8* %19)
%120 = add nuw i32 %43, 1
%121 = icmp eq i32 %120, %26
br i1 %121, label %122, label %42
122: ; preds = %118, %15, %40
%123 = phi i32 [ 1, %40 ], [ 0, %15 ], [ 0, %118 ]
br label %124
124: ; preds = %122, %6
%125 = phi i32 [ 1, %6 ], [ %123, %122 ]
ret i32 %125
}