#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdout;
int strncmp(char *, char *, int);
int main() {
  char *str1;
  char *str2;
  int ret;
  str1 = (char *)malloc(sizeof(char));
  str2 = (char *)malloc(sizeof(char));
  fprintf(stdout, "Insira a primeira string: ");
  scanf("%s", str1);
  fprintf(stdout, "Insira a primeira string: ");
  scanf("%s", str2);
  ret = strncmp(str1, str2, 6);
  if (ret > 0)
    printf("str1 is longer\n");
  else if (ret < 0)
    printf("str2 is longer\n");
  else
    printf("The two strings are equal\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1070 <scanf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11f5 <main+0xa5>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
jmp    1221 <main+0xd1>
cmpl   $0x0,-0x1c(%rbp)
jge    1210 <main+0xc0>
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <main+0xcc>
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
jmp    1221 <main+0xd1>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    0x2e66(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe7b(%rip),%r15
mov    %r15,%rsi
call   1050 <fprintf@plt>
lea    0xe87(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    0x0(%r13),%edi
mov    %r15,%rsi
call   1050 <fprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
lea    0xe69(%rip),%rax
lea    0xe48(%rip),%rcx
cmovs  %rax,%rcx
lea    0xe66(%rip),%rdi
cmovle %rcx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [27 x i8] c"Insira a primeira string: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"str1 is longer\0A\00"
@.str.3 = [16 x i8] c"str2 is longer\0A\00"
@.str.4 = [27 x i8] c"The two strings are equal\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @malloc(i32 1)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = call i64 @malloc(i32 1)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stdout
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %3
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %2
%18 = load i8*, i8** %3
%19 = call i32 @strncmp(i8* %17, i8* %18, i32 6)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %32
24: ; preds = %0
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %31
29: ; preds = %24
%30 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
br label %32
32: ; preds = %31, %22
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [27 x i8] c"Insira a primeira string: \00"
@.str.1 = [3 x i8] c"%s\00"
@str = [26 x i8] c"The two strings are equal\00"
@str.5 = [15 x i8] c"str2 is longer\00"
@str.6 = [15 x i8] c"str1 is longer\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 1)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i64 @malloc(i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = load i32, i32* @stdout
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = tail call i32 @strncmp(i8* %2, i8* %4, i32 6)
%12 = icmp sgt i32 %11, 0
%13 = icmp slt i32 %11, 0
%14 = select i1 %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0)
%15 = select i1 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0), i8* %14
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
ret i32 0
}