#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*/ printf(char *, ...);
void printSomeCharAddresses(int *ptrFromMain) {
  char n = 'n';
  char *nLoc = &n;
  printf("Value of n: %c, Location of n: %p\n", n, nLoc);
  char m = 'm';
  char *mLoc = &m;
  printf("Value of m: %c, Location of m: %p\n", m, mLoc);
  printf("Size of a char: %d\n", (int)sizeof(char));
  printf("Difference between char pointers: %d\n\n", (int)mLoc - (int)nLoc);
  printf("m declared after n\n");
  printf("Where are they comparatively in memory?\n");
  printf("Is mLoc > nLoc?: %s\n\n", mLoc > nLoc ? "Yes" : "No");
  printf("Difference between char and ptr from main: %d\n\n",
         (int)nLoc - (int)ptrFromMain);
}


x86 assembly (clang, -O0):
<printSomeCharAddresses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x6e,-0x9(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsbl -0x9(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x6d,-0x19(%rbp)
lea    -0x19(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsbl -0x19(%rbp),%esi
mov    -0x28(%rbp),%rdx
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rax
sub    %eax,%esi
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rdx
lea    0xf20(%rip),%rsi
lea    0xf15(%rip),%rax
cmp    %rdx,%rcx
cmova  %rax,%rsi
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
sub    %eax,%esi
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSomeCharAddresses>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
movb   $0x6e,0xf(%rsp)
lea    0xec8(%rip),%rdi
lea    0xf(%rsp),%rbx
mov    $0x6e,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
movb   $0x6d,0xe(%rsp)
lea    0xecb(%rip),%rdi
lea    0xe(%rsp),%r15
mov    $0x6d,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%esi
sub    %ebx,%esi
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3c(%rip),%rdi
call   1030 <puts@plt>
cmp    %rbx,%r15
lea    0xee3(%rip),%rax
lea    0xee0(%rip),%rsi
cmova  %rax,%rsi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
sub    %r14d,%ebx
lea    0xec7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Value of n: %c, Location of n: %p\0A\00"
@.str.1 = [35 x i8] c"Value of m: %c, Location of m: %p\0A\00"
@.str.2 = [20 x i8] c"Size of a char: %d\0A\00"
@.str.3 = [39 x i8] c"Difference between char pointers: %d\0A\0A\00"
@.str.4 = [20 x i8] c"m declared after n\0A\00"
@.str.5 = [41 x i8] c"Where are they comparatively in memory?\0A\00"
@.str.6 = [22 x i8] c"Is mLoc > nLoc?: %s\0A\0A\00"
@.str.7 = [4 x i8] c"Yes\00"
@.str.8 = [3 x i8] c"No\00"
@.str.9 = [48 x i8] c"Difference between char and ptr from main: %d\0A\0A\00"
define void @printSomeCharAddresses(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
store i32* %0, i32** %2
store i8 110, i8* %3
store i8* %3, i8** %4
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %9)
store i8 109, i8* %5
store i8* %5, i8** %6
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = load i8*, i8** %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 1)
%16 = load i8*, i8** %6
%17 = ptrtoint i8* %16 to i32
%18 = load i8*, i8** %4
%19 = ptrtoint i8* %18 to i32
%20 = sub nsw i32 %17, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%24 = load i8*, i8** %6
%25 = load i8*, i8** %4
%26 = icmp ugt i8* %24, %25
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %4
%31 = ptrtoint i8* %30 to i32
%32 = load i32*, i32** %2
%33 = ptrtoint i32* %32 to i32
%34 = sub nsw i32 %31, %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32 %34)
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"Value of n: %c, Location of n: %p\0A\00"
@.str.1 = [35 x i8] c"Value of m: %c, Location of m: %p\0A\00"
@.str.2 = [20 x i8] c"Size of a char: %d\0A\00"
@.str.3 = [39 x i8] c"Difference between char pointers: %d\0A\0A\00"
@.str.6 = [22 x i8] c"Is mLoc > nLoc?: %s\0A\0A\00"
@.str.7 = [4 x i8] c"Yes\00"
@.str.8 = [3 x i8] c"No\00"
@.str.9 = [48 x i8] c"Difference between char and ptr from main: %d\0A\0A\00"
@str = [19 x i8] c"m declared after n\00"
@str.10 = [40 x i8] c"Where are they comparatively in memory?\00"
define void @printSomeCharAddresses(i32* %0) {
%2 = alloca i8
%3 = alloca i8
store i8 110, i8* %2
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 110, i8* %2)
store i8 109, i8* %3
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 109, i8* %3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 1)
%7 = ptrtoint i8* %3 to i64
%8 = trunc i64 %7 to i32
%9 = ptrtoint i8* %2 to i64
%10 = trunc i64 %9 to i32
%11 = sub nsw i32 %8, %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
%15 = icmp ugt i8* %3, %2
%16 = select i1 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%18 = ptrtoint i32* %0 to i64
%19 = trunc i64 %18 to i32
%20 = sub nsw i32 %10, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32 %20)
ret void
}