#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*/ getchar();
int /*<<< orphan*/ printf(char *, unsigned short, int, int);
int main(void) {
  int twos[] = {1,   2,   4,    8,    16,   32,   64,    128,
                256, 512, 1024, 2048, 4096, 8192, 16384, 32768};
  int x, r, tus = 1;
  unsigned short int v = 0;
  for (x = 0; x < 16; x++) {
    r = v | tus;
    printf("0x%04X | %5d = 0x%04X\n", v, tus, r);
    tus <<= 1;
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
movl   $0x1,-0x5c(%rbp)
movw   $0x0,-0x5e(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    11ac <main+0x7c>
movzwl -0x5e(%rbp),%eax
or     -0x5c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x5e(%rbp),%ax
mov    -0x5c(%rbp),%edx
mov    -0x58(%rbp),%ecx
lea    0xeb3(%rip),%rdi
movzwl %ax,%esi
call   1030 <printf@plt>
mov    -0x5c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1168 <main+0x38>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
mov    $0x4,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
mov    $0x8,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
mov    $0x10,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
mov    $0x20,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
mov    $0x40,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
mov    $0x80,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
mov    $0x100,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x200,%edx
mov    $0x200,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
mov    $0x400,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x800,%edx
mov    $0x800,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
mov    $0x1000,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2000,%edx
mov    $0x2000,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4000,%edx
mov    $0x4000,%ecx
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8000,%edx
mov    $0x8000,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.twos = [16 x i32] [i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 256, i32 512, i32 1024, i32 2048, i32 4096, i32 8192, i32 16384, i32 32768]
@.str = [23 x i8] c"0x%04X | %5d = 0x%04X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i16
store i32 0, i32* %1
%7 = bitcast [16 x i32]* %2 to i8*
store i32 1, i32* %5
store i16 0, i16* %6
store i32 0, i32* %3
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i16, i16* %6
%13 = zext i16 %12 to i32
%14 = load i32, i32* %5
%15 = or i32 %13, %14
store i32 %15, i32* %4
%16 = load i16, i16* %6
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext %16, i32 %17, i32 %18)
%20 = load i32, i32* %5
%21 = shl i32 %20, 1
store i32 %21, i32* %5
br label %22
22: ; preds = %11
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %8
25: ; preds = %8
%26 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"0x%04X | %5d = 0x%04X\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 1, i32 1)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 2, i32 2)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 4, i32 4)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 8, i32 8)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 16, i32 16)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 32, i32 32)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 64, i32 64)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 128, i32 128)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 256, i32 256)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 512, i32 512)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 1024, i32 1024)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 2048, i32 2048)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 4096, i32 4096)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 8192, i32 8192)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 16384, i32 16384)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i16 zeroext 0, i32 32768, i32 32768)
%17 = tail call i32 (...) @getchar()
ret i32 0
}