#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 */
typedef int /*<<< orphan*/ answer;

/* Variables and functions */
int snprintf(char *, int, char *, char const *, int, char *, int);
int write(int, char *, int);
void send_status(int fd, int status_code, const char *version, int cseq_read) {
  char answer[1024];
  int retval;
  retval =
      snprintf(answer, sizeof(answer), "%s %d %s\r\nCSeq: %d\r\n\r\n", version,
               status_code, (status_code == 200) ? "OK" : "KO", cseq_read);
  retval = write(fd, answer, retval);
}


x86 assembly (clang, -O0):
<send_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8d
mov    -0x8(%rbp),%edx
lea    0xec9(%rip),%r9
lea    0xebf(%rip),%rax
cmp    $0xc8,%edx
cmove  %rax,%r9
mov    -0x14(%rbp),%eax
mov    $0x400,%esi
lea    0xe8f(%rip),%rdx
mov    %eax,(%rsp)
call   1040 <snprintf@plt>
mov    %eax,-0x424(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x424(%rbp)
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_status>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rdx,%rax
mov    %esi,%r8d
mov    %edi,%ebx
cmp    $0xc8,%esi
lea    0xed8(%rip),%rdx
lea    0xed4(%rip),%r9
cmove  %rdx,%r9
mov    %ecx,(%rsp)
lea    0xeac(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rax,%rcx
call   1040 <snprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"%s %d %s\0D\0ACSeq: %d\0D\0A\0D\0A\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"KO\00"
define void @send_status(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %7
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 200
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%18 = load i32, i32* %8
%19 = call i32 @snprintf(i8* %11, i32 1024, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13, i8* %17, i32 %18)
store i32 %19, i32* %10
%20 = load i32, i32* %5
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%22 = load i32, i32* %10
%23 = call i32 @write(i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %10
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s %d %s\0D\0ACSeq: %d\0D\0A\0D\0A\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"KO\00"
define void @send_status(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = icmp eq i32 %1, 200
%8 = select i1 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%9 = call i32 @snprintf(i8* %6, i32 1024, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1, i8* %8, i32 %3)
%10 = call i32 @write(i32 %0, i8* %6, i32 %9)
ret void
}