#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__ is_bigendian();
int /*<<< orphan*/ printbinary(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ size_t_unit();
int wordlength();
int main(int argc, char *argv[]) {
  printf("Ok dude, let's take a look at this machine...\n");
  printf("I see that there are %d bits in a char\n", (int)size_t_unit());
  printf("Woooha, this is a %s architecture!\n",
         is_bigendian() ? "big endian" : "little endian");
  printf("It looks like there are %d bits in a machine word\n", wordlength());
  printf("Let's see how -1 is represented: ");
  printbinary(-1);
  printf("Nice! What about %d (INT_MAX)?\n", ((unsigned int)~0) >> 1);
  printbinary((int)(((unsigned int)~0) >> 1));
  printf("What about %d (INT_MIN)?\n", -(((unsigned int)~0) >> 1) - 1);
  printbinary((int)-(((unsigned int)~0) >> 1) - 1);
  printf("What about abs(INT_MIN)?\n");
  printbinary((int)-(-(((unsigned int)~0) >> 1) - 1));
  printf(
      "Oops! That's the case where x = -x for x != 0, which theoretically and "
      "mathematically speaking can't happen, but it does in real world!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <size_t_unit@plt>
mov    %eax,%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <is_bigendian@plt>
mov    %rax,%rcx
lea    0xeea(%rip),%rsi
lea    0xed8(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <wordlength@plt>
mov    %eax,%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <printbinary@plt>
lea    0xefa(%rip),%rdi
mov    $0x7fffffff,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7fffffff,%edi
call   1070 <printbinary@plt>
lea    0xefd(%rip),%rdi
mov    $0x80000000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x80000000,%edi
call   1070 <printbinary@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x80000000,%edi
call   1070 <printbinary@plt>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf8c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <size_t_unit@plt>
lea    0xe85(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <is_bigendian@plt>
test   %rax,%rax
lea    0xec2(%rip),%rax
lea    0xeb0(%rip),%rsi
cmove  %rax,%rsi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <wordlength@plt>
lea    0xea9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <printbinary@plt>
lea    0xed6(%rip),%rdi
mov    $0x7fffffff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7fffffff,%edi
call   1080 <printbinary@plt>
lea    0xed9(%rip),%rdi
mov    $0x80000000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x80000000,%edi
call   1080 <printbinary@plt>
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
mov    $0x80000000,%edi
call   1080 <printbinary@plt>
lea    0xf07(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Ok dude, let's take a look at this machine...\0A\00"
@.str.1 = [40 x i8] c"I see that there are %d bits in a char\0A\00"
@.str.2 = [36 x i8] c"Woooha, this is a %s architecture!\0A\00"
@.str.3 = [11 x i8] c"big endian\00"
@.str.4 = [14 x i8] c"little endian\00"
@.str.5 = [51 x i8] c"It looks like there are %d bits in a machine word\0A\00"
@.str.6 = [34 x i8] c"Let's see how -1 is represented: \00"
@.str.7 = [32 x i8] c"Nice! What about %d (INT_MAX)?\0A\00"
@.str.8 = [26 x i8] c"What about %d (INT_MIN)?\0A\00"
@.str.9 = [26 x i8] c"What about abs(INT_MIN)?\0A\00"
@.str.10 = [137 x i8] c"Oops! That's the case where x = -x for x != 0, which theoretically and mathematically speaking can't happen, but it does in real world!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i64 (...) @size_t_unit()
%8 = trunc i64 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i64 (...) @is_bigendian()
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = call i32 (...) @wordlength()
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @printbinary(i32 -1)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 2147483647)
%20 = call i32 @printbinary(i32 2147483647)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 -2147483648)
%22 = call i32 @printbinary(i32 -2147483648)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 @printbinary(i32 -2147483648)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"I see that there are %d bits in a char\0A\00"
@.str.2 = [36 x i8] c"Woooha, this is a %s architecture!\0A\00"
@.str.3 = [11 x i8] c"big endian\00"
@.str.4 = [14 x i8] c"little endian\00"
@.str.5 = [51 x i8] c"It looks like there are %d bits in a machine word\0A\00"
@.str.6 = [34 x i8] c"Let's see how -1 is represented: \00"
@.str.7 = [32 x i8] c"Nice! What about %d (INT_MAX)?\0A\00"
@.str.8 = [26 x i8] c"What about %d (INT_MIN)?\0A\00"
@str = [46 x i8] c"Ok dude, let's take a look at this machine...\00"
@str.11 = [25 x i8] c"What about abs(INT_MIN)?\00"
@str.12 = [136 x i8] c"Oops! That's the case where x = -x for x != 0, which theoretically and mathematically speaking can't happen, but it does in real world!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%4 = tail call i64 (...) @size_t_unit()
%5 = trunc i64 %4 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i64 (...) @is_bigendian()
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = tail call i32 (...) @wordlength()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%14 = tail call i32 @printbinary(i32 -1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 2147483647)
%16 = tail call i32 @printbinary(i32 2147483647)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 -2147483648)
%18 = tail call i32 @printbinary(i32 -2147483648)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%20 = tail call i32 @printbinary(i32 -2147483648)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([136 x i8], [136 x i8]* @str.12, i64 0, i64 0))
ret i32 0
}