#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*/ chomp(char *);
int /*<<< orphan*/ error(char *, int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ system(char *);
void do_request(int connfd) {
  char read_buffer[1025] = {0};
  if (read(connfd, read_buffer, 1025) >= 0) {
    chomp(read_buffer);
    system(read_buffer);
  } else {
    error("Error getting request", 0);
  }
}


x86 assembly (clang, -O0):
<do_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x401,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
jl     11ac <do_request+0x5c>
lea    -0x410(%rbp),%rdi
call   1060 <chomp@plt>
lea    -0x410(%rbp),%rdi
call   1030 <system@plt>
jmp    11ba <do_request+0x6a>
lea    0xe4d(%rip),%rdi
xor    %esi,%esi
call   1070 <error@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_request>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    $0x401,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x401,%edx
call   1050 <read@plt>
test   %rax,%rax
js     11a0 <do_request+0x50>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <chomp@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe59(%rip),%rdi
xor    %esi,%esi
add    $0x408,%rsp
pop    %rbx
pop    %r14
jmp    1070 <error@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Error getting request\00"
define void @do_request(i32 %0) {
%2 = alloca i32
%3 = alloca [1025 x i8]
store i32 %0, i32* %2
%4 = bitcast [1025 x i8]* %3 to i8*
%5 = load i32, i32* %2
%6 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%7 = call i64 @read(i32 %5, i8* %6, i32 1025)
%8 = icmp sge i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%11 = call i32 @chomp(i8* %10)
%12 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%13 = call i32 @system(i8* %12)
br label %16
14: ; preds = %1
%15 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 0)
br label %16
16: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Error getting request\00"
define void @do_request(i32 %0) {
%2 = alloca [1025 x i8]
%3 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%4 = call i64 @read(i32 %0, i8* %3, i32 1025)
%5 = icmp sgt i64 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = call i32 @chomp(i8* %3)
%8 = call i32 @system(i8* %3)
br label %11
9: ; preds = %1
%10 = tail call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 0)
br label %11
11: ; preds = %9, %6
ret void
}