#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char nome1[40], nome2[40], copia[40];
  int tamanho1, tamanho2, igualdade;
  printf("Digite o nome do aluno 1\n");
  gets(nome1);
  printf("Digite o nome do aluno 2\n");
  gets(nome2);
  printf("\n\n%s\n%s\n", nome1, nome2);
  tamanho1 = strlen(nome1);
  tamanho2 = strlen(nome2);
  printf("\nO primeiro nome tem %d caracteres, enquanto que o segundo tem %d "
         "caracteres\n\n",
         tamanho1, tamanho2);
  if (tamanho1 > tamanho2) {
    strcpy(copia, nome1);
  } else {
    strcpy(copia, nome2);
  }
  printf("\nO maior nome e o %s\n\n", copia);
  if (tamanho1 > tamanho2) {
    strcat(copia, nome2);
  } else {
    strcat(copia, nome1);
  }
  igualdade = strcmp(nome1, nome2);
  if (igualdade == 0) {
    printf("\nOs nomes inseridos sao iguais!\n");
  } else {
    printf("Os nomes inseridos sao diferentes!");
  }
  printf("\nOs nomes concatenados ficam: %s\n", copia);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1070 <gets@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x30(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%esi
mov    -0x98(%rbp),%edx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
jle    1215 <main+0xb5>
lea    -0x90(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1225 <main+0xc5>
lea    -0x90(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
jle    1261 <main+0x101>
lea    -0x90(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <strcat@plt>
jmp    1271 <main+0x111>
lea    -0x90(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
jne    12a4 <main+0x144>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12b2 <main+0x152>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xf30(%rip),%rdi
call   1040 <puts@plt>
lea    0x60(%rsp),%r14
mov    %r14,%rdi
call   1080 <gets@plt>
lea    0xf30(%rip),%rdi
call   1040 <puts@plt>
lea    0x30(%rsp),%r15
mov    %r15,%rdi
call   1080 <gets@plt>
lea    0xe4a(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xe2b(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %ebx,%ebp
mov    %r15,%rsi
cmovg  %r14,%rsi
mov    %r14,%rbx
cmovg  %r15,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xe4d(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123f <main+0xcf>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    124b <main+0xdb>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe40(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Digite o nome do aluno 1\0A\00"
@.str.1 = [26 x i8] c"Digite o nome do aluno 2\0A\00"
@.str.2 = [9 x i8] c"\0A\0A%s\0A%s\0A\00"
@.str.3 = [79 x i8] c"\0AO primeiro nome tem %d caracteres, enquanto que o segundo tem %d caracteres\0A\0A\00"
@.str.4 = [23 x i8] c"\0AO maior nome e o %s\0A\0A\00"
@.str.5 = [33 x i8] c"\0AOs nomes inseridos sao iguais!\0A\00"
@.str.6 = [35 x i8] c"Os nomes inseridos sao diferentes!\00"
@.str.7 = [34 x i8] c"\0AOs nomes concatenados ficam: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = alloca [40 x i8]
%4 = alloca [40 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%13 = call i32 @gets(i8* %12)
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %15)
%17 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %5
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %6
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %31
27: ; preds = %0
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%29 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%30 = call i32 @strcpy(i8* %28, i8* %29)
br label %35
31: ; preds = %0
%32 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%33 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %35
35: ; preds = %31, %27
%36 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%43 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%44 = call i32 @strcat(i8* %42, i8* %43)
br label %49
45: ; preds = %35
%46 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%47 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%48 = call i32 @strcat(i8* %46, i8* %47)
br label %49
49: ; preds = %45, %41
%50 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%51 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%52 = call i32 @strcmp(i8* %50, i8* %51)
store i32 %52, i32* %7
%53 = load i32, i32* %7
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %49
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %59
57: ; preds = %49
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %59
59: ; preds = %57, %55
%60 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %60)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c"\0A\0A%s\0A%s\0A\00"
@.str.3 = [79 x i8] c"\0AO primeiro nome tem %d caracteres, enquanto que o segundo tem %d caracteres\0A\0A\00"
@.str.4 = [23 x i8] c"\0AO maior nome e o %s\0A\0A\00"
@.str.6 = [35 x i8] c"Os nomes inseridos sao diferentes!\00"
@.str.7 = [34 x i8] c"\0AOs nomes concatenados ficam: %s\0A\00"
@str = [25 x i8] c"Digite o nome do aluno 1\00"
@str.8 = [25 x i8] c"Digite o nome do aluno 2\00"
@str.9 = [32 x i8] c"\0AOs nomes inseridos sao iguais!\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [40 x i8]
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.8, i64 0, i64 0))
%10 = call i32 @gets(i8* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %5)
%12 = call i32 @strlen(i8* %4)
%13 = call i32 @strlen(i8* %5)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %13)
%15 = icmp sgt i32 %12, %13
%16 = select i1 %15, i8* %4, i8* %5
%17 = select i1 %15, i8* %5, i8* %4
%18 = call i32 @strcpy(i8* %6, i8* %16)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%20 = call i32 @strcat(i8* %6, i8* %17)
%21 = call i32 @strcmp(i8* %4, i8* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
br label %27
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %6)
ret i32 0
}