#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 wchar_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int wcslen(int *);
void escapa_cometes(wchar_t *cadena) {
  int longitud;
  int i;
  longitud = wcslen(cadena);
  for (i = 0; i < longitud; i++) {
    if ((1))
      printf("posicio %d -> lletra %c \n", i, cadena[i]);
    if (cadena[i] == '\'')
      cadena[i] = '^';
  }
}


x86 assembly (clang, -O0):
<escapa_cometes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <wcslen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1199 <escapa_cometes+0x79>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x27,(%rax,%rcx,4)
jne    1186 <escapa_cometes+0x66>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x5e,(%rax,%rcx,4)
jmp    118b <escapa_cometes+0x6b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <escapa_cometes+0x1f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escapa_cometes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <wcslen@plt>
test   %eax,%eax
jle    1178 <escapa_cometes+0x58>
mov    %eax,%r12d
xor    %ebx,%ebx
lea    0xec0(%rip),%r15
jmp    1159 <escapa_cometes+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1178 <escapa_cometes+0x58>
mov    (%r14,%rbx,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmpl   $0x27,(%r14,%rbx,4)
jne    1150 <escapa_cometes+0x30>
movl   $0x5e,(%r14,%rbx,4)
jmp    1150 <escapa_cometes+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"posicio %d -> lletra %c \0A\00"
define void @escapa_cometes(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @wcslen(i32* %5)
store i32 %6, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %31, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = load i32, i32* %4
%13 = load i32*, i32** %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %17)
%19 = load i32*, i32** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 39
br i1 %24, label %25, label %30
25: ; preds = %11
%26 = load i32*, i32** %2
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 94, i32* %29
br label %30
30: ; preds = %25, %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %7
34: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"posicio %d -> lletra %c \0A\00"
define void @escapa_cometes(i32* nocapture %0) {
%2 = tail call i32 @wcslen(i32* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ 0, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = trunc i64 %7 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %9)
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, 39
br i1 %13, label %14, label %15
14: ; preds = %6
store i32 94, i32* %8
br label %15
15: ; preds = %6, %14
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, %5
br i1 %17, label %18, label %6
18: ; preds = %15, %1
ret void
}