#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 int /*<<< orphan*/ test_s;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, ...);
size_t strlen(char *);
int main() {
  char *test_s = "Hello,world";
  printf("address %s : %p\n", test_s, &test_s);
  printf("sizeof %s : %ld\n", test_s, (unsigned long)sizeof(test_s));
  size_t len = strlen(test_s);
  printf("length of %s : %ld\n", test_s, (unsigned long)len);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rsi
mov    %rsi,0x8(%rsp)
lea    0xed4(%rip),%rdi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xebe(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Hello,world\00"
@.str.1 = [17 x i8] c"address %s : %p\0A\00"
@.str.2 = [17 x i8] c"sizeof %s : %ld\0A\00"
@.str.3 = [20 x i8] c"length of %s : %ld\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = load i8*, i8** %1
%4 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8** %1)
%5 = load i8*, i8** %1
%6 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %5, i64 8)
%7 = load i8*, i8** %1
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %2
%9 = load i8*, i8** %1
%10 = load i64, i64* %2
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %9, i64 %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello,world\00"
@.str.1 = [17 x i8] c"address %s : %p\0A\00"
@.str.2 = [17 x i8] c"sizeof %s : %ld\0A\00"
@.str.3 = [20 x i8] c"length of %s : %ld\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %1)
%4 = load i8*, i8** %1
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %4, i64 8)
%6 = load i8*, i8** %1
%7 = call i64 @strlen(i8* dereferenceable(1) %6)
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %6, i64 %7)
ret i32 0
}