#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 scalar_t__ ip;

/* Variables and functions */
int /*<<< orphan*/ printargs(int, char **);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printargs(argc, argv);
  unsigned int i = 0, *ip;
  unsigned int j = 0x12345678;
  unsigned char c, *cp;
  ip = &i;
  printf("writing %X at %p\n", j, ip);
  *ip = j;
  if (*((unsigned char *)(ip)) == 0x12)
    printf("Big Endian\n");
  if (*((unsigned char *)(ip)) == 0x78)
    printf("Little Endian\n");
  cp = (unsigned char *)(ip) + 0;
  printf("value at address: %p: %x\n", cp, *cp);
  cp = (unsigned char *)(ip) + 1;
  printf("value at address: %p: %x\n", cp, *cp);
  cp = (unsigned char *)(ip) + 2;
  printf("value at address: %p: %x\n", cp, *cp);
  cp = (unsigned char *)(ip) + 3;
  printf("value at address: %p: %x\n", cp, *cp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <printargs@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x12345678,-0x24(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x12,%eax
jne    1194 <main+0x74>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x78,%eax
jne    11b2 <main+0x92>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rax
movzbl (%rax),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rax
movzbl (%rax),%edx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rax
movzbl (%rax),%edx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x30(%rbp),%rax
movzbl (%rax),%edx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
call   1040 <printargs@plt>
movl   $0x0,0x4(%rsp)
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%r14
mov    $0x12345678,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x12345678,0x4(%rsp)
12
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
movzbl 0x4(%rsp),%edx
lea    0xe96(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x5(%rsp),%rsi
movzbl 0x5(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x6(%rsp),%rsi
movzbl 0x6(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x7(%rsp),%rsi
movzbl 0x7(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"writing %X at %p\0A\00"
@.str.1 = [12 x i8] c"Big Endian\0A\00"
@.str.2 = [15 x i8] c"Little Endian\0A\00"
@.str.3 = [26 x i8] c"value at address: %p: %x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @printargs(i32 %11, i8** %12)
store i32 0, i32* %6
store i32 305419896, i32* %8
store i32* %6, i32** %7
%14 = load i32, i32* %8
%15 = load i32*, i32** %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %14, i32* %15)
%17 = load i32, i32* %8
%18 = load i32*, i32** %7
store i32 %17, i32* %18
%19 = load i32*, i32** %7
%20 = bitcast i32* %19 to i8*
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 18
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %2
%27 = load i32*, i32** %7
%28 = bitcast i32* %27 to i8*
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 120
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %26
%35 = load i32*, i32** %7
%36 = bitcast i32* %35 to i8*
%37 = getelementptr inbounds i8, i8* %36, i64 0
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = load i8*, i8** %10
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %38, i32 %41)
%43 = load i32*, i32** %7
%44 = bitcast i32* %43 to i8*
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8* %45, i8** %10
%46 = load i8*, i8** %10
%47 = load i8*, i8** %10
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %46, i32 %49)
%51 = load i32*, i32** %7
%52 = bitcast i32* %51 to i8*
%53 = getelementptr inbounds i8, i8* %52, i64 2
store i8* %53, i8** %10
%54 = load i8*, i8** %10
%55 = load i8*, i8** %10
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %54, i32 %57)
%59 = load i32*, i32** %7
%60 = bitcast i32* %59 to i8*
%61 = getelementptr inbounds i8, i8* %60, i64 3
store i8* %61, i8** %10
%62 = load i8*, i8** %10
%63 = load i8*, i8** %10
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %62, i32 %65)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"writing %X at %p\0A\00"
@.str.3 = [26 x i8] c"value at address: %p: %x\0A\00"
@str = [14 x i8] c"Little Endian\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i32 @printargs(i32 %0, i8** %1)
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 305419896, i32* %3)
store i32 305419896, i32* %3
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%8 = load i8, i8* %5
%9 = zext i8 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32 %9)
%11 = getelementptr inbounds i8, i8* %5, i64 1
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %11, i32 %13)
%15 = getelementptr inbounds i8, i8* %5, i64 2
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %15, i32 %17)
%19 = getelementptr inbounds i8, i8* %5, i64 3
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 %21)
ret i32 0
}