#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 */
char *bubblesort(char *, int);
scalar_t__ control_saved(char *, int, int, char);
int /*<<< orphan*/ errPointer(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, char *);
char *malloc(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *delalpha(char *del, int dim, int *dim_tmp) {
  int i = 0, pos = 0, dimsaved = 0;
  char *saved = NULL, trash;
  fprintf(stdout, "Insert characters you want to delete.\n"
                  "Insert '0' (zero) to end.\n\n");
  del = malloc(dim * sizeof(char));
  if (del == NULL)
    errPointer(-11);
  saved = malloc(dim * sizeof(char));
  if (saved == NULL)
    errPointer(-22);
  for (i = 0; i < dim; i++) {
    fprintf(stdout, "Insert characters %d: ", i + 1);
    fscanf(stdin, "%1s", &trash);
    if (trash == '0') {
      (*dim_tmp) = i;
      break;
    } else {
      if (control_saved(saved, dimsaved, pos, trash)) {
        del[pos] = trash;
        pos++;
        dimsaved++;
      } else
        fprintf(stdout, "Characters %c just removed.\n", trash);
    }
  }
  del = bubblesort(del, (*dim_tmp));
  free(saved);
  return del;
}


x86 assembly (clang, -O0):
<delalpha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11df <delalpha+0x6f>
mov    $0xfffffff5,%edi
call   1090 <errPointer@plt>
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1207 <delalpha+0x97>
mov    $0xffffffea,%edi
call   1090 <errPointer@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12e0 <delalpha+0x170>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
lea    -0x31(%rbp),%rdx
call   1050 <fscanf@plt>
movsbl -0x31(%rbp),%eax
cmp    $0x30,%eax
jne    126b <delalpha+0xfb>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12e0 <delalpha+0x170>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
movsbl -0x31(%rbp),%ecx
call   1040 <control_saved@plt>
cmp    $0x0,%rax
je     12ad <delalpha+0x13d>
mov    -0x31(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12c8 <delalpha+0x158>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
movsbl -0x31(%rbp),%edx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12cd <delalpha+0x15d>
jmp    12d2 <delalpha+0x162>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120e <delalpha+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1080 <bubblesort@plt>
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delalpha>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x8(%rsp)
mov    %esi,%ebp
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
jne    11b7 <delalpha+0x47>
mov    $0xfffffff5,%edi
call   1090 <errPointer@plt>
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d0 <delalpha+0x60>
mov    $0xffffffea,%edi
call   1090 <errPointer@plt>
test   %ebp,%ebp
jle    128d <delalpha+0x11d>
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    1214 <delalpha+0xa4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
movsbl 0x7(%rsp),%edx
lea    0xe58(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14d,%r15d
cmp    %r14d,%ebp
je     128d <delalpha+0x11d>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0x1(%r15),%r14d
lea    0xe1a(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
lea    0x7(%rsp),%rdx
call   1050 <fscanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0x30,%al
je     1285 <delalpha+0x115>
movsbl %al,%ecx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
call   1040 <control_saved@plt>
test   %rax,%rax
je     11f0 <delalpha+0x80>
movzbl 0x7(%rsp),%eax
movslq %r13d,%rcx
mov    0x10(%rsp),%rdx
mov    %al,(%rdx,%rcx,1)
add    $0x1,%r13d
add    $0x1,%r12d
jmp    120c <delalpha+0x9c>
mov    0x8(%rsp),%rax
mov    %r15d,(%rax)
mov    0x8(%rsp),%rax
mov    (%rax),%esi
mov    0x10(%rsp),%rdi
call   1080 <bubblesort@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [66 x i8] c"Insert characters you want to delete.\0AInsert '0' (zero) to end.\0A\0A\00"
@.str.1 = [23 x i8] c"Insert characters %d: \00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%1s\00"
@.str.3 = [29 x i8] c"Characters %c just removed.\0A\00"
define i8* @delalpha(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
%12 = load i32, i32* @stdout
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = call i32 @errPointer(i32 -11)
br label %23
23: ; preds = %21, %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 1
%27 = trunc i64 %26 to i32
%28 = call i8* @malloc(i32 %27)
store i8* %28, i8** %10
%29 = load i8*, i8** %10
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 @errPointer(i32 -22)
br label %33
33: ; preds = %31, %23
store i32 0, i32* %7
br label %34
34: ; preds = %75, %33
%35 = load i32, i32* %7
%36 = load i32, i32* %5
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %78
38: ; preds = %34
%39 = load i32, i32* @stdout
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = load i32, i32* @stdin
%44 = call i32 @fscanf(i32 %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%45 = load i8, i8* %11
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 48
br i1 %47, label %48, label %51
48: ; preds = %38
%49 = load i32, i32* %7
%50 = load i32*, i32** %6
store i32 %49, i32* %50
br label %78
51: ; preds = %38
%52 = load i8*, i8** %10
%53 = load i32, i32* %9
%54 = load i32, i32* %8
%55 = load i8, i8* %11
%56 = call i64 @control_saved(i8* %52, i32 %53, i32 %54, i8 signext %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %68
58: ; preds = %51
%59 = load i8, i8* %11
%60 = load i8*, i8** %4
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 %59, i8* %63
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %73
68: ; preds = %51
%69 = load i32, i32* @stdout
%70 = load i8, i8* %11
%71 = sext i8 %70 to i32
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %68, %58
br label %74
74: ; preds = %73
br label %75
75: ; preds = %74
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %34
78: ; preds = %48, %34
%79 = load i8*, i8** %4
%80 = load i32*, i32** %6
%81 = load i32, i32* %80
%82 = call i8* @bubblesort(i8* %79, i32 %81)
store i8* %82, i8** %4
%83 = load i8*, i8** %10
%84 = call i32 @free(i8* %83)
%85 = load i8*, i8** %4
ret i8* %85
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [66 x i8] c"Insert characters you want to delete.\0AInsert '0' (zero) to end.\0A\0A\00"
@.str.1 = [23 x i8] c"Insert characters %d: \00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%1s\00"
@.str.3 = [29 x i8] c"Characters %c just removed.\0A\00"
define i8* @delalpha(i8* nocapture readnone %0, i32 %1, i32* nocapture %2) {
%4 = alloca i8
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @malloc(i32 %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @errPointer(i32 -11)
br label %11
11: ; preds = %9, %3
%12 = tail call i8* @malloc(i32 %1)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @errPointer(i32 -22)
br label %16
16: ; preds = %14, %11
%17 = icmp sgt i32 %1, 0
br i1 %17, label %18, label %48
18: ; preds = %16, %44
%19 = phi i32 [ %46, %44 ], [ 0, %16 ]
%20 = phi i32 [ %45, %44 ], [ 0, %16 ]
%21 = phi i32 [ %23, %44 ], [ 0, %16 ]
%22 = load i32, i32* @stdout
%23 = add nuw nsw i32 %21, 1
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @stdin
%26 = call i32 @fscanf(i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%27 = load i8, i8* %4
%28 = icmp eq i8 %27, 48
br i1 %28, label %29, label %30
29: ; preds = %18
store i32 %21, i32* %2
br label %48
30: ; preds = %18
%31 = call i64 @control_saved(i8* %12, i32 %19, i32 %20, i8 signext %27)
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load i8, i8* %4
%35 = sext i32 %20 to i64
%36 = getelementptr inbounds i8, i8* %7, i64 %35
store i8 %34, i8* %36
%37 = add nsw i32 %20, 1
%38 = add nsw i32 %19, 1
br label %44
39: ; preds = %30
%40 = load i32, i32* @stdout
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %39, %33
%45 = phi i32 [ %37, %33 ], [ %20, %39 ]
%46 = phi i32 [ %38, %33 ], [ %19, %39 ]
%47 = icmp eq i32 %23, %1
br i1 %47, label %48, label %18
48: ; preds = %44, %16, %29
%49 = load i32, i32* %2
%50 = call i8* @bubblesort(i8* %7, i32 %49)
%51 = call i32 @free(i8* %12)
ret i8* %50
}