#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 s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int inet_pton(int /*<<< orphan*/, char *, unsigned char *);
int /*<<< orphan*/ printf(char *, char *, int);
int test_inet_pton(void) {
  unsigned char buffer[10];
  struct in_addr *inaddr = (void *)buffer;
  do {
    if (!(1 == inet_pton(AF_INET, "127.0.0.1", buffer))) {
      printf("expression '%s' untrue at %d\n",
             "1 == inet_pton(AF_INET, \"127.0.0.1\", buffer)", 87);
      return 0;
    }
  } while (0);
  do {
    if (!(inaddr->s_addr == 0x0100007f)) {
      printf("expression '%s' untrue at %d\n", "inaddr->s_addr == 0x0100007f",
             88);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_inet_pton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0xe(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    -0xe(%rbp),%rdx
lea    0xebc(%rip),%rsi
call   1040 <inet_pton@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     117c <test_inet_pton+0x5c>
lea    0xeab(%rip),%rdi
lea    0xec2(%rip),%rsi
mov    $0x57,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <test_inet_pton+0xa6>
jmp    1181 <test_inet_pton+0x61>
jmp    1186 <test_inet_pton+0x66>
mov    -0x18(%rbp),%rax
cmpl   $0x100007f,(%rax)
je     11ba <test_inet_pton+0x9a>
lea    0xe6d(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x58,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <test_inet_pton+0xa6>
jmp    11bf <test_inet_pton+0x9f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_inet_pton>:
sub    $0x18,%rsp
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <inet_pton@plt>
cmp    $0x1,%eax
jne    1167 <test_inet_pton+0x47>
mov    $0x1,%eax
cmpl   $0x100007f,0xc(%rsp)
01
je     1181 <test_inet_pton+0x61>
lea    0xeb1(%rip),%rdi
lea    0xef5(%rip),%rsi
mov    $0x58,%edx
jmp    117a <test_inet_pton+0x5a>
lea    0xe9c(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x57,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@.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 = [45 x i8] c"1 == inet_pton(AF_INET, \22127.0.0.1\22, buffer)\00"
@.str.3 = [29 x i8] c"inaddr->s_addr == 0x0100007f\00"
define i32 @test_inet_pton() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca %struct.in_addr*
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = bitcast i8* %4 to %struct.in_addr*
store %struct.in_addr* %5, %struct.in_addr** %3
br label %6
6: ; preds = %0
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i32 @inet_pton(i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i32 1, %9
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 87)
store i32 0, i32* %1
br label %24
13: ; preds = %6
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
%16 = load %struct.in_addr*, %struct.in_addr** %3
%17 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 16777343
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 88)
store i32 0, i32* %1
br label %24
22: ; preds = %15
br label %23
23: ; preds = %22
store i32 1, i32* %1
br label %24
24: ; preds = %23, %20, %11
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@AF_INET = global i32 0
@.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 = [45 x i8] c"1 == inet_pton(AF_INET, \22127.0.0.1\22, buffer)\00"
@.str.3 = [29 x i8] c"inaddr->s_addr == 0x0100007f\00"
define i32 @test_inet_pton() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @AF_INET
%4 = call i32 @inet_pton(i32 %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp eq i32 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 87)
br label %14
8: ; preds = %0
%9 = bitcast [10 x i8]* %1 to i32*
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 16777343
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 88)
br label %14
14: ; preds = %8, %12, %6
%15 = phi i32 [ 0, %12 ], [ 0, %6 ], [ 1, %8 ]
ret i32 %15
}