#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*/ charIn(char *, int);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void ex2() {
  char *str1 = malloc(100), *str2 = malloc(100);
  printf("Frase 1: ");
  charIn(str1, 100);
  printf("Frase 2: ");
  charIn(str2, 100);
  if (strcmp(str1, str2) != 0)
    printf("%s e diferente de %s.", str1, str2);
  else
    printf("%s e igual a %s.", str1, str2);
}


x86 assembly (clang, -O0):
<ex2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x64,%esi
call   1030 <charIn@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1030 <charIn@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11ce <ex2+0x8e>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e4 <ex2+0xa4>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex2>:
push   %r14
push   %rbx
push   %rax
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x64,%esi
call   1030 <charIn@plt>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1030 <charIn@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe81(%rip),%rax
lea    0xe64(%rip),%rdi
cmove  %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Frase 1: \00"
@.str.1 = [10 x i8] c"Frase 2: \00"
@.str.2 = [22 x i8] c"%s e diferente de %s.\00"
@.str.3 = [17 x i8] c"%s e igual a %s.\00"
define void @ex2() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @malloc(i32 100)
store i8* %3, i8** %1
%4 = call i8* @malloc(i32 100)
store i8* %4, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = call i32 @charIn(i8* %6, i32 100)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = load i8*, i8** %2
%10 = call i32 @charIn(i8* %9, i32 100)
%11 = load i8*, i8** %1
%12 = load i8*, i8** %2
%13 = call i64 @strcmp(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i8*, i8** %1
%17 = load i8*, i8** %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %17)
br label %23
19: ; preds = %0
%20 = load i8*, i8** %1
%21 = load i8*, i8** %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* %21)
br label %23
23: ; preds = %19, %15
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"Frase 1: \00"
@.str.1 = [10 x i8] c"Frase 2: \00"
@.str.2 = [22 x i8] c"%s e diferente de %s.\00"
@.str.3 = [17 x i8] c"%s e igual a %s.\00"
define void @ex2() {
%1 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%2 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @charIn(i8* %1, i32 100)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @charIn(i8* %2, i32 100)
%7 = tail call i64 @strcmp(i8* %1, i8* %2)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9, i8* %1, i8* %2)
ret void
}