#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*/ isValidIpAddress(char *);
int ping(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int status = 0;
  if (argc != 2) {
    printf("Example Usage: %s 192.168.1.1\n", argv[0]);
    return 1;
  } else if (!isValidIpAddress(argv[1])) {
    printf("%s is an invalid IP Address\n", argv[1]);
    return 1;
  }
  status = ping(argv[1]);
  if (status == 0) {
    printf("Could ping %s successfully, status %d\n", argv[1], status);
  } else {
    printf("Machine not reachable, status %d\n", status);
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1178 <main+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1204 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <isValidIpAddress@plt>
cmp    $0x0,%eax
jne    11b0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1204 <main+0xd4>
jmp    11b5 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <ping@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11ed <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fe <main+0xce>
mov    -0x14(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    116c <main+0x3c>
mov    0x8(%rbx),%rdi
call   1050 <isValidIpAddress@plt>
mov    0x8(%rbx),%rsi
test   %eax,%eax
je     1178 <main+0x48>
mov    %rsi,%rdi
call   1040 <ping@plt>
test   %eax,%eax
je     1194 <main+0x64>
mov    %eax,%ebp
lea    0xf02(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    118b <main+0x5b>
mov    (%rbx),%rsi
lea    0xe8a(%rip),%rdi
jmp    117f <main+0x4f>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x8(%rbx),%rsi
lea    0xe9d(%rip),%rdi
xor    %ebp,%ebp
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    118b <main+0x5b>

LLVM IR (-O0):
@.str = [31 x i8] c"Example Usage: %s 192.168.1.1\0A\00"
@.str.1 = [29 x i8] c"%s is an invalid IP Address\0A\00"
@.str.2 = [39 x i8] c"Could ping %s successfully, status %d\0A\00"
@.str.3 = [34 x i8] c"Machine not reachable, status %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 1, i32* %3
br label %44
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @isValidIpAddress(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %44
25: ; preds = %14
br label %26
26: ; preds = %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @ping(i8* %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %26
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %36, i32 %37)
br label %42
39: ; preds = %26
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %39, %33
%43 = load i32, i32* %6
store i32 %43, i32* %3
br label %44
44: ; preds = %42, %20, %9
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [31 x i8] c"Example Usage: %s 192.168.1.1\0A\00"
@.str.1 = [29 x i8] c"%s is an invalid IP Address\0A\00"
@.str.2 = [39 x i8] c"Could ping %s successfully, status %d\0A\00"
@.str.3 = [34 x i8] c"Machine not reachable, status %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @isValidIpAddress(i8* %9)
%11 = icmp eq i32 %10, 0
%12 = load i8*, i8** %8
br i1 %11, label %13, label %15
13: ; preds = %7
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %23
15: ; preds = %7
%16 = tail call i32 @ping(i8* %12)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i8*, i8** %8
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %19, i32 0)
br label %23
21: ; preds = %15
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %23
23: ; preds = %18, %21, %13, %4
%24 = phi i32 [ 1, %4 ], [ 1, %13 ], [ %16, %21 ], [ 0, %18 ]
ret i32 %24
}