#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 */
struct in_addr {
  int dummy;
};

/* Variables and functions */
scalar_t__ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ ping_it(struct in_addr *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("usage: %s destination_ip\n", argv[0]);
    return 1;
  }
  struct in_addr dst;
  if (inet_aton(argv[1], &dst) == 0) {
    perror("inet_aton");
    printf("%s isn't a valid IP address\n", argv[1]);
    return 1;
  }
  ping_it(&dst);
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     117f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <inet_aton@plt>
cmp    $0x0,%rax
jne    11c6 <main+0x86>
lea    0xe79(%rip),%rdi
call   1060 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
lea    -0x18(%rbp),%rdi
call   1050 <ping_it@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    116e <main+0x2e>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1040 <inet_aton@plt>
test   %rax,%rax
je     1188 <main+0x48>
lea    0x8(%rsp),%rdi
call   1050 <ping_it@plt>
xor    %eax,%eax
jmp    1182 <main+0x42>
mov    (%rbx),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe8b(%rip),%rdi
call   1060 <perror@plt>
mov    0x8(%rbx),%rsi
lea    0xe85(%rip),%rdi
jmp    1178 <main+0x38>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [26 x i8] c"usage: %s destination_ip\0A\00"
@.str.1 = [10 x i8] c"inet_aton\00"
@.str.2 = [29 x i8] c"%s isn't a valid IP address\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.in_addr
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%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 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 1, i32* %3
br label %28
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @inet_aton(i8* %17, %struct.in_addr* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %14
%21 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 1, i32* %3
br label %28
26: ; preds = %14
%27 = call i32 @ping_it(%struct.in_addr* %6)
store i32 0, i32* %3
br label %28
28: ; preds = %26, %20, %9
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [26 x i8] c"usage: %s destination_ip\0A\00"
@.str.1 = [10 x i8] c"inet_aton\00"
@.str.2 = [29 x i8] c"%s isn't a valid IP address\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %22
8: ; preds = %2
%9 = bitcast %struct.in_addr* %3 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @inet_aton(i8* %11, %struct.in_addr* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %10
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %20
18: ; preds = %8
%19 = call i32 @ping_it(%struct.in_addr* %3)
br label %20
20: ; preds = %18, %14
%21 = phi i32 [ 1, %14 ], [ 0, %18 ]
br label %22
22: ; preds = %20, %5
%23 = phi i32 [ 1, %5 ], [ %21, %20 ]
ret i32 %23
}