#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 */
scalar_t__ snprintf(char *, int, char *, char const *, ...);
int write(int, char *, int);
bool identify(int ircfd, const char *pass, const char *nick, const char *name) {
  char mesg[512 * 3] = "";
  int len = 0;
  if (pass)
    len += snprintf(mesg, sizeof mesg, "PASS %s\r\n", pass);
  len += snprintf(mesg + len, sizeof mesg - len,
                  "NICK %s\r\nUSER %s 0 * : %s\r\n", nick, nick, name);
  return len == write(ircfd, mesg, len);
}


x86 assembly (clang, -O0):
<identify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x630,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x620(%rbp),%rdi
xor    %esi,%esi
mov    $0x600,%edx
call   1050 <memset@plt>
movl   $0x0,-0x624(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a3 <identify+0x73>
lea    -0x620(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x600,%esi
lea    0xe77(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %rax,%rcx
movslq -0x624(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x624(%rbp)
lea    -0x620(%rbp),%rdi
movslq -0x624(%rbp),%rax
add    %rax,%rdi
movslq -0x624(%rbp),%rcx
mov    $0x600,%eax
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    0xe32(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %rax,%rcx
movslq -0x624(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x624(%rbp)
mov    -0x624(%rbp),%eax
mov    %eax,-0x628(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x620(%rbp),%rsi
mov    -0x624(%rbp),%edx
call   1030 <write@plt>
mov    %eax,%ecx
mov    -0x628(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x630,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<identify>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x600,%rsp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%rdi
xor    %ebp,%ebp
mov    $0x600,%edx
xor    %esi,%esi
call   1050 <memset@plt>
test   %rbx,%rbx
je     117d <identify+0x4d>
lea    0xe98(%rip),%rdx
mov    %rsp,%rdi
mov    $0x600,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rdi
mov    $0x600,%esi
sub    %ebp,%esi
lea    0xe7b(%rip),%rdx
mov    %r12,%rcx
mov    %r12,%r8
mov    %r15,%r9
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %rsp,%rsi
mov    %r14d,%edi
mov    %ebx,%edx
call   1030 <write@plt>
xor    %ecx,%ecx
cmp    %ebx,%eax
sete   %cl
mov    %ecx,%eax
add    $0x600,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"PASS %s\0D\0A\00"
@.str.1 = [28 x i8] c"NICK %s\0D\0AUSER %s 0 * : %s\0D\0A\00"
define i32 @identify(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1536 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = bitcast [1536 x i8]* %9 to i8*
store i32 0, i32* %10
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %22
14: ; preds = %4
%15 = getelementptr inbounds [1536 x i8], [1536 x i8]* %9, i64 0, i64 0
%16 = load i8*, i8** %6
%17 = call i64 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %15, i32 1536, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = add nsw i64 %19, %17
%21 = trunc i64 %20 to i32
store i32 %21, i32* %10
br label %22
22: ; preds = %14, %4
%23 = getelementptr inbounds [1536 x i8], [1536 x i8]* %9, i64 0, i64 0
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = sub i64 1536, %28
%30 = trunc i64 %29 to i32
%31 = load i8*, i8** %7
%32 = load i8*, i8** %7
%33 = load i8*, i8** %8
%34 = call i64 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %26, i32 %30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %32, i8* %33)
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = add nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = load i32, i32* %5
%41 = getelementptr inbounds [1536 x i8], [1536 x i8]* %9, i64 0, i64 0
%42 = load i32, i32* %10
%43 = call i32 @write(i32 %40, i8* %41, i32 %42)
%44 = icmp eq i32 %39, %43
%45 = zext i1 %44 to i32
ret i32 %45
}

LLVM IR (-O2):
@.str = [10 x i8] c"PASS %s\0D\0A\00"
@.str.1 = [28 x i8] c"NICK %s\0D\0AUSER %s 0 * : %s\0D\0A\00"
define i32 @identify(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [1536 x i8]
%6 = getelementptr inbounds [1536 x i8], [1536 x i8]* %5, i64 0, i64 0
%7 = icmp eq i8* %1, null
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = call i64 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %6, i32 1536, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = shl i64 %9, 32
%11 = ashr exact i64 %10, 32
br label %12
12: ; preds = %8, %4
%13 = phi i64 [ %11, %8 ], [ 0, %4 ]
%14 = getelementptr inbounds [1536 x i8], [1536 x i8]* %5, i64 0, i64 %13
%15 = trunc i64 %13 to i32
%16 = sub i32 1536, %15
%17 = call i64 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %2, i8* %3)
%18 = add nsw i64 %17, %13
%19 = trunc i64 %18 to i32
%20 = call i32 @write(i32 %0, i8* %6, i32 %19)
%21 = icmp eq i32 %20, %19
%22 = zext i1 %21 to i32
ret i32 %22
}