#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*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ recv(int, unsigned char *, int, int /*<<< orphan*/);
unsigned char toupper(unsigned char);
unsigned char *getCommand(int fd, unsigned char (*req)[256],
                          unsigned char (*tmpReq)[256]) {
  unsigned int i, u;
  memset(*req, 0, sizeof(*req));
  memset(*tmpReq, 0, sizeof(*tmpReq));
  recv(fd, *tmpReq, sizeof(*tmpReq), 0);
  u = 0;
  for (i = 0; (*tmpReq)[i]; i++) {
    if (((*tmpReq)[i] != 10) && ((*tmpReq)[i] != 13)) {
      (*req)[u] = toupper((*tmpReq)[i]);
      u++;
    }
  }
  return *req;
}


x86 assembly (clang, -O0):
<getCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
cmpb   $0x0,(%rax,%rcx,1)
je     11f5 <getCommand+0xc5>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11e2 <getCommand+0xb2>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
je     11e2 <getCommand+0xb2>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e7 <getCommand+0xb7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1184 <getCommand+0x54>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCommand>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%r15d
xor    %ebp,%ebp
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
xor    %ebx,%ebx
jmp    1183 <getCommand+0x53>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %ebp,%eax
movzbl (%r12,%rax,1),%eax
cmp    $0xa,%al
je     1180 <getCommand+0x50>
cmp    $0xd,%al
je     1180 <getCommand+0x50>
test   %al,%al
je     11a9 <getCommand+0x79>
movzbl %al,%edi
call   1040 <toupper@plt>
mov    %ebx,%ecx
mov    %al,(%r14,%rcx,1)
add    $0x1,%ebx
jmp    1180 <getCommand+0x50>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @getCommand(i32 %0, [256 x i8]* %1, [256 x i8]* %2) {
%4 = alloca i32
%5 = alloca [256 x i8]*
%6 = alloca [256 x i8]*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store [256 x i8]* %1, [256 x i8]** %5
store [256 x i8]* %2, [256 x i8]** %6
%9 = load [256 x i8]*, [256 x i8]** %5
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 256)
%12 = load [256 x i8]*, [256 x i8]** %6
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 256)
%15 = load i32, i32* %4
%16 = load [256 x i8]*, [256 x i8]** %6
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%18 = call i32 @recv(i32 %15, i8* %17, i32 256, i32 0)
store i32 0, i32* %8
store i32 0, i32* %7
br label %19
19: ; preds = %56, %3
%20 = load [256 x i8]*, [256 x i8]** %6
%21 = load i32, i32* %7
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
br i1 %25, label %26, label %59
26: ; preds = %19
%27 = load [256 x i8]*, [256 x i8]** %6
%28 = load i32, i32* %7
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %27, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %55
34: ; preds = %26
%35 = load [256 x i8]*, [256 x i8]** %6
%36 = load i32, i32* %7
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %35, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = icmp ne i32 %40, 13
br i1 %41, label %42, label %55
42: ; preds = %34
%43 = load [256 x i8]*, [256 x i8]** %6
%44 = load i32, i32* %7
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %43, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = call zeroext i8 @toupper(i8 zeroext %47)
%49 = load [256 x i8]*, [256 x i8]** %5
%50 = load i32, i32* %8
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %49, i64 0, i64 %51
store i8 %48, i8* %52
%53 = load i32, i32* %8
%54 = add i32 %53, 1
store i32 %54, i32* %8
br label %55
55: ; preds = %42, %34, %26
br label %56
56: ; preds = %55
%57 = load i32, i32* %7
%58 = add i32 %57, 1
store i32 %58, i32* %7
br label %19
59: ; preds = %19
%60 = load [256 x i8]*, [256 x i8]** %5
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %60, i64 0, i64 0
ret i8* %61
}

LLVM IR (-O2):
define i8* @getCommand(i32 %0, [256 x i8]* %1, [256 x i8]* %2) {
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = tail call i32 @memset(i8* %4, i32 0, i32 256)
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = tail call i32 @memset(i8* %6, i32 0, i32 256)
%8 = tail call i32 @recv(i32 %0, i8* %6, i32 256, i32 0)
br label %9
9: ; preds = %20, %3
%10 = phi i32 [ 0, %3 ], [ %22, %20 ]
%11 = phi i32 [ 0, %3 ], [ %21, %20 ]
%12 = zext i32 %10 to i64
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %15 [
i8 0, label %23
i8 10, label %20
i8 13, label %20
]
15: ; preds = %9
%16 = tail call zeroext i8 @toupper(i8 zeroext %14)
%17 = zext i32 %11 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %17
store i8 %16, i8* %18
%19 = add i32 %11, 1
br label %20
20: ; preds = %9, %9, %15
%21 = phi i32 [ %19, %15 ], [ %11, %9 ], [ %11, %9 ]
%22 = add i32 %10, 1
br label %9
23: ; preds = %9
ret i8* %4
}