#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 unsigned int uint32_t;
typedef int /*<<< orphan*/ n;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void print32bits(uint32_t n) {
  unsigned int i;
  i = 1 << (sizeof(n) * 8 - 1);
  while (i > 0) {
    if (n & i)
      fprintf(stderr, "1");
    else
      fprintf(stderr, "0");
    i >>= 1;
  }
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<print32bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x80000000,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jbe    1178 <print32bits+0x68>
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
cmp    $0x0,%eax
je     1155 <print32bits+0x45>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1030 <fprintf@plt>
jmp    116a <print32bits+0x5a>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <print32bits+0x12>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print32bits>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r13d
mov    $0x80000000,%ebx
mov    0x2eb6(%rip),%r14
lea    0xed1(%rip),%r15
lea    0xec8(%rip),%r12
mov    $0x80000000,%ebp
nopl   (%rax)
test   %r13d,%ebx
mov    (%r14),%edi
mov    %r12,%rsi
cmove  %r15,%rsi
call   1030 <fprintf@plt>
shr    %ebp
cmp    $0x1,%ebx
mov    %ebp,%ebx
ja     1140 <print32bits+0x30>
mov    (%r14),%edi
lea    0xe9f(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print32bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 -2147483648, i32* %3
br label %4
4: ; preds = %18, %1
%5 = load i32, i32* %3
%6 = icmp ugt i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = and i32 %8, %9
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
15: ; preds = %7
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %3
%20 = lshr i32 %19, 1
store i32 %20, i32* %3
br label %4
21: ; preds = %4
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print32bits(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ -2147483648, %1 ], [ %9, %2 ]
%4 = and i32 %3, %0
%5 = icmp eq i32 %4, 0
%6 = load i32, i32* @stderr
%7 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%8 = tail call i32 @fprintf(i32 %6, i8* %7)
%9 = lshr i32 %3, 1
%10 = icmp ult i32 %3, 2
br i1 %10, label %11, label %2
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}