#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 inet_addr(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int test_inet_addr(void) {
  do {
    if (!((127 + (1 << 24)) == inet_addr("127.0.0.1"))) {
      printf("expression '%s' untrue at %d\n",
             "(127 + (1 << 24)) == inet_addr(\"127.0.0.1\")", 74);
      return 0;
    }
  } while (0);
  do {
    if (!((192 + (168 << 8) + (254 << 16) + (1 << 24)) ==
          inet_addr("192.168.254.1"))) {
      printf("expression '%s' untrue at %d\n",
             "(192 + (168 << 8) + (254 << 16) + (1 << 24)) == "
             "inet_addr(\"192.168.254.1\")",
             75);
      return 0;
    }
  } while (0);
  do {
    if (!(~0 == inet_addr(""))) {
      printf("expression '%s' untrue at %d\n", "~0 == inet_addr(\"\")", 77);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_inet_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <inet_addr@plt>
mov    %eax,%ecx
mov    $0x100007f,%eax
cmp    %ecx,%eax
je     1167 <test_inet_addr+0x47>
lea    0xec0(%rip),%rdi
lea    0xed7(%rip),%rsi
mov    $0x4a,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <test_inet_addr+0xe5>
jmp    116c <test_inet_addr+0x4c>
jmp    1171 <test_inet_addr+0x51>
lea    0xedc(%rip),%rdi
call   1040 <inet_addr@plt>
mov    %eax,%ecx
mov    $0x1fea8c0,%eax
cmp    %ecx,%eax
je     11b0 <test_inet_addr+0x90>
lea    0xe77(%rip),%rdi
lea    0xec8(%rip),%rsi
mov    $0x4b,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <test_inet_addr+0xe5>
jmp    11b5 <test_inet_addr+0x95>
jmp    11ba <test_inet_addr+0x9a>
lea    0xe66(%rip),%rdi
call   1040 <inet_addr@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     11f9 <test_inet_addr+0xd9>
lea    0xe2e(%rip),%rdi
lea    0xeca(%rip),%rsi
mov    $0x4d,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <test_inet_addr+0xe5>
jmp    11fe <test_inet_addr+0xde>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_inet_addr>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <inet_addr@plt>
cmp    $0x100007f,%eax
jne    116d <test_inet_addr+0x4d>
lea    0xf19(%rip),%rdi
call   1040 <inet_addr@plt>
cmp    $0x1fea8c0,%eax
jne    1182 <test_inet_addr+0x62>
lea    0xed9(%rip),%rdi
call   1040 <inet_addr@plt>
cmp    $0xffffffff,%eax
je     119e <test_inet_addr+0x7e>
lea    0xeab(%rip),%rdi
lea    0xf47(%rip),%rsi
mov    $0x4d,%edx
jmp    1195 <test_inet_addr+0x75>
lea    0xe96(%rip),%rdi
lea    0xead(%rip),%rsi
mov    $0x4a,%edx
jmp    1195 <test_inet_addr+0x75>
lea    0xe81(%rip),%rdi
lea    0xed2(%rip),%rsi
mov    $0x4b,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [44 x i8] c"(127 + (1 << 24)) == inet_addr(\22127.0.0.1\22)\00"
@.str.3 = [14 x i8] c"192.168.254.1\00"
@.str.4 = [75 x i8] c"(192 + (168 << 8) + (254 << 16) + (1 << 24)) == inet_addr(\22192.168.254.1\22)\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [20 x i8] c"~0 == inet_addr(\22\22)\00"
define i32 @test_inet_addr() {
%1 = alloca i32
br label %2
2: ; preds = %0
%3 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 16777343, %3
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 74)
store i32 0, i32* %1
br label %23
7: ; preds = %2
br label %8
8: ; preds = %7
br label %9
9: ; preds = %8
%10 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i32 33466560, %10
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 75)
store i32 0, i32* %1
br label %23
14: ; preds = %9
br label %15
15: ; preds = %14
br label %16
16: ; preds = %15
%17 = call i32 @inet_addr(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i32 -1, %17
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 77)
store i32 0, i32* %1
br label %23
21: ; preds = %16
br label %22
22: ; preds = %21
store i32 1, i32* %1
br label %23
23: ; preds = %22, %19, %12, %5
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [44 x i8] c"(127 + (1 << 24)) == inet_addr(\22127.0.0.1\22)\00"
@.str.3 = [14 x i8] c"192.168.254.1\00"
@.str.4 = [75 x i8] c"(192 + (168 << 8) + (254 << 16) + (1 << 24)) == inet_addr(\22192.168.254.1\22)\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [20 x i8] c"~0 == inet_addr(\22\22)\00"
define i32 @test_inet_addr() {
%1 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 16777343
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 74)
br label %15
5: ; preds = %0
%6 = tail call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i32 %6, 33466560
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 75)
br label %15
10: ; preds = %5
%11 = tail call i32 @inet_addr(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i32 %11, -1
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 77)
br label %15
15: ; preds = %10, %13, %8, %3
%16 = phi i32 [ 0, %13 ], [ 0, %8 ], [ 0, %3 ], [ 1, %10 ]
ret i32 %16
}