#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 *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void ex1() {
  char *name = malloc(100 / 2), *lastname = malloc(100 / 2);
  printf("Digite seu nome: ");
  charIn(name, 100 / 2);
  name[strlen(name)] = ' ';
  name[strlen(name) + 1] = '\0';
  printf("Digite seu sobrenome: ");
  charIn(lastname, 100 / 2);
  strcat(name, lastname);
  printf("%s", name);
}


x86 assembly (clang, -O0):
<ex1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x32,%esi
call   1040 <charIn@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
call   1040 <charIn@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex1>:
push   %r14
push   %rbx
push   %rax
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1040 <charIn@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x20,(%rbx,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,0x1(%rax,%rbx,1)
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x32,%esi
call   1040 <charIn@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Digite seu nome: \00"
@.str.1 = [23 x i8] c"Digite seu sobrenome: \00"
@.str.2 = [3 x i8] c"%s\00"
define void @ex1() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @malloc(i32 50)
store i8* %3, i8** %1
%4 = call i8* @malloc(i32 50)
store i8* %4, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = call i32 @charIn(i8* %6, i32 50)
%8 = load i8*, i8** %1
%9 = load i8*, i8** %1
%10 = call i32 @strlen(i8* %9)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
store i8 32, i8* %12
%13 = load i8*, i8** %1
%14 = load i8*, i8** %1
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
store i8 0, i8* %18
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = call i32 @charIn(i8* %20, i32 50)
%22 = load i8*, i8** %1
%23 = load i8*, i8** %2
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = load i8*, i8** %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Digite seu nome: \00"
@.str.1 = [23 x i8] c"Digite seu sobrenome: \00"
@.str.2 = [3 x i8] c"%s\00"
define void @ex1() {
%1 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%2 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @charIn(i8* %1, i32 50)
%5 = tail call i32 @strlen(i8* %1)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 32, i8* %7
%8 = tail call i32 @strlen(i8* %1)
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 0, i8* %11
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @charIn(i8* %2, i32 50)
%14 = tail call i32 @strcat(i8* %1, i8* %2)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret void
}