#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char *buf = "hello world";
  printf("栈区域地址%p  常量区%p\n\n", &buf, buf);
  const char const str1[] = "abcd";
  const char const str2[] = "abcd";
  printf("[%p == %p] %d\n", &str1, &str2, &str1 == &str2);
  printf("[%p == %p] %d\n\n", str1, str2, str1 == str2);
  printf("%s\n", str1);
  const char *pstr1 = "abcd";
  const char *pstr2 = "abcd";
  printf("[%p == %p] %d\n", &pstr1, &pstr2, &pstr1 == &pstr2);
  printf("[%p == %p] %d\n\n", pstr1, pstr2, pstr1 == pstr2);
  pstr1 = "1234";
  pstr2 = "1234";
  printf("[%p == %p] %d\n", &pstr1, &pstr2, &pstr1 == &pstr2);
  printf("[%p == %p] %d\n\n", pstr1, pstr2, pstr1 == pstr2);
  pstr1 = "abcd";
  pstr2 = "1234";
  printf("[%p == %p] %d\n", &pstr1, &pstr2, &pstr1 == &pstr2);
  printf("[%p == %p] %d\n\n", pstr1, pstr2, pstr1 == pstr2);
  char *const pstr3 = "abcd";
  char *const pstr4 = "abcd";
  printf("[%p == %p] %d\n", &pstr3, &pstr4, &pstr3 == &pstr4);
  printf("[%p == %p] %d\n\n", pstr3, pstr4, pstr3 == pstr4);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xed7(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xee7(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xee2(%rip),%al
mov    %al,-0x11(%rbp)
mov    0xed5(%rip),%eax
mov    %eax,-0x1a(%rbp)
mov    0xed0(%rip),%al
mov    %al,-0x16(%rbp)
lea    -0x15(%rbp),%rax
lea    -0x1a(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xeb4(%rip),%rdi
lea    -0x15(%rbp),%rsi
lea    -0x1a(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x15(%rbp),%rsi
lea    -0x1a(%rbp),%rdx
lea    -0x15(%rbp),%rax
lea    -0x1a(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x15(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5e(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rax
lea    -0x30(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe3a(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe21(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe16(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rax
lea    -0x30(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xdd5(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd94(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xdb1(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rax
lea    -0x30(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xd70(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd2f(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xd24(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    -0x38(%rbp),%rax
lea    -0x40(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xd0b(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd04(%rip),%rdi
lea    0xce9(%rip),%rdx
mov    $0x1,%ecx
mov    %rdx,%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2c86(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xecb(%rip),%rdx
mov    %rdx,0x30(%rsp)
lea    0xecb(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movb   $0x0,0x1c(%rsp)
movl   $0x64636261,0x18(%rsp)
64
lea    0xeeb(%rip),%r14
movb   $0x0,0x14(%rsp)
movl   $0x64636261,0x10(%rsp)
64
lea    0xeb8(%rip),%r15
lea    0x18(%rsp),%rbx
lea    0x10(%rsp),%rbp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea4(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,0x8(%rsp)
mov    %r14,(%rsp)
lea    0x8(%rsp),%rbp
mov    %rsp,%r13
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
xor    %ecx,%ecx
cmp    %rdx,%rsi
sete   %cl
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5a(%rip),%rbx
mov    %rbx,0x8(%rsp)
mov    %rbx,(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
xor    %ecx,%ecx
cmp    %rdx,%rsi
sete   %cl
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,0x8(%rsp)
mov    %rbx,(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
xor    %ecx,%ecx
cmp    %rdx,%rsi
sete   %cl
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,0x28(%rsp)
mov    %r14,0x20(%rsp)
lea    0x28(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    %r15,%rdi
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r14,%rdx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"hello world\00"
@.str.1 = [33 x i8] c"\E6\A0\88\E5\8C\BA\E5\9F\9F\E5\9C\B0\E5\9D\80%p \E5\B8\B8\E9\87\8F\E5\8C\BA%p\0A\0A\00"
@__const.main.str1 = [5 x i8] c"abcd\00"
@__const.main.str2 = [5 x i8] c"abcd\00"
@.str.2 = [15 x i8] c"[%p == %p] %d\0A\00"
@.str.3 = [16 x i8] c"[%p == %p] %d\0A\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [5 x i8] c"abcd\00"
@.str.6 = [5 x i8] c"1234\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [5 x i8]
%4 = alloca [5 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8** %2, i8* %9)
%11 = bitcast [5 x i8]* %3 to i8*
%12 = bitcast [5 x i8]* %4 to i8*
%13 = icmp eq [5 x i8]* %3, %4
%14 = zext i1 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), [5 x i8]* %3, [5 x i8]* %4, i32 %14)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%20 = icmp eq i8* %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17, i32 %21)
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %23)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %6
%25 = icmp eq i8** %5, %6
%26 = zext i1 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %5, i8** %6, i32 %26)
%28 = load i8*, i8** %5
%29 = load i8*, i8** %6
%30 = load i8*, i8** %5
%31 = load i8*, i8** %6
%32 = icmp eq i8* %30, %31
%33 = zext i1 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %28, i8* %29, i32 %33)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %6
%35 = icmp eq i8** %5, %6
%36 = zext i1 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %5, i8** %6, i32 %36)
%38 = load i8*, i8** %5
%39 = load i8*, i8** %6
%40 = load i8*, i8** %5
%41 = load i8*, i8** %6
%42 = icmp eq i8* %40, %41
%43 = zext i1 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %39, i32 %43)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %6
%45 = icmp eq i8** %5, %6
%46 = zext i1 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %5, i8** %6, i32 %46)
%48 = load i8*, i8** %5
%49 = load i8*, i8** %6
%50 = load i8*, i8** %5
%51 = load i8*, i8** %6
%52 = icmp eq i8* %50, %51
%53 = zext i1 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %48, i8* %49, i32 %53)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %8
%55 = icmp eq i8** %7, %8
%56 = zext i1 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %7, i8** %8, i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i32 1)
%59 = load i32, i32* @EXIT_SUCCESS
ret i32 %59
}

LLVM IR (-O2):
@.str = [12 x i8] c"hello world\00"
@.str.1 = [33 x i8] c"\E6\A0\88\E5\8C\BA\E5\9F\9F\E5\9C\B0\E5\9D\80%p \E5\B8\B8\E9\87\8F\E5\8C\BA%p\0A\0A\00"
@.str.2 = [15 x i8] c"[%p == %p] %d\0A\00"
@.str.3 = [16 x i8] c"[%p == %p] %d\0A\0A\00"
@.str.5 = [5 x i8] c"abcd\00"
@.str.6 = [5 x i8] c"1234\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = bitcast i8** %1 to i8*
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), [5 x i8]* %2, [5 x i8]* %3, i32 0)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %11, i32 0)
%14 = call i32 @puts(i8* %10)
%15 = bitcast i8** %4 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %4
%16 = bitcast i8** %5 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %5
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %4, i8** %5, i32 0)
%18 = load i8*, i8** %4
%19 = load i8*, i8** %5
%20 = icmp eq i8* %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %18, i8* %19, i32 %21)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %5
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %4, i8** %5, i32 0)
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = icmp eq i8* %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %25, i32 %27)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %5
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %4, i8** %5, i32 0)
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = icmp eq i8* %30, %31
%33 = zext i1 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %31, i32 %33)
%35 = bitcast i8** %6 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %6
%36 = bitcast i8** %7 to i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %7
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %6, i8** %7, i32 0)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 1)
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}