#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 EXIT_SUCCESS;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
char *quebrar(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char s1[20];
  char *s2;
  int n1, tam;
  printf("\nDigite a palavra: ");
  fflush(stdin);
  gets(s1);
  printf("\nNumero para retirada do prefixo: ");
  scanf("%d", &n1);
  tam = strlen(s1);
  if (n1 > tam) {
    printf("\nA palavra é menor que o tamanho desejado!");
    return (EXIT_SUCCESS);
  }
  s2 = quebrar(s1, n1);
  printf("\n%s", s1);
  printf("\n%s", s2);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x20(%rbp),%rdi
call   1060 <gets@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1080 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    11e9 <main+0x89>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1229 <main+0xc9>
lea    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <quebrar@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe90(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0xc(%rsp),%esi
cmp    %eax,%esi
jle    11d1 <main+0x71>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1202 <main+0xa2>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <quebrar@plt>
mov    %rax,%rbx
lea    0xe7e(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0ADigite a palavra: \00"
@stdin = global i32 0
@.str.1 = [35 x i8] c"\0ANumero para retirada do prefixo: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [44 x i8] c"\0AA palavra \C3\A9 menor que o tamanho desejado!\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fflush(i32 %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @EXIT_SUCCESS
store i32 %20, i32* %1
br label %30
21: ; preds = %0
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%23 = load i32, i32* %4
%24 = call i8* @quebrar(i8* %22, i32 %23)
store i8* %24, i8** %3
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @EXIT_SUCCESS
store i32 %29, i32* %1
br label %30
30: ; preds = %21, %18
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0ADigite a palavra: \00"
@stdin = global i32 0
@.str.1 = [35 x i8] c"\0ANumero para retirada do prefixo: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [44 x i8] c"\0AA palavra \C3\A9 menor que o tamanho desejado!\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [4 x i8] c"\0A%s\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = tail call i32 @fflush(i32 %6)
%8 = call i32 @gets(i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%11 = call i32 @strlen(i8* %3)
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %20
16: ; preds = %0
%17 = call i8* @quebrar(i8* %3, i32 %12)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %17)
br label %20
20: ; preds = %16, %14
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}