#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*/ strcpy(char *, char *);
char *strstr(char *, char *);
int request_remove(char *buffer, short int *id_app, char *spec, char *option) {
  char *pch;
  if (buffer[0] != 1)
    return -1;
  *id_app = buffer[6];
  *id_app <<= 8;
  *id_app += buffer[7];
  buffer += 10;
  pch = strstr(buffer, "\r\n");
  *pch = '\0';
  strcpy(spec, buffer);
  buffer = pch + 2;
  pch = strstr(buffer, "\r\n");
  *pch = '\0';
  strcpy(option, buffer);
  return 0;
}


x86 assembly (clang, -O0):
<request_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1,%eax
je     1154 <request_remove+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f6 <request_remove+0xd6>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
mov    -0x18(%rbp),%rax
movswl (%rax),%ecx
shl    $0x8,%ecx
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%edx
mov    -0x18(%rbp),%rax
movswl (%rax),%ecx
add    %edx,%ecx
mov    %cx,(%rax)
mov    -0x10(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<request_remove>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0xffffffff,%eax
cmpb   $0x1,(%rdi)
jne    1195 <request_remove+0x75>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
movzbl 0x6(%rdi),%eax
shl    $0x8,%eax
mov    %ax,(%rsi)
movsbl 0x7(%rdi),%ecx
add    %eax,%ecx
mov    %cx,(%rsi)
add    $0xa,%rbx
lea    0xea6(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strstr@plt>
mov    %rax,%r13
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x2,%r13
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strstr@plt>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
define i32 @request_remove(i8* %0, i16* nocapture writeonly %1, i8* %2, i8* %3) {
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 1
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 6
%9 = load i8, i8* %8
%10 = zext i8 %9 to i16
%11 = shl nuw i16 %10, 8
store i16 %11, i16* %1
%12 = getelementptr inbounds i8, i8* %0, i64 7
%13 = load i8, i8* %12
%14 = sext i8 %13 to i16
%15 = add i16 %11, %14
store i16 %15, i16* %1
%16 = getelementptr inbounds i8, i8* %0, i64 10
%17 = tail call i8* @strstr(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %17
%18 = tail call i32 @strcpy(i8* %2, i8* %16)
%19 = getelementptr inbounds i8, i8* %17, i64 2
%20 = tail call i8* @strstr(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %20
%21 = tail call i32 @strcpy(i8* %3, i8* %19)
br label %22
22: ; preds = %4, %7
%23 = phi i32 [ 0, %7 ], [ -1, %4 ]
ret i32 %23
}