#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char getc(int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *realloc(char *, int);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
void vazio(void) {
  char *str = malloc(1);
  char c;
  int i = 0;
  printf("Informe a string: ");
  do {
    c = getc(stdin);
    if (c != '\n') {
      str = realloc(str, i + 1);
      str[i++] = c;
    }
  } while (c != '\n');
  str[i] = '\0';
  if (strlen(str) == 0 || strcmp(str, "0") == 0) {
    printf("\7\a\nErro!\n");
    exit(EXIT_FAILURE);
  }
  printf("\nString: %s", str);
  free(str);
}


x86 assembly (clang, -O0):
<vazio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   10a0 <getc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     11f4 <vazio+0x74>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1080 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11f9 <vazio+0x79>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    11ab <vazio+0x2b>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
je     123f <vazio+0xbf>
mov    -0x8(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    125b <vazio+0xdb>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vazio>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe63(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e3a(%rip),%r12
mov    (%r12),%edi
call   10a0 <getc@plt>
cmp    $0xa,%al
je     11eb <vazio+0x6b>
mov    %eax,%ebx
xor    %r15d,%r15d
mov    %r15,%r13
add    $0x1,%r15
mov    %r14,%rdi
mov    %r15d,%esi
call   1080 <realloc@plt>
mov    %rax,%r14
mov    %bl,(%rax,%r13,1)
mov    (%r12),%edi
call   10a0 <getc@plt>
mov    %eax,%ebx
cmp    $0xa,%al
jne    11c0 <vazio+0x40>
mov    %r15d,%r15d
movb   $0x0,(%r14,%r15,1)
cmpb   $0x0,(%r14)
je     122c <vazio+0xac>
lea    0xe16(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     122c <vazio+0xac>
lea    0xe04(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    0xdee(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Informe a string: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [10 x i8] c"\07\07\0AErro!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"\0AString: %s\00"
define void @vazio() {
%1 = alloca i8*
%2 = alloca i8
%3 = alloca i32
%4 = call i8* @malloc(i32 1)
store i8* %4, i8** %1
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* @stdin
%8 = call signext i8 @getc(i32 %7)
store i8 %8, i8* %2
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %23
12: ; preds = %6
%13 = load i8*, i8** %1
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = call i8* @realloc(i8* %13, i32 %15)
store i8* %16, i8** %1
%17 = load i8, i8* %2
%18 = load i8*, i8** %1
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
store i8 %17, i8* %22
br label %23
23: ; preds = %12, %6
br label %24
24: ; preds = %23
%25 = load i8, i8* %2
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br i1 %27, label %6, label %28
28: ; preds = %24
%29 = load i8*, i8** %1
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
%33 = load i8*, i8** %1
%34 = call i64 @strlen(i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %28
%37 = load i8*, i8** %1
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36, %28
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %36
%45 = load i8*, i8** %1
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = load i8*, i8** %1
%48 = call i32 @free(i8* %47)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Informe a string: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"0\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"\0AString: %s\00"
@str = [9 x i8] c"\07\07\0AErro!\00"
define void @vazio() {
%1 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call signext i8 @getc(i32 %3)
%5 = icmp eq i8 %4, 10
br i1 %5, label %19, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %10, %6 ], [ 0, %0 ]
%8 = phi i8 [ %15, %6 ], [ %4, %0 ]
%9 = phi i8* [ %12, %6 ], [ %1, %0 ]
%10 = add nuw i64 %7, 1
%11 = trunc i64 %10 to i32
%12 = tail call i8* @realloc(i8* %9, i32 %11)
%13 = getelementptr inbounds i8, i8* %12, i64 %7
store i8 %8, i8* %13
%14 = load i32, i32* @stdin
%15 = tail call signext i8 @getc(i32 %14)
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %6
17: ; preds = %6
%18 = and i64 %10, 4294967295
br label %19
19: ; preds = %17, %0
%20 = phi i8* [ %1, %0 ], [ %12, %17 ]
%21 = phi i64 [ 0, %0 ], [ %18, %17 ]
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8 0, i8* %22
%23 = load i8, i8* %20
%24 = icmp eq i8 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25, %19
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%34 = tail call i32 @free(i8* %20)
ret void
}