#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 uint32_t;
typedef int /*<<< orphan*/ numbers;
typedef int /*<<< orphan*/ d;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ printBits(int, int *);
int /*<<< orphan*/ printf(char *);
int main() {
  int i;
  uint32_t a = 0;
  uint32_t d = 0;
  const uint32_t magic = 0x7EFEFEFF;
  const uint32_t magicRev = magic ^ 0xFFFFFFFF;
  const uint32_t numbers[] = {0x00000000, 0x00000001, 0x34003231, 0x34323331,
                              0x01010101};
  for (i = 0; i != sizeof(numbers) / sizeof(numbers[0]); i++) {
    a = numbers[i];
    d = magic;
    printf("a:            ");
    printBits(sizeof(a), &a);
    printf("\n");
    d = a + d;
    printf("a+magic:      ");
    printBits(sizeof(d), &d);
    printf("\n");
    a = a ^ 0xFFFFFFFF;
    printf("!a:           ");
    printBits(sizeof(a), &a);
    printf("\n");
    a = a ^ d;
    printf("result:       ");
    printBits(sizeof(a), &a);
    printf("\n");
    a = a & magicRev;
    printf("              ");
    printBits(sizeof(a), &a);
    if (a == 0) {
      printf(" (zero)\n");
    } else {
      printf(" (at least one)\n");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x7efefeff,-0x14(%rbp)
movl   $0x81010100,-0x18(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea9(%rip),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    $0x5,%rax
je     12aa <main+0x18a>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
movl   $0x7efefeff,-0x10(%rbp)
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
lea    -0xc(%rbp),%rsi
call   1030 <printBits@plt>
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
lea    -0x10(%rbp),%rsi
call   1030 <printBits@plt>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
lea    -0xc(%rbp),%rsi
call   1030 <printBits@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
xor    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
lea    -0xc(%rbp),%rsi
call   1030 <printBits@plt>
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x81010100,%eax
mov    %eax,-0xc(%rbp)
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
mov    $0x4,%edi
lea    -0xc(%rbp),%rsi
call   1030 <printBits@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1284 <main+0x164>
lea    0xde5(%rip),%rdi
call   1040 <printf@plt>
jmp    1290 <main+0x170>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x51>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
mov    %rsp,%rbx
lea    0xee9(%rip),%rbp
lea    0xef1(%rip),%r14
lea    0xf09(%rip),%r12
lea    0xef2(%rip),%r13
nopl   (%rax)
lea    0xe89(%rip),%rax
mov    (%r15,%rax,1),%eax
mov    %eax,(%rsp)
movl   $0x7efefeff,0x4(%rsp)
7e
lea    0xe87(%rip),%rdi
call   1060 <printf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1050 <printBits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
add    %eax,0x4(%rsp)
lea    0xe6c(%rip),%rdi
call   1060 <printf@plt>
mov    $0x4,%edi
lea    0x4(%rsp),%rsi
call   1050 <printBits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
notl   (%rsp)
lea    0xe53(%rip),%rdi
call   1060 <printf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1050 <printBits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
xor    %eax,(%rsp)
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1050 <printBits@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
andl   $0x81010100,(%rsp)
mov    %r14,%rdi
call   1060 <printf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1050 <printBits@plt>
cmpl   $0x0,(%rsp)
mov    %r13,%rdi
cmove  %r12,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x4,%r15
cmp    $0x14,%r15
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.numbers = [5 x i32] [i32 0, i32 1, i32 872428081, i32 875705137, i32 16843009]
@.str = [15 x i8] c"a: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [15 x i8] c"a+magic: \00"
@.str.3 = [15 x i8] c"!a: \00"
@.str.4 = [15 x i8] c"result: \00"
@.str.5 = [15 x i8] c" \00"
@.str.6 = [9 x i8] c" (zero)\0A\00"
@.str.7 = [17 x i8] c" (at least one)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [5 x i32]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 2130640639, i32* %5
store i32 -2130640640, i32* %6
%8 = bitcast [5 x i32]* %7 to i8*
store i32 0, i32* %2
br label %9
9: ; preds = %50, %0
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = icmp ne i64 %11, 5
br i1 %12, label %13, label %53
13: ; preds = %9
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 %15
%17 = load i32, i32* %16
store i32 %17, i32* %3
store i32 2130640639, i32* %4
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @printBits(i32 4, i32* %3)
%20 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = add nsw i32 %21, %22
store i32 %23, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @printBits(i32 4, i32* %4)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = xor i32 %27, -1
store i32 %28, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @printBits(i32 4, i32* %3)
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = xor i32 %32, %33
store i32 %34, i32* %3
%35 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 @printBits(i32 4, i32* %3)
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = and i32 %38, -2130640640
store i32 %39, i32* %3
%40 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @printBits(i32 4, i32* %3)
%42 = load i32, i32* %3
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %13
%45 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %48
46: ; preds = %13
%47 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
%49 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %9
53: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.numbers = [5 x i32] [i32 0, i32 1, i32 872428081, i32 875705137, i32 16843009]
@.str = [15 x i8] c"a: \00"
@.str.2 = [15 x i8] c"a+magic: \00"
@.str.3 = [15 x i8] c"!a: \00"
@.str.4 = [15 x i8] c"result: \00"
@.str.5 = [15 x i8] c" \00"
@str = [16 x i8] c" (at least one)\00"
@str.8 = [8 x i8] c" (zero)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %38, %5 ]
%7 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.numbers, i64 0, i64 %6
%8 = load i32, i32* %7
store i32 %8, i32* %1
store i32 2130640639, i32* %2
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printBits(i32 4, i32* %1)
%11 = call i32 @putchar(i32 10)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = add nsw i32 %13, %12
store i32 %14, i32* %2
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @printBits(i32 4, i32* %2)
%17 = call i32 @putchar(i32 10)
%18 = load i32, i32* %1
%19 = xor i32 %18, -1
store i32 %19, i32* %1
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @printBits(i32 4, i32* %1)
%22 = call i32 @putchar(i32 10)
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = xor i32 %24, %23
store i32 %25, i32* %1
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @printBits(i32 4, i32* %1)
%28 = call i32 @putchar(i32 10)
%29 = load i32, i32* %1
%30 = and i32 %29, -2130640640
store i32 %30, i32* %1
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 @printBits(i32 4, i32* %1)
%33 = load i32, i32* %1
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0)
%36 = call i32 @puts(i8* dereferenceable(1) %35)
%37 = call i32 @putchar(i32 10)
%38 = add nuw nsw i64 %6, 1
%39 = icmp eq i64 %38, 5
br i1 %39, label %40, label %5
40: ; preds = %5
ret i32 0
}