#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 */
typedef int /*<<< orphan*/ intValue;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void ICCalculateBits(int intValue) {
  printf("Number = %d\n", intValue);
  int arrayElements[sizeof(intValue) * 8];
  int i = 0;
  while (intValue != 0) {
    arrayElements[i] = intValue & 1;
    ++i;
    intValue = intValue >> 1;
  }
  for (int k = i - 1; k >= 0; --k) {
    printf("%d", arrayElements[k]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<ICCalculateBits>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1174 <ICCalculateBits+0x64>
mov    -0x4(%rbp),%ecx
and    $0x1,%ecx
movslq -0x94(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1139 <ICCalculateBits+0x29>
mov    -0x94(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0x98(%rbp)
jl     11c0 <ICCalculateBits+0xb0>
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x98(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x98(%rbp)
jmp    1183 <ICCalculateBits+0x73>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ICCalculateBits>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %edi,%ebx
lea    0xecd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     119a <ICCalculateBits+0x7a>
xor    %eax,%eax
mov    %ebx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edx
and    $0x1,%edx
mov    %edx,(%rsp,%rax,4)
add    $0x1,%rax
sar    %ecx
cmp    $0x2,%ebx
mov    %ecx,%ebx
jae    1150 <ICCalculateBits+0x30>
test   %eax,%eax
jle    119a <ICCalculateBits+0x7a>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0xe97(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    (%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1180 <ICCalculateBits+0x60>
mov    $0xa,%edi
add    $0x88,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [13 x i8] c"Number = %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define void @ICCalculateBits(i32 %0) {
%2 = alloca [32 x i32]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = bitcast [32 x i32]* %2 to i8*
%5 = icmp eq i32 %0, 0
br i1 %5, label %19, label %11
6: ; preds = %11
%7 = trunc i64 %16 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = and i64 %16, 4294967295
br label %21
11: ; preds = %1, %11
%12 = phi i64 [ %16, %11 ], [ 0, %1 ]
%13 = phi i32 [ %17, %11 ], [ %0, %1 ]
%14 = and i32 %13, 1
%15 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %12
store i32 %14, i32* %15
%16 = add nuw i64 %12, 1
%17 = ashr i32 %13, 1
%18 = icmp ult i32 %13, 2
br i1 %18, label %6, label %11
19: ; preds = %21, %1, %6
%20 = tail call i32 @putchar(i32 10)
ret void
21: ; preds = %9, %21
%22 = phi i64 [ %10, %9 ], [ %23, %21 ]
%23 = add nsw i64 %22, -1
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = icmp ugt i64 %22, 1
br i1 %28, label %21, label %19
}