#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*/ free(void *);
int /*<<< orphan*/ irc_send(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
void *ping(void *code) {
  char *packet = malloc(1501);
  if (packet && code) {
    snprintf(packet, 1500, "PONG %s\r\n", (char *)code);
    irc_send(packet);
  } else {
    printf("Error with variables in ping thread.  PONG not sent.\n");
  }
  if (packet)
    free(packet);
  if (code)
    free(code);
  return NULL;
}


x86 assembly (clang, -O0):
<ping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x5dd,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a7 <ping+0x57>
cmpq   $0x0,-0x8(%rbp)
je     11a7 <ping+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x5dc,%esi
lea    0xe6c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <irc_send@plt>
jmp    11b3 <ping+0x63>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11c7 <ping+0x77>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x8(%rbp)
je     11db <ping+0x8b>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ping>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x5dd,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %r14,%r14
je     1194 <ping+0x44>
test   %rbx,%rbx
je     1194 <ping+0x44>
lea    0xe8b(%rip),%rdx
mov    %rbx,%rdi
mov    $0x5dc,%esi
mov    %r14,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1070 <irc_send@plt>
test   %rbx,%rbx
jne    11a5 <ping+0x55>
jmp    11ad <ping+0x5d>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
test   %rbx,%rbx
je     11ad <ping+0x5d>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     11ba <ping+0x6a>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"PONG %s\0D\0A\00"
@.str.1 = [54 x i8] c"Error with variables in ping thread. PONG not sent.\0A\00"
define i8* @ping(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i8* @malloc(i32 1501)
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = call i32 @snprintf(i8* %11, i32 1500, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @irc_send(i8* %14)
br label %18
16: ; preds = %7, %1
%17 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %10
%19 = load i8*, i8** %3
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = call i32 @free(i8* %22)
br label %24
24: ; preds = %21, %18
%25 = load i8*, i8** %2
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %2
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %27, %24
ret i8* null
}

LLVM IR (-O2):
@.str = [10 x i8] c"PONG %s\0D\0A\00"
@str = [53 x i8] c"Error with variables in ping thread. PONG not sent.\00"
define noalias i8* @ping(i8* %0) {
%2 = tail call dereferenceable_or_null(1501) i8* @malloc(i32 1501)
%3 = icmp ne i8* %2, null
%4 = icmp ne i8* %0, null
%5 = and i1 %4, %3
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i32 @snprintf(i8* %2, i32 1500, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @irc_send(i8* %2)
br label %11
9: ; preds = %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
br i1 %3, label %12, label %14
12: ; preds = %11
%13 = tail call i32 @free(i8* %2)
br label %14
14: ; preds = %12, %11
br i1 %4, label %15, label %17
15: ; preds = %14
%16 = tail call i32 @free(i8* %0)
br label %17
17: ; preds = %15, %14
ret i8* null
}