#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*/ WriteToLog(char *);
int strlen(char *);
void SanitizeInput(char *inStr, char *outStr) {
  int idx = 0;
  WriteToLog("Sanitizing client input...");
  for (idx = 1; idx < strlen(inStr); idx++) {
    if (inStr[idx] == 10 && inStr[idx - 1] == 13) {
      outStr[idx - 1] = '\0';
      break;
    } else
      outStr[idx - 1] = inStr[idx - 1];
  }
  outStr[idx - 1] = '\0';
  WriteToLog("Sanitization complete...");
}


x86 assembly (clang, -O0):
<SanitizeInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec2(%rip),%rdi
call   1040 <WriteToLog@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11de <SanitizeInput+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11ab <SanitizeInput+0x8b>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    11ab <SanitizeInput+0x8b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11de <SanitizeInput+0xbe>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11d0 <SanitizeInput+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <SanitizeInput+0x2a>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe25(%rip),%rdi
call   1040 <WriteToLog@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SanitizeInput>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xece(%rip),%rdi
call   1040 <WriteToLog@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jl     117f <SanitizeInput+0x5f>
mov    $0x1,%ebx
jmp    1168 <SanitizeInput+0x48>
mov    %al,-0x1(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    117f <SanitizeInput+0x5f>
movzbl -0x1(%r15,%rbx,1),%eax
cmpb   $0xa,(%r15,%rbx,1)
jne    1150 <SanitizeInput+0x30>
cmp    $0xd,%al
jne    1150 <SanitizeInput+0x30>
movb   $0x0,-0x1(%r14,%rbx,1)
add    $0xffffffff,%ebx
movslq %ebx,%rax
movb   $0x0,(%r14,%rax,1)
lea    0xe8a(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <WriteToLog@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Sanitizing client input...\00"
@.str.1 = [25 x i8] c"Sanitization complete...\00"
define void @SanitizeInput(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = call i32 @WriteToLog(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %7
7: ; preds = %48, %2
%8 = load i32, i32* %5
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %51
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %35
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 13
br i1 %28, label %29, label %35
29: ; preds = %20
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
store i8 0, i8* %34
br label %51
35: ; preds = %20, %12
%36 = load i8*, i8** %3
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i8, i8* %40
%42 = load i8*, i8** %4
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %42, i64 %45
store i8 %41, i8* %46
br label %47
47: ; preds = %35
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %7
51: ; preds = %29, %7
%52 = load i8*, i8** %4
%53 = load i32, i32* %5
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
store i8 0, i8* %56
%57 = call i32 @WriteToLog(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Sanitizing client input...\00"
@.str.1 = [25 x i8] c"Sanitization complete...\00"
define void @SanitizeInput(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @WriteToLog(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %23
6: ; preds = %2, %18
%7 = phi i64 [ %19, %18 ], [ 1, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 10
%11 = add nsw i64 %7, -1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 13
%15 = select i1 %10, i1 %14, i1 false
%16 = getelementptr inbounds i8, i8* %1, i64 %11
br i1 %15, label %17, label %18
17: ; preds = %6
store i8 0, i8* %16
br label %23
18: ; preds = %6
store i8 %13, i8* %16
%19 = add nuw nsw i64 %7, 1
%20 = tail call i32 @strlen(i8* %0)
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %6, label %23
23: ; preds = %18, %2, %17
%24 = phi i64 [ %7, %17 ], [ 1, %2 ], [ %19, %18 ]
%25 = shl i64 %24, 32
%26 = add i64 %25, -4294967296
%27 = ashr exact i64 %26, 32
%28 = getelementptr inbounds i8, i8* %1, i64 %27
store i8 0, i8* %28
%29 = tail call i32 @WriteToLog(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
ret void
}