#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*/ scanf(char *, char *);
main() {
  char nome_c[30], nome[15], sobre[25];
  int i, j;
  printf("Entre com um nome e sobrenome: ");
  scanf("%s", nome);
  gets(nome_c);
  i = j = 0;
  while (nome_c[i] != ' ') {
    i++;
  }
  while (nome_c[i + 1] != '\0') {
    sobre[j] = nome_c[i + 1];
    i++;
    j++;
  }
  sobre[j] = '\0';
  printf("\n%s, %s", sobre, nome);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x3f(%rbp),%rsi
lea    0xecd(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
movslq -0x64(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x20,%eax
je     1194 <main+0x64>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1174 <main+0x44>
jmp    1199 <main+0x69>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11da <main+0xaa>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
movslq -0x68(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1199 <main+0x69>
movslq -0x68(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    -0x3f(%rbp),%rdx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xec4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x21(%rsp),%rsi
call   1050 <scanf@plt>
mov    %rsp,%rdi
call   1040 <gets@plt>
xchg   %ax,%ax
cmpb   $0x20,(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1160 <main+0x30>
mov    %ebx,%eax
mov    (%rsp,%rax,1),%al
test   %al,%al
je     11a4 <main+0x74>
add    $0xffffffffffffffff,%rbx
mov    %ebx,%ecx
lea    (%rsp,%rcx,1),%rdx
add    $0x2,%rdx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,0x30(%rsp,%rcx,1)
movzbl (%rdx,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1190 <main+0x60>
mov    %ecx,%eax
jmp    11a6 <main+0x76>
xor    %eax,%eax
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xe6e(%rip),%rdi
lea    0x30(%rsp),%rsi
lea    0x21(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [32 x i8] c"Entre com um nome e sobrenome: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [8 x i8] c"\0A%s, %s\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [15 x i8]
%3 = alloca [25 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 @gets(i8* %4)
br label %10
10: ; preds = %10, %0
%11 = phi i64 [ %15, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
%15 = add nuw i64 %11, 1
br i1 %14, label %16, label %10
16: ; preds = %10
%17 = add i64 %11, 1
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %37, label %22
22: ; preds = %16
%23 = and i64 %11, 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 [25 x i8], [25 x i8]* %3, i64 0, i64 %26
store i8 %28, i8* %29
%30 = add nuw i64 %26, 1
%31 = add nuw i64 %27, 1
%32 = getelementptr inbounds [30 x i8], [30 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 %30, 4294967295
br label %37
37: ; preds = %35, %16
%38 = phi i64 [ 0, %16 ], [ %36, %35 ]
%39 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 %38
store i8 0, i8* %39
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %5)
ret i32 0
}