#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*/ _response(char *);
int snprintf(char *, int, char *, char const *);
int /*<<< orphan*/ write_log(char *, int /*<<< orphan*/);
int failed(const char *s) {
  char msg500[4096] = {0};
  int m_len;
  if ((m_len = snprintf(msg500, 4096,
                        "500 \'%s\' command is not supported.\r\n", s)) >=
          4096 ||
      m_len == -1) {
    write_log("Too long command got.", 0);
    return -1;
  }
  _response(msg500);
  return 0;
}


x86 assembly (clang, -O0):
<failed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1000,%esi
lea    0xe87(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x1014(%rbp)
cmp    $0x1000,%eax
jge    119c <failed+0x5c>
cmpl   $0xffffffff,-0x1014(%rbp)
jne    11b6 <failed+0x76>
lea    0xe82(%rip),%rdi
xor    %esi,%esi
call   1060 <write_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <failed+0x89>
lea    -0x1010(%rbp),%rdi
call   1050 <_response@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<failed>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    $0x1000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe9a(%rip),%rdx
mov    %r14,%rdi
mov    $0x1000,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
cmp    $0xfff,%eax
jg     118e <failed+0x4e>
cmp    $0xffffffff,%eax
je     118e <failed+0x4e>
mov    %rsp,%rdi
call   1050 <_response@plt>
xor    %eax,%eax
jmp    11a1 <failed+0x61>
lea    0xe90(%rip),%rdi
xor    %esi,%esi
call   1060 <write_log@plt>
mov    $0xffffffff,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"500 '%s' command is not supported.\0D\0A\00"
@.str.1 = [22 x i8] c"Too long command got.\00"
define i32 @failed(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4096 x i8]
%5 = alloca i32
store i8* %0, i8** %3
%6 = bitcast [4096 x i8]* %4 to i8*
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @snprintf(i8* %7, i32 4096, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %8)
store i32 %9, i32* %5
%10 = icmp sge i32 %9, 4096
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %11, %1
%15 = call i32 @write_log(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 -1, i32* %2
br label %19
16: ; preds = %11
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%18 = call i32 @_response(i8* %17)
store i32 0, i32* %2
br label %19
19: ; preds = %16, %14
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [37 x i8] c"500 '%s' command is not supported.\0D\0A\00"
@.str.1 = [22 x i8] c"Too long command got.\00"
define i32 @failed(i8* %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 4096, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i32 %4, 4095
%6 = icmp eq i32 %4, -1
%7 = or i1 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @write_log(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %12
10: ; preds = %1
%11 = call i32 @_response(i8* %3)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ -1, %8 ], [ 0, %10 ]
ret i32 %13
}