#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 main(int argc, char *argv[]) {
  char *p;
  char string[10];
  string[0] = 'C';
  string[1] = 'a';
  string[2] = 's';
  string[3] = 'a';
  p = string;
  printf("El puntero apunta a %s.\n", p);
  if (argc > 1) {
    p = argv[1];
    printf("El puntero apunta a %s.\n", p);
  }
  for (int i = 0; i < 4; i++) {
    printf("%c", *p);
    p++;
  }
  printf("\n");
  printf("%d", *p);
  printf("\n");
  p++;
  printf("%d", *p);
  printf("\n");
  printf("La dirección de string es %p\n", string);
  printf("Y el puntero apunta actualmente a %p\n", p);
  printf("La diferencia en bytes es de %d\n", p - string);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x43,-0x22(%rbp)
movb   $0x61,-0x21(%rbp)
movb   $0x73,-0x20(%rbp)
movb   $0x61,-0x1f(%rbp)
lea    -0x22(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1178 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    11b8 <main+0xa8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117f <main+0x6f>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    -0x22(%rbp),%rax
sub    %rax,%rsi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xe(%rsp),%r14
movl   $0x61736143,0xe(%rsp)
61
lea    0xebd(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rbx
cmp    $0x2,%ebp
jl     116a <main+0x4a>
mov    0x8(%r15),%rbx
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x1(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x2(%rbx),%edi
call   1030 <putchar@plt>
movsbl 0x3(%rbx),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl 0x4(%rbx),%esi
lea    0xe77(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl 0x5(%rbx),%esi
add    $0x5,%rbx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe43(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe51(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
sub    %r14,%rbx
lea    0xe63(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"El puntero apunta a %s.\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [31 x i8] c"La direcci\C3\B3n de string es %p\0A\00"
@.str.5 = [38 x i8] c"Y el puntero apunta actualmente a %p\0A\00"
@.str.6 = [33 x i8] c"La diferencia en bytes es de %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [10 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
store i8 67, i8* %9
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 1
store i8 97, i8* %10
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 2
store i8 115, i8* %11
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 3
store i8 97, i8* %12
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %18, %2
store i32 0, i32* %8
br label %25
25: ; preds = %35, %24
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %6
br label %35
35: ; preds = %28
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %25
38: ; preds = %25
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = load i8*, i8** %6
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %6
%47 = load i8*, i8** %6
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %52)
%54 = load i8*, i8** %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i8*, i8** %6
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%58 = ptrtoint i8* %56 to i64
%59 = ptrtoint i8* %57 to i64
%60 = sub i64 %58, %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i64 %60)
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [25 x i8] c"El puntero apunta a %s.\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [31 x i8] c"La direcci\C3\B3n de string es %p\0A\00"
@.str.5 = [38 x i8] c"Y el puntero apunta actualmente a %p\0A\00"
@.str.6 = [33 x i8] c"La diferencia en bytes es de %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 67, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
store i8 97, i8* %5
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 115, i8* %6
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 97, i8* %7
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %10, %2
%15 = phi i8* [ %12, %10 ], [ %4, %2 ]
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i32 @putchar(i32 %17)
%19 = getelementptr inbounds i8, i8* %15, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 @putchar(i32 %21)
%23 = getelementptr inbounds i8, i8* %15, i64 2
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 @putchar(i32 %25)
%27 = getelementptr inbounds i8, i8* %15, i64 3
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 @putchar(i32 %29)
%31 = getelementptr inbounds i8, i8* %15, i64 4
%32 = call i32 @putchar(i32 10)
%33 = load i8, i8* %31
%34 = sext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = call i32 @putchar(i32 10)
%37 = getelementptr inbounds i8, i8* %15, i64 5
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = call i32 @putchar(i32 10)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%44 = ptrtoint i8* %37 to i64
%45 = ptrtoint [10 x i8]* %3 to i64
%46 = sub i64 %44, %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i64 %46)
ret i32 0
}