#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 */
typedef scalar_t__ in_addr_t;

/* Variables and functions */
scalar_t__ INADDR_NONE;
char *consume_until_whitespace(char **);
int /*<<< orphan*/ fatal(char *);
scalar_t__ inet_addr(char *);
in_addr_t consume_ip_address(char **str) {
  in_addr_t addr;
  char *tok = consume_until_whitespace(str);
  if (!tok)
    fatal("IP address isn't specified");
  addr = inet_addr(tok);
  if (addr == INADDR_NONE) {
    fatal("Invalid IP address specified");
  }
  return addr;
}


x86 assembly (clang, -O0):
<consume_ip_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <consume_until_whitespace@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1160 <consume_ip_address+0x30>
lea    0xea5(%rip),%rdi
call   1050 <fatal@plt>
mov    -0x18(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%rax
jne    118d <consume_ip_address+0x5d>
lea    0xe93(%rip),%rdi
call   1050 <fatal@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consume_ip_address>:
push   %rbx
call   1030 <consume_until_whitespace@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114a <consume_ip_address+0x1a>
lea    0xebb(%rip),%rdi
call   1050 <fatal@plt>
mov    %rbx,%rdi
call   1040 <inet_addr@plt>
mov    %rax,%rbx
mov    0x2e8c(%rip),%rax
cmp    (%rax),%rbx
jne    116d <consume_ip_address+0x3d>
lea    0xeb3(%rip),%rdi
call   1050 <fatal@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"IP address isn't specified\00"
@INADDR_NONE = global i64 0
@.str.1 = [29 x i8] c"Invalid IP address specified\00"
define i64 @consume_ip_address(i8** %0) {
%2 = alloca i8**
%3 = alloca i64
%4 = alloca i8*
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = call i8* @consume_until_whitespace(i8** %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @fatal(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = load i8*, i8** %4
%13 = call i64 @inet_addr(i8* %12)
store i64 %13, i64* %3
%14 = load i64, i64* %3
%15 = load i64, i64* @INADDR_NONE
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @fatal(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %11
%20 = load i64, i64* %3
ret i64 %20
}

LLVM IR (-O2):
@.str = [27 x i8] c"IP address isn't specified\00"
@INADDR_NONE = global i64 0
@.str.1 = [29 x i8] c"Invalid IP address specified\00"
define i64 @consume_ip_address(i8** %0) {
%2 = tail call i8* @consume_until_whitespace(i8** %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @fatal(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i64 @inet_addr(i8* %2)
%8 = load i64, i64* @INADDR_NONE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @fatal(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
ret i64 %7
}