#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 */
scalar_t__ bit_value(unsigned char, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  unsigned long int max = ~0;
  unsigned char buffer1[] = {0, 0, 0, 255};
  unsigned char buffer2[] = {255, 0, 0, 0};
  unsigned char buffer3[] = {0, 0, 0, 255};
  unsigned char buffer4[] = {255, 0, 0, 0};
  printf("Max %lu\n", max);
  printf("Buffer1 BE %lu\n",
         (((unsigned long int)buffer1[0]) * 256 * 256 * 256) +
             (((unsigned long int)buffer1[1]) * 256 * 256) +
             (((unsigned long int)buffer1[2]) * 256) +
             ((unsigned long int)buffer1[3]));
  printf("Buffer2 BE %lu\n", ((unsigned long int)buffer2[0] << 24) |
                                 ((unsigned long int)buffer2[1] << 16) |
                                 ((unsigned long int)buffer2[2] << 8) |
                                 buffer2[3]);
  printf("Buffer3 LE %lu\n",
         ((unsigned long int)buffer3[0]) +
             (((unsigned long int)buffer3[1]) * 256) +
             (((unsigned long int)buffer3[2]) * 256 * 256) +
             (((unsigned long int)buffer3[3]) * 256 * 256 * 256));
  printf("Buffer4 LE %lu\n", ((unsigned long int)buffer4[0]) |
                                 ((unsigned long int)buffer4[1] << 8) |
                                 ((unsigned long int)buffer4[2] << 16) |
                                 ((unsigned long int)buffer4[3] << 24));
  printf("Buffer4[0] Bit Values %i %i %i %i %i %i %i %i\n",
         (int)bit_value(buffer4[0], 7), (int)bit_value(buffer4[0], 6),
         (int)bit_value(buffer4[0], 5), (int)bit_value(buffer4[0], 4),
         (int)bit_value(buffer4[0], 3), (int)bit_value(buffer4[0], 2),
         (int)bit_value(buffer4[0], 1), (int)bit_value(buffer4[0], 0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
mov    0xec3(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    0xebe(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xeb1(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x14(%rbp),%eax
shl    $0x8,%rax
shl    $0x8,%rax
shl    $0x8,%rax
movzbl -0x13(%rbp),%ecx
shl    $0x8,%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movzbl -0x12(%rbp),%ecx
shl    $0x8,%rcx
add    %rcx,%rax
movzbl -0x11(%rbp),%ecx
add    %rcx,%rax
mov    %eax,%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x18(%rbp),%eax
shl    $0x18,%rax
movzbl -0x17(%rbp),%ecx
shl    $0x10,%rcx
or     %rcx,%rax
movzbl -0x16(%rbp),%ecx
shl    $0x8,%rcx
or     %rcx,%rax
movzbl -0x15(%rbp),%ecx
or     %rcx,%rax
mov    %eax,%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x1c(%rbp),%eax
movzbl -0x1b(%rbp),%ecx
shl    $0x8,%rcx
add    %rcx,%rax
movzbl -0x1a(%rbp),%ecx
shl    $0x8,%rcx
shl    $0x8,%rcx
add    %rcx,%rax
movzbl -0x19(%rbp),%ecx
shl    $0x8,%rcx
shl    $0x8,%rcx
shl    $0x8,%rcx
add    %rcx,%rax
mov    %eax,%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x20(%rbp),%eax
movzbl -0x1f(%rbp),%ecx
shl    $0x8,%rcx
or     %rcx,%rax
movzbl -0x1e(%rbp),%ecx
shl    $0x10,%rcx
or     %rcx,%rax
movzbl -0x1d(%rbp),%ecx
shl    $0x18,%rcx
or     %rcx,%rax
mov    %eax,%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x6,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x38(%rbp)
mov    $0x5,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x34(%rbp)
mov    $0x4,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x30(%rbp)
mov    $0x3,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x2,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x28(%rbp)
mov    $0x1,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    %eax,-0x24(%rbp)
xor    %esi,%esi
movzbl -0x20(%rbp),%edi
call   1030 <bit_value@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x28(%rbp),%r11d
mov    -0x24(%rbp),%r10d
lea    0xd54(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0xff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0xff000000,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0xff000000,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0xff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xff,%edi
mov    $0x7,%esi
call   1030 <bit_value@plt>
mov    %rax,0x10(%rsp)
mov    $0xff,%edi
mov    $0x6,%esi
call   1030 <bit_value@plt>
mov    %rax,0x8(%rsp)
mov    $0xff,%edi
mov    $0x5,%esi
call   1030 <bit_value@plt>
mov    %rax,%r12
mov    $0xff,%edi
mov    $0x4,%esi
call   1030 <bit_value@plt>
mov    %rax,%r13
mov    $0xff,%edi
mov    $0x3,%esi
call   1030 <bit_value@plt>
mov    %rax,%rbp
mov    $0xff,%edi
mov    $0x2,%esi
call   1030 <bit_value@plt>
mov    %rax,%r15
mov    $0xff,%edi
mov    $0x1,%esi
call   1030 <bit_value@plt>
mov    %rax,%r14
mov    $0xff,%edi
xor    %esi,%esi
call   1030 <bit_value@plt>
mov    %rax,%rbx
sub    $0x8,%rsp
lea    0xe20(%rip),%rdi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %r12d,%ecx
mov    %r13d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %rbx
push   %r14
push   %r15
call   1040 <printf@plt>
add    $0x20,%rsp
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.buffer1 = [4 x i8] c"\00\00\00\FF"
@__const.main.buffer2 = [4 x i8] c"\FF\00\00\00"
@__const.main.buffer3 = [4 x i8] c"\00\00\00\FF"
@__const.main.buffer4 = [4 x i8] c"\FF\00\00\00"
@.str = [9 x i8] c"Max %lu\0A\00"
@.str.1 = [16 x i8] c"Buffer1 BE %lu\0A\00"
@.str.2 = [16 x i8] c"Buffer2 BE %lu\0A\00"
@.str.3 = [16 x i8] c"Buffer3 LE %lu\0A\00"
@.str.4 = [16 x i8] c"Buffer4 LE %lu\0A\00"
@.str.5 = [47 x i8] c"Buffer4[0] Bit Values %i %i %i %i %i %i %i %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = alloca [4 x i8]
%6 = alloca [4 x i8]
store i32 0, i32* %1
store i64 -1, i64* %2
%7 = bitcast [4 x i8]* %3 to i8*
%8 = bitcast [4 x i8]* %4 to i8*
%9 = bitcast [4 x i8]* %5 to i8*
%10 = bitcast [4 x i8]* %6 to i8*
%11 = load i64, i64* %2
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i64
%17 = mul i64 %16, 256
%18 = mul i64 %17, 256
%19 = mul i64 %18, 256
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i64
%23 = mul i64 %22, 256
%24 = mul i64 %23, 256
%25 = add i64 %19, %24
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%27 = load i8, i8* %26
%28 = zext i8 %27 to i64
%29 = mul i64 %28, 256
%30 = add i64 %25, %29
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%32 = load i8, i8* %31
%33 = zext i8 %32 to i64
%34 = add i64 %30, %33
%35 = trunc i64 %34 to i32
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%38 = load i8, i8* %37
%39 = zext i8 %38 to i64
%40 = shl i64 %39, 24
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%42 = load i8, i8* %41
%43 = zext i8 %42 to i64
%44 = shl i64 %43, 16
%45 = or i64 %40, %44
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%47 = load i8, i8* %46
%48 = zext i8 %47 to i64
%49 = shl i64 %48, 8
%50 = or i64 %45, %49
%51 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%52 = load i8, i8* %51
%53 = zext i8 %52 to i64
%54 = or i64 %50, %53
%55 = trunc i64 %54 to i32
%56 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%58 = load i8, i8* %57
%59 = zext i8 %58 to i64
%60 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
%61 = load i8, i8* %60
%62 = zext i8 %61 to i64
%63 = mul i64 %62, 256
%64 = add i64 %59, %63
%65 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
%66 = load i8, i8* %65
%67 = zext i8 %66 to i64
%68 = mul i64 %67, 256
%69 = mul i64 %68, 256
%70 = add i64 %64, %69
%71 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
%72 = load i8, i8* %71
%73 = zext i8 %72 to i64
%74 = mul i64 %73, 256
%75 = mul i64 %74, 256
%76 = mul i64 %75, 256
%77 = add i64 %70, %76
%78 = trunc i64 %77 to i32
%79 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %78)
%80 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%81 = load i8, i8* %80
%82 = zext i8 %81 to i64
%83 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 1
%84 = load i8, i8* %83
%85 = zext i8 %84 to i64
%86 = shl i64 %85, 8
%87 = or i64 %82, %86
%88 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 2
%89 = load i8, i8* %88
%90 = zext i8 %89 to i64
%91 = shl i64 %90, 16
%92 = or i64 %87, %91
%93 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 3
%94 = load i8, i8* %93
%95 = zext i8 %94 to i64
%96 = shl i64 %95, 24
%97 = or i64 %92, %96
%98 = trunc i64 %97 to i32
%99 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%101 = load i8, i8* %100
%102 = call i64 @bit_value(i8 zeroext %101, i32 7)
%103 = trunc i64 %102 to i32
%104 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%105 = load i8, i8* %104
%106 = call i64 @bit_value(i8 zeroext %105, i32 6)
%107 = trunc i64 %106 to i32
%108 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%109 = load i8, i8* %108
%110 = call i64 @bit_value(i8 zeroext %109, i32 5)
%111 = trunc i64 %110 to i32
%112 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%113 = load i8, i8* %112
%114 = call i64 @bit_value(i8 zeroext %113, i32 4)
%115 = trunc i64 %114 to i32
%116 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%117 = load i8, i8* %116
%118 = call i64 @bit_value(i8 zeroext %117, i32 3)
%119 = trunc i64 %118 to i32
%120 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%121 = load i8, i8* %120
%122 = call i64 @bit_value(i8 zeroext %121, i32 2)
%123 = trunc i64 %122 to i32
%124 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%125 = load i8, i8* %124
%126 = call i64 @bit_value(i8 zeroext %125, i32 1)
%127 = trunc i64 %126 to i32
%128 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%129 = load i8, i8* %128
%130 = call i64 @bit_value(i8 zeroext %129, i32 0)
%131 = trunc i64 %130 to i32
%132 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %103, i32 %107, i32 %111, i32 %115, i32 %119, i32 %123, i32 %127, i32 %131)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"Max %lu\0A\00"
@.str.1 = [16 x i8] c"Buffer1 BE %lu\0A\00"
@.str.2 = [16 x i8] c"Buffer2 BE %lu\0A\00"
@.str.3 = [16 x i8] c"Buffer3 LE %lu\0A\00"
@.str.4 = [16 x i8] c"Buffer4 LE %lu\0A\00"
@.str.5 = [47 x i8] c"Buffer4[0] Bit Values %i %i %i %i %i %i %i %i\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 -1)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 255)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 -16777216)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 -16777216)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 255)
%6 = tail call i64 @bit_value(i8 zeroext -1, i32 7)
%7 = trunc i64 %6 to i32
%8 = tail call i64 @bit_value(i8 zeroext -1, i32 6)
%9 = trunc i64 %8 to i32
%10 = tail call i64 @bit_value(i8 zeroext -1, i32 5)
%11 = trunc i64 %10 to i32
%12 = tail call i64 @bit_value(i8 zeroext -1, i32 4)
%13 = trunc i64 %12 to i32
%14 = tail call i64 @bit_value(i8 zeroext -1, i32 3)
%15 = trunc i64 %14 to i32
%16 = tail call i64 @bit_value(i8 zeroext -1, i32 2)
%17 = trunc i64 %16 to i32
%18 = tail call i64 @bit_value(i8 zeroext -1, i32 1)
%19 = trunc i64 %18 to i32
%20 = tail call i64 @bit_value(i8 zeroext -1, i32 0)
%21 = trunc i64 %20 to i32
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %7, i32 %9, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19, i32 %21)
ret i32 0
}