#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 *, ...);
int /*<<< orphan*/ puts(char *);
int main(void) {
  char strlit[] = "Gheorghe";
  char *ptr2str = strlit;
  char **ptr2str2 = &ptr2str;
  char ***ptr2str3 = &ptr2str2;
  int gogu = 3;
  printf("ptr2str e %s\n *ptr2str e %c\n", ptr2str, *ptr2str);
  ptr2str[1] = 'x';
  puts(**ptr2str3);
  ptr2str2[0][1] = 'z';
  printf("second element os ptr2str3 is %c\n\n", ptr2str3[0][0][1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xec8(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xd(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x3,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movb   $0x78,0x1(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movb   $0x7a,0x1(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x656867726f656847,%rax
67 68 65
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0xeca(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x47,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movb   $0x78,0x1(%rsp)
mov    %rbx,%rdi
call   1030 <puts@plt>
movb   $0x7a,0x1(%rsp)
lea    0xebc(%rip),%rdi
mov    $0x7a,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.strlit = [9 x i8] c"Gheorghe\00"
@.str = [29 x i8] c"ptr2str e %s\0A *ptr2str e %c\0A\00"
@.str.1 = [35 x i8] c"second element os ptr2str3 is %c\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8***
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [9 x i8]* %2 to i8*
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
store i8* %8, i8** %3
store i8** %3, i8*** %4
store i8*** %4, i8**** %5
store i32 3, i32* %6
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %12)
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 120, i8* %15
%16 = load i8***, i8**** %5
%17 = load i8**, i8*** %16
%18 = load i8*, i8** %17
%19 = call i32 @puts(i8* %18)
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8 122, i8* %23
%24 = load i8***, i8**** %5
%25 = getelementptr inbounds i8**, i8*** %24, i64 0
%26 = load i8**, i8*** %25
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@__const.main.strlit = [9 x i8] c"Gheorghe\00"
@.str = [29 x i8] c"ptr2str e %s\0A *ptr2str e %c\0A\00"
@.str.1 = [35 x i8] c"second element os ptr2str3 is %c\0A\0A\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %2, i32 71)
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 1
store i8 120, i8* %4
%5 = call i32 @puts(i8* %2)
store i8 122, i8* %4
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 122)
ret i32 0
}