#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 comparar(char x[], char y[], int n) {
  int i = 0;
  int c[n];
  int d = 0;
  while (x[i] != '\0') {
    printf("hey");
  }
  n = i;
  for (i = 0; i < n; i++) {
    c[i] = (x[i] != y[i]);
    d += c[i];
  }
  return (d);
}


x86 assembly (clang, -O0):
<comparar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     117e <comparar+0x6e>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    1158 <comparar+0x48>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e0 <comparar+0xd0>
mov    -0x38(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
mov    -0x10(%rbp),%rdx
movslq -0x18(%rbp),%rsi
movsbl (%rdx,%rsi,1),%edx
cmp    %edx,%ecx
setne  %cl
and    $0x1,%cl
movzbl %cl,%edx
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118b <comparar+0x7b>
mov    -0x2c(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comparar>:
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     113d <comparar+0x2d>
mov    %rdi,%rbx
lea    0xedd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
cmpb   $0x0,(%rbx)
jne    1130 <comparar+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hey\00"
define i32 @comparar(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%11 = load i32, i32* %6
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %8
%14 = alloca i32, i64 %12
store i64 %12, i64* %9
store i32 0, i32* %10
br label %15
15: ; preds = %23, %3
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %15
25: ; preds = %15
%26 = load i32, i32* %7
store i32 %26, i32* %6
store i32 0, i32* %7
br label %27
27: ; preds = %55, %25
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %58
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = load i8*, i8** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %37, %43
%45 = zext i1 %44 to i32
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %14, i64 %47
store i32 %45, i32* %48
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %14, i64 %50
%52 = load i32, i32* %51
%53 = load i32, i32* %10
%54 = add nsw i32 %53, %52
store i32 %54, i32* %10
br label %55
55: ; preds = %31
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %27
58: ; preds = %27
%59 = load i32, i32* %10
%60 = load i8*, i8** %8
ret i32 %59
}

LLVM IR (-O2):
@.str = [4 x i8] c"hey\00"
define i32 @comparar(i8* nocapture %0, i8* nocapture readnone %1, i32 %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3, %6
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6, %3
ret i32 0
}