#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 *, char *, char *);
int /*<<< orphan*/ puts(char *);
main() {
  char nome_completo[100];
  char nome[50];
  char sobrenome[50];
  int i = 0, j = 0;
  puts("Por favor, digite nome e sobrenome: ");
  gets(nome_completo);
  while ((nome_completo[i] != ' ') && (nome_completo[i] != '\0')) {
    nome[i] = nome_completo[i];
    i++;
  }
  i++;
  while (nome_completo[i] != '\0') {
    sobrenome[j] = nome_completo[i];
    j++;
    i++;
  }
  nome[i] = '\0';
  sobrenome[j] = '\0';
  printf("%s, %s", sobrenome, nome);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
movslq -0xf4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0xf9(%rbp)
je     11a0 <main+0x70>
movslq -0xf4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xf9(%rbp)
mov    -0xf9(%rbp),%al
test   $0x1,%al
jne    11b3 <main+0x83>
jmp    11e0 <main+0xb0>
movslq -0xf4(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0xf4(%rbp),%rax
mov    %cl,-0xb0(%rbp,%rax,1)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    116b <main+0x3b>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
movslq -0xf4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1240 <main+0x110>
movslq -0xf4(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0xf8(%rbp),%rax
mov    %cl,-0xf0(%rbp,%rax,1)
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11ef <main+0xbf>
movslq -0xf4(%rbp),%rax
movb   $0x0,-0xb0(%rbp,%rax,1)
movslq -0xf8(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
lea    -0xf0(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
lea    0xdb2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xe8,%rsp
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0x80(%rsp),%rdi
call   1050 <gets@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x80(%rsp,%rax,1),%ecx
test   $0xdf,%cl
je     1177 <main+0x47>
mov    %cl,0x40(%rsp,%rax,1)
add    $0x1,%rax
jmp    1160 <main+0x30>
lea    0x1(%rax),%esi
mov    0x80(%rsp,%rsi,1),%dl
test   %dl,%dl
je     11b9 <main+0x89>
mov    %eax,%ecx
lea    (%rsp,%rcx,1),%rsi
add    $0x82,%rsi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %dl,(%rsp,%rcx,1)
movzbl (%rsi,%rcx,1),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    11a0 <main+0x70>
lea    (%rax,%rcx,1),%esi
add    $0x1,%esi
mov    %ecx,%eax
jmp    11bb <main+0x8b>
xor    %eax,%eax
movb   $0x0,0x40(%rsp,%rsi,1)
movb   $0x0,(%rsp,%rax,1)
lea    0xe5a(%rip),%rdi
mov    %rsp,%rsi
lea    0x40(%rsp),%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe8,%rsp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Por favor, digite nome e sobrenome: \00"
@.str.1 = [7 x i8] c"%s, %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
br label %10
10: ; preds = %26, %0
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 32
br i1 %16, label %17, label %24
17: ; preds = %10
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br label %24
24: ; preds = %17, %10
%25 = phi i1 [ false, %10 ], [ %23, %17 ]
br i1 %25, label %26, label %36
26: ; preds = %24
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %32
store i8 %30, i8* %33
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %10
36: ; preds = %24
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %39
39: ; preds = %46, %36
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %58
46: ; preds = %39
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %52
store i8 %50, i8* %53
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %39
58: ; preds = %39
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %60
store i8 0, i8* %61
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %63
store i8 0, i8* %64
%65 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%66 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%67 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %65, i8* %66)
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@.str = [37 x i8] c"Por favor, digite nome e sobrenome: \00"
@.str.1 = [7 x i8] c"%s, %s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
br label %9
9: ; preds = %13, %0
%10 = phi i64 [ %15, %13 ], [ 0, %0 ]
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 32, label %16
i8 0, label %16
]
13: ; preds = %9
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %10
store i8 %12, i8* %14
%15 = add nuw i64 %10, 1
br label %9
16: ; preds = %9, %9
%17 = add i64 %10, 1
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %38, label %22
22: ; preds = %16
%23 = and i64 %10, 4294967295
%24 = add nuw nsw i64 %23, 1
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 0, %22 ], [ %30, %25 ]
%27 = phi i64 [ %24, %22 ], [ %31, %25 ]
%28 = phi i8 [ %20, %22 ], [ %33, %25 ]
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %26
store i8 %28, i8* %29
%30 = add nuw i64 %26, 1
%31 = add nuw nsw i64 %27, 1
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %25
35: ; preds = %25
%36 = and i64 %31, 4294967295
%37 = and i64 %30, 4294967295
br label %38
38: ; preds = %35, %16
%39 = phi i64 [ %36, %35 ], [ %18, %16 ]
%40 = phi i64 [ %37, %35 ], [ 0, %16 ]
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %39
store i8 0, i8* %41
%42 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %40
store i8 0, i8* %42
%43 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %5)
ret i32 0
}