#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*/ free(unsigned int *);
unsigned int *hamming(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void testHamming() {
  unsigned n = 42;
  unsigned *seq = hamming(n);
  for (unsigned i = 0; i < n; i++)
    printf("%d ", seq[i]);
  printf("\n");
  free(seq);
}


x86 assembly (clang, -O0):
<testHamming>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x2a,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <hamming@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1184 <testHamming+0x54>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <testHamming+0x22>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testHamming>:
push   %r15
push   %r14
push   %rbx
mov    $0x2a,%edi
call   1060 <hamming@plt>
mov    %rax,%r15
lea    0xea7(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x2a,%rbx
jne    1160 <testHamming+0x20>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @testHamming() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 42, i32* %1
%4 = load i32, i32* %1
%5 = call i32* @hamming(i32 %4)
store i32* %5, i32** %2
store i32 0, i32* %3
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %1
%9 = icmp ult i32 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %3
%19 = add i32 %18, 1
store i32 %19, i32* %3
br label %6
20: ; preds = %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32*, i32** %2
%23 = call i32 @free(i32* %22)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @testHamming() {
%1 = tail call i32* @hamming(i32 42)
br label %5
2: ; preds = %5
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @free(i32* %1)
ret void
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %10, %5 ]
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = load i32, i32* %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, 42
br i1 %11, label %2, label %5
}