#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 *, ...);
main() {
  int i = 0;
  char nome_completo[30], nome[16];
  printf("Entre com um nome (\"nome sobrenome\"): ");
  gets(nome_completo);
  while ((nome_completo[i] != ' ') && (nome_completo[i] != '\0')) {
    nome[i] = nome_completo[i];
    i++;
  }
  nome[i] = '\0';
  printf("\n%s", nome);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <gets@plt>
movslq -0x8(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x41(%rbp)
je     1176 <main+0x56>
movslq -0x8(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1186 <main+0x66>
jmp    11a4 <main+0x84>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x2d>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
call   1040 <gets@plt>
nop
movzbl 0x10(%rsp,%rbx,1),%eax
test   $0xdf,%al
je     1152 <main+0x32>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
jmp    1140 <main+0x20>
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xec8(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Entre com um nome (\22nome sobrenome\22): \00"
@.str.1 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [30 x i8]
%4 = alloca [16 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 32
br i1 %14, label %15, label %22
15: ; preds = %8
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br label %22
22: ; preds = %15, %8
%23 = phi i1 [ false, %8 ], [ %21, %15 ]
br i1 %23, label %24, label %34
24: ; preds = %22
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %30
store i8 %28, i8* %31
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %8
34: ; preds = %22
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %36
store i8 0, i8* %37
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [39 x i8] c"Entre com um nome (\22nome sobrenome\22): \00"
@.str.1 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
br label %7
7: ; preds = %11, %0
%8 = phi i64 [ %13, %11 ], [ 0, %0 ]
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 32, label %14
i8 0, label %14
]
11: ; preds = %7
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %8
store i8 %10, i8* %12
%13 = add nuw i64 %8, 1
br label %7
14: ; preds = %7, %7
%15 = and i64 %8, 4294967295
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}