#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*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
scalar_t__ scanf(char *, int *);
void main() {
  int n, s;
  short p, i, f;
  while (scanf("%d", &n) && n) {
    f = 0;
    s = 1073741824;
    printf("The parity of ");
    p = 0;
    for (i = 0; i < 31; i++) {
      if (s & n) {
        f = 1;
        putchar('1');
        p++;
      } else if (f)
        putchar('0');
      s >>= 1;
    }
    printf(" is %hd (mod 2).\n", p);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xf(%rbp)
je     1164 <main+0x34>
cmpl   $0x0,-0x4(%rbp)
setne  %al
mov    %al,-0xf(%rbp)
mov    -0xf(%rbp),%al
test   $0x1,%al
jne    1174 <main+0x44>
jmp    1223 <main+0xf3>
movw   $0x0,-0xe(%rbp)
movl   $0x40000000,-0x8(%rbp)
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movw   $0x0,-0xa(%rbp)
movw   $0x0,-0xc(%rbp)
movswl -0xc(%rbp),%eax
cmp    $0x1f,%eax
jge    120c <main+0xdc>
mov    -0x8(%rbp),%eax
and    -0x4(%rbp),%eax
cmp    $0x0,%eax
je     11d8 <main+0xa8>
movw   $0x1,-0xe(%rbp)
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    -0xa(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa(%rbp)
jmp    11f2 <main+0xc2>
cmpw   $0x0,-0xe(%rbp)
je     11ed <main+0xbd>
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    11f2 <main+0xc2>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xc(%rbp)
jmp    119b <main+0x6b>
movswl -0xa(%rbp),%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1138 <main+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11fd <main+0xcd>
cmpl   $0x0,0x4(%rsp)
je     11fd <main+0xcd>
lea    0xe99(%rip),%r12
lea    0x4(%rsp),%r13
nopl   0x0(%rax)
xor    %r15d,%r15d
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x40000000,%ebp
mov    $0x1f,%bx
xor    %r14d,%r14d
jmp    11ab <main+0x7b>
nop
mov    $0x31,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
mov    $0x1,%r15w
shr    %ebp
add    $0xffff,%bx
je     11d0 <main+0xa0>
test   %ebp,0x4(%rsp)
jne    1190 <main+0x60>
test   %r15w,%r15w
je     11c3 <main+0x93>
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    119e <main+0x6e>
xor    %r15d,%r15d
jmp    11a3 <main+0x73>
nopl   0x0(%rax,%rax,1)
movswl %r14w,%esi
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11fd <main+0xcd>
cmpl   $0x0,0x4(%rsp)
jne    1170 <main+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [15 x i8] c"The parity of \00"
@.str.2 = [18 x i8] c" is %hd (mod 2).\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
br label %6
6: ; preds = %41, %0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %1
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ false, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %45
14: ; preds = %12
store i16 0, i16* %5
store i32 1073741824, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i16 0, i16* %3
store i16 0, i16* %4
br label %16
16: ; preds = %38, %14
%17 = load i16, i16* %4
%18 = sext i16 %17 to i32
%19 = icmp slt i32 %18, 31
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load i32, i32* %2
%22 = load i32, i32* %1
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
store i16 1, i16* %5
%26 = call i32 @putchar(i8 signext 49)
%27 = load i16, i16* %3
%28 = add i16 %27, 1
store i16 %28, i16* %3
br label %35
29: ; preds = %20
%30 = load i16, i16* %5
%31 = icmp ne i16 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @putchar(i8 signext 48)
br label %34
34: ; preds = %32, %29
br label %35
35: ; preds = %34, %25
%36 = load i32, i32* %2
%37 = ashr i32 %36, 1
store i32 %37, i32* %2
br label %38
38: ; preds = %35
%39 = load i16, i16* %4
%40 = add i16 %39, 1
store i16 %40, i16* %4
br label %16
41: ; preds = %16
%42 = load i16, i16* %3
%43 = sext i16 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %6
45: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [15 x i8] c"The parity of \00"
@.str.2 = [18 x i8] c" is %hd (mod 2).\0A\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp ne i64 %3, 0
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %39
8: ; preds = %0, %31
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %25
%11 = phi i16 [ 0, %8 ], [ %27, %25 ]
%12 = phi i16 [ 0, %8 ], [ %29, %25 ]
%13 = phi i16 [ 0, %8 ], [ %26, %25 ]
%14 = phi i32 [ 1073741824, %8 ], [ %28, %25 ]
%15 = load i32, i32* %1
%16 = and i32 %15, %14
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %10
%19 = call i32 @putchar(i8 signext 49)
%20 = add i16 %13, 1
br label %25
21: ; preds = %10
%22 = icmp eq i16 %11, 0
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = call i32 @putchar(i8 signext 48)
br label %25
25: ; preds = %21, %23, %18
%26 = phi i16 [ %20, %18 ], [ %13, %23 ], [ %13, %21 ]
%27 = phi i16 [ 1, %18 ], [ 1, %23 ], [ 0, %21 ]
%28 = lshr i32 %14, 1
%29 = add nuw nsw i16 %12, 1
%30 = icmp eq i16 %29, 31
br i1 %30, label %31, label %10
31: ; preds = %25
%32 = sext i16 %26 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%35 = icmp ne i64 %34, 0
%36 = load i32, i32* %1
%37 = icmp ne i32 %36, 0
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %8, label %39
39: ; preds = %31, %0
ret void
}