#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 pp_send(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int ping(int argc, char **argv) {
  int ret = -1;
  if (argc == 2) {
    printf(". send user PING to [%s]\n", argv[1]);
    ret = pp_send(argv[1], "PING");
  } else {
    puts(". send multicast PING to [ff02::1]");
    ret = pp_send("ff02::1", "PING");
  }
  return ret;
}


x86 assembly (clang, -O0):
<ping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    1180 <ping+0x50>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea7(%rip),%rsi
call   1040 <pp_send@plt>
mov    %eax,-0x14(%rbp)
jmp    11a2 <ping+0x72>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1040 <pp_send@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ping>:
push   %rbx
cmp    $0x2,%edi
jne    114f <ping+0x1f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xebc(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
jmp    1162 <ping+0x32>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
lea    0xeb1(%rip),%rsi
pop    %rbx
jmp    1040 <pp_send@plt>

LLVM IR (-O0):
@.str = [26 x i8] c". send user PING to [%s]\0A\00"
@.str.1 = [5 x i8] c"PING\00"
@.str.2 = [35 x i8] c". send multicast PING to [ff02::1]\00"
@.str.3 = [8 x i8] c"ff02::1\00"
define i32 @ping(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 -1, i32* %5
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @pp_send(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %5
br label %20
17: ; preds = %2
%18 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @pp_send(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 %19, i32* %5
br label %20
20: ; preds = %17, %8
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
@.str = [26 x i8] c". send user PING to [%s]\0A\00"
@.str.1 = [5 x i8] c"PING\00"
@.str.2 = [35 x i8] c". send multicast PING to [ff02::1]\00"
@.str.3 = [8 x i8] c"ff02::1\00"
define i32 @ping(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %5
br label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %9 ], [ %8, %4 ]
%13 = tail call i32 @pp_send(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
ret i32 %13
}