#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*/ ptrToStringLiteral;
typedef int /*<<< orphan*/ mallocedString;
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *);
int main(void) {
  char array[11] = "hello world";
  printf("sizeof(array) = %lu\n", sizeof(array));
  char *ptrToStringLiteral = "hello world";
  printf("sizeof(ptrToStringLiteral) = %lu\n", sizeof(ptrToStringLiteral));
  char *mallocedString = malloc(12);
  sprintf(mallocedString, "hello world");
  printf("sizeof(mallocedString) = %lu\n", sizeof(mallocedString));
  free(mallocedString);
  printf("sizeof(\"hello world\") = %lu\n", sizeof("hello world"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0x5(%rbp)
lea    0xe96(%rip),%rdi
mov    $0xb,%esi
call   1040 <printf@plt>
lea    0xe9a(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <sprintf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xe92(%rip),%rdi
mov    $0xc,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
mov    $0xb,%esi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movabs $0x6f77206f6c6c6568,%rax
20 77 6f
mov    %rax,(%rbx)
movl   $0x646c72,0x8(%rbx)
lea    0xec8(%rip),%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xecd(%rip),%rdi
mov    $0xc,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array = [11 x i8] c"hello world"
@.str = [21 x i8] c"sizeof(array) = %lu\0A\00"
@.str.1 = [12 x i8] c"hello world\00"
@.str.2 = [34 x i8] c"sizeof(ptrToStringLiteral) = %lu\0A\00"
@.str.3 = [30 x i8] c"sizeof(mallocedString) = %lu\0A\00"
@.str.4 = [29 x i8] c"sizeof(\22hello world\22) = %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [11 x i8]* %2 to i8*
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 11)
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %3
%7 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 8)
%8 = call i8* @malloc(i32 12)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 8)
%12 = load i8*, i8** %4
%13 = call i32 @free(i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 12)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"sizeof(array) = %lu\0A\00"
@.str.1 = [12 x i8] c"hello world\00"
@.str.2 = [34 x i8] c"sizeof(ptrToStringLiteral) = %lu\0A\00"
@.str.3 = [30 x i8] c"sizeof(mallocedString) = %lu\0A\00"
@.str.4 = [29 x i8] c"sizeof(\22hello world\22) = %lu\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 11)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 8)
%3 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %3, i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 12, i1 false)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 8)
%5 = tail call i32 @free(i8* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 12)
ret i32 0
}