#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*/ erase(int, char *);
int find(char, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ removeZero(char *);
int /*<<< orphan*/ scanf(char *, char *, char *);
scalar_t__ stringcompare(char *, char *);
int main() {
  char digito;
  char *numero = malloc(sizeof(char) * 1001);
  int posicao;
  scanf(" %c %s", &digito, numero);
  while (digito != '0' && stringcompare(numero, "0")) {
    posicao = find(digito, numero);
    while (posicao != -1) {
      erase(posicao, numero);
      posicao = find(digito, numero);
    }
    removeZero(numero);
    printf("%s\n", numero);
    scanf(" %c %s", &digito, numero);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3e9,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe68(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1080 <scanf@plt>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x15(%rbp)
je     11cd <main+0x5d>
mov    -0x10(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1090 <stringcompare@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11dd <main+0x6d>
jmp    124e <main+0xde>
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1060 <find@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     121c <main+0xac>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <erase@plt>
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1060 <find@plt>
mov    %eax,-0x14(%rbp)
jmp    11ef <main+0x7f>
mov    -0x10(%rbp),%rdi
call   1050 <removeZero@plt>
mov    -0x10(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdx
lea    0xdc0(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1080 <scanf@plt>
jmp    11a1 <main+0x31>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x3e9,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rdi
lea    0xf(%rsp),%rsi
mov    %rax,%rdx
call   1080 <scanf@plt>
cmpb   $0x30,0xf(%rsp)
jne    11b5 <main+0x45>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe4b(%rip),%r14
lea    0xe46(%rip),%r15
lea    0xe36(%rip),%r12
lea    0xf(%rsp),%r13
jmp    1208 <main+0x98>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <removeZero@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1080 <scanf@plt>
cmpb   $0x30,0xf(%rsp)
je     11a5 <main+0x35>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <stringcompare@plt>
test   %rax,%rax
je     11a5 <main+0x35>
nopl   0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%edi
mov    %rbx,%rsi
call   1060 <find@plt>
cmp    $0xffffffff,%eax
je     11e0 <main+0x70>
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <erase@plt>
jmp    1220 <main+0xb0>

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

LLVM IR (-O2):
@.str = [7 x i8] c" %c %s\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call dereferenceable_or_null(1001) i8* @malloc(i32 1001)
%3 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 48
br i1 %5, label %25, label %6
6: ; preds = %0, %19
%7 = call i64 @stringcompare(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = load i8, i8* %1
%11 = call i32 @find(i8 signext %10, i8* %2)
%12 = icmp eq i32 %11, -1
br i1 %12, label %19, label %13
13: ; preds = %9, %13
%14 = phi i32 [ %17, %13 ], [ %11, %9 ]
%15 = call i32 @erase(i32 %14, i8* %2)
%16 = load i8, i8* %1
%17 = call i32 @find(i8 signext %16, i8* %2)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %13
19: ; preds = %13, %9
%20 = call i32 @removeZero(i8* %2)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%22 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%23 = load i8, i8* %1
%24 = icmp eq i8 %23, 48
br i1 %24, label %25, label %6
25: ; preds = %6, %19, %0
ret i32 0
}