#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*/ checkPTRALLOC(void **);
char *correct(char *, int *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int correctInput(char **in, int *understoodPercent, int numwords) {
  int understood = 100, likeness, i;
  char *corrected_word;
  for (i = 0; i < numwords; i++) {
    likeness = 0;
    corrected_word = correct(in[i], &likeness);
    if (corrected_word == NULL) {
      return 0;
    }
    free(in[i]);
    in[i] = malloc((1 + strlen(corrected_word)) * sizeof(char));
    checkPTRALLOC((void **)&in[i]);
    strcpy(in[i], corrected_word);
    free(corrected_word);
    understood -= (100 - likeness) / numwords;
  }
  *understoodPercent = understood;
  return 1;
}


x86 assembly (clang, -O0):
<correctInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x64,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1253 <correctInput+0xf3>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x24(%rbp),%rsi
call   1080 <correct@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c4 <correctInput+0x64>
movl   $0x0,-0x4(%rbp)
jmp    1263 <correctInput+0x103>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rdi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1060 <checkPTRALLOC@plt>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    $0x64,%eax
sub    -0x24(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1181 <correctInput+0x21>
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<correctInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
mov    %rsi,0x10(%rsp)
jle    11fd <correctInput+0x9d>
mov    %edx,%r12d
mov    %rdi,%rbx
mov    %edx,%r14d
mov    $0x64,%r13d
lea    0xc(%rsp),%r15
nop
movl   $0x0,0xc(%rsp)
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1080 <correct@plt>
test   %rax,%rax
je     1212 <correctInput+0xb2>
mov    %rax,%rbp
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,(%rbx)
mov    %rbx,%rdi
call   1060 <checkPTRALLOC@plt>
mov    (%rbx),%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x64,%eax
sub    0xc(%rsp),%eax
cltd
idiv   %r12d
sub    %eax,%r13d
add    $0x8,%rbx
add    $0xffffffffffffffff,%r14
jne    1190 <correctInput+0x30>
jmp    1203 <correctInput+0xa3>
mov    $0x64,%r13d
mov    0x10(%rsp),%rax
mov    %r13d,(%rax)
mov    $0x1,%eax
jmp    1214 <correctInput+0xb4>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @correctInput(i8** %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8** %0, i8*** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 100, i32* %8
store i32 0, i32* %10
br label %12
12: ; preds = %64, %3
%13 = load i32, i32* %10
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %67
16: ; preds = %12
store i32 0, i32* %9
%17 = load i8**, i8*** %5
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i8* @correct(i8* %21, i32* %9)
store i8* %22, i8** %11
%23 = load i8*, i8** %11
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %16
store i32 0, i32* %4
br label %70
26: ; preds = %16
%27 = load i8**, i8*** %5
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @free(i8* %31)
%33 = load i8*, i8** %11
%34 = call i32 @strlen(i8* %33)
%35 = add nsw i32 1, %34
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 1
%38 = trunc i64 %37 to i32
%39 = call i8* @malloc(i32 %38)
%40 = load i8**, i8*** %5
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
store i8* %39, i8** %43
%44 = load i8**, i8*** %5
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = call i32 @checkPTRALLOC(i8** %47)
%49 = load i8**, i8*** %5
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = load i8*, i8** %11
%55 = call i32 @strcpy(i8* %53, i8* %54)
%56 = load i8*, i8** %11
%57 = call i32 @free(i8* %56)
%58 = load i32, i32* %9
%59 = sub nsw i32 100, %58
%60 = load i32, i32* %7
%61 = sdiv i32 %59, %60
%62 = load i32, i32* %8
%63 = sub nsw i32 %62, %61
store i32 %63, i32* %8
br label %64
64: ; preds = %26
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %12
67: ; preds = %12
%68 = load i32, i32* %8
%69 = load i32*, i32** %6
store i32 %68, i32* %69
store i32 1, i32* %4
br label %70
70: ; preds = %67, %25
%71 = load i32, i32* %4
ret i32 %71
}

LLVM IR (-O2):
define i32 @correctInput(i8** %0, i32* nocapture writeonly %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %32
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %16
%10 = phi i64 [ 0, %7 ], [ %30, %16 ]
%11 = phi i32 [ 100, %7 ], [ %29, %16 ]
store i32 0, i32* %4
%12 = getelementptr inbounds i8*, i8** %0, i64 %10
%13 = load i8*, i8** %12
%14 = call i8* @correct(i8* %13, i32* %4)
%15 = icmp eq i8* %14, null
br i1 %15, label %34, label %16
16: ; preds = %9
%17 = load i8*, i8** %12
%18 = call i32 @free(i8* %17)
%19 = call i32 @strlen(i8* %14)
%20 = add nsw i32 %19, 1
%21 = call i8* @malloc(i32 %20)
store i8* %21, i8** %12
%22 = call i32 @checkPTRALLOC(i8** %12)
%23 = load i8*, i8** %12
%24 = call i32 @strcpy(i8* %23, i8* %14)
%25 = call i32 @free(i8* %14)
%26 = load i32, i32* %4
%27 = sub nsw i32 100, %26
%28 = sdiv i32 %27, %2
%29 = sub nsw i32 %11, %28
%30 = add nuw nsw i64 %10, 1
%31 = icmp eq i64 %30, %8
br i1 %31, label %32, label %9
32: ; preds = %16, %3
%33 = phi i32 [ 100, %3 ], [ %29, %16 ]
store i32 %33, i32* %1
br label %34
34: ; preds = %9, %32
%35 = phi i32 [ 1, %32 ], [ 0, %9 ]
ret i32 %35
}