#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 getbits(int, int, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
main() {
  int n, x, n2, x2, x3;
  n = 0200;
  x = 0200;
  printf("n=%o, %X, %d\n", n, n, n);
  printf("x=%o, %X, %d\n\n", x, x, x);
  n2 = n & 0177;
  x2 = x | 0177;
  printf("n2=%o, %X, %d\n", n2, n2, n2);
  printf("x2=%o, %X, %d\n\n", x2, x2, x2);
  x3 = n ^ x;
  printf("x3=%o, %X, %d\n\n", x3, x3, x3);
  n2 = n << 2;
  x2 = n >> 2;
  printf("n2=%o, %X, %d\n", n2, n2, n2);
  printf("x2=%o, %X, %d\n\n", x2, x2, x2);
  x2 = ~n;
  printf("x2=%o, %X, %d\n", x2, x2, x2);
  n2 = getbits(x2, 4, 3);
  printf("n2=%o, %X, %d\n", n2, n2, n2);
  printf("\nPress any key to end...");
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x80,-0x4(%rbp)
movl   $0x80,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
or     $0x7f,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edi
mov    $0x4,%esi
mov    $0x3,%edx
call   1040 <getbits@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
mov    $0x80,%esi
mov    $0x80,%edx
mov    $0x80,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x80,%esi
mov    $0x80,%edx
mov    $0x80,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea8(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0xff,%edx
mov    $0xff,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x200,%esi
mov    $0x200,%edx
mov    $0x200,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x20,%edx
mov    $0x20,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
mov    $0xffffff7f,%esi
mov    $0xffffff7f,%edx
mov    $0xffffff7f,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffff7f,%edi
mov    $0x4,%esi
mov    $0x3,%edx
call   1040 <getbits@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"n=%o, %X, %d\0A\00"
@.str.1 = [15 x i8] c"x=%o, %X, %d\0A\0A\00"
@.str.2 = [15 x i8] c"n2=%o, %X, %d\0A\00"
@.str.3 = [16 x i8] c"x2=%o, %X, %d\0A\0A\00"
@.str.4 = [16 x i8] c"x3=%o, %X, %d\0A\0A\00"
@.str.5 = [15 x i8] c"x2=%o, %X, %d\0A\00"
@.str.6 = [25 x i8] c"\0APress any key to end...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 128, i32* %1
store i32 128, i32* %2
%6 = load i32, i32* %1
%7 = load i32, i32* %1
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7, i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
%14 = load i32, i32* %1
%15 = and i32 %14, 127
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = or i32 %16, 127
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* %4
%23 = load i32, i32* %4
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = xor i32 %26, %27
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = load i32, i32* %5
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
%33 = load i32, i32* %1
%34 = shl i32 %33, 2
store i32 %34, i32* %3
%35 = load i32, i32* %1
%36 = ashr i32 %35, 2
store i32 %36, i32* %4
%37 = load i32, i32* %3
%38 = load i32, i32* %3
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* %4
%42 = load i32, i32* %4
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
%45 = load i32, i32* %1
%46 = xor i32 %45, -1
store i32 %46, i32* %4
%47 = load i32, i32* %4
%48 = load i32, i32* %4
%49 = load i32, i32* %4
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %4
%52 = call i32 @getbits(i32 %51, i32 4, i32 3)
store i32 %52, i32* %3
%53 = load i32, i32* %3
%54 = load i32, i32* %3
%55 = load i32, i32* %3
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %53, i32 %54, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%58 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"n=%o, %X, %d\0A\00"
@.str.1 = [15 x i8] c"x=%o, %X, %d\0A\0A\00"
@.str.2 = [15 x i8] c"n2=%o, %X, %d\0A\00"
@.str.3 = [16 x i8] c"x2=%o, %X, %d\0A\0A\00"
@.str.4 = [16 x i8] c"x3=%o, %X, %d\0A\0A\00"
@.str.5 = [15 x i8] c"x2=%o, %X, %d\0A\00"
@.str.6 = [25 x i8] c"\0APress any key to end...\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 128, i32 128, i32 128)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 128, i32 128, i32 128)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 0)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 255, i32 255, i32 255)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 0, i32 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 512, i32 512, i32 512)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 32, i32 32, i32 32)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 -129, i32 -129, i32 -129)
%9 = tail call i32 @getbits(i32 -129, i32 4, i32 3)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %9, i32 %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%12 = tail call i32 (...) @getchar()
ret i32 0
}