#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*/ PF_INET6;
int /*<<< orphan*/ SOCK_DGRAM;
scalar_t__ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ parse_opts(int, char **);
int /*<<< orphan*/ run_tests(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int fd;
  parse_opts(argc, argv);
  fd = socket(PF_INET6, SOCK_DGRAM, 0);
  if (fd == -1)
    error(1, errno, "socket");
  run_tests(fd);
  if (close(fd))
    error(1, errno, "close");
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <parse_opts@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11b2 <main+0x62>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe53(%rip),%rdx
call   1050 <error@plt>
mov    -0x14(%rbp),%edi
call   1060 <run_tests@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
cmp    $0x0,%rax
je     11e6 <main+0x96>
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe26(%rip),%rdx
call   1050 <error@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
call   1030 <parse_opts@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1190 <main+0x40>
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdx
mov    $0x1,%edi
call   1050 <error@plt>
mov    %ebx,%edi
call   1060 <run_tests@plt>
mov    %ebx,%edi
call   1040 <close@plt>
test   %rax,%rax
je     11bd <main+0x6d>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    0xe54(%rip),%rdx
mov    $0x1,%edi
call   1050 <error@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@PF_INET6 = global i32 0
@SOCK_DGRAM = global i32 0
@errno = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [6 x i8] c"close\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
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @parse_opts(i32 %7, i8** %8)
%10 = load i32, i32* @PF_INET6
%11 = load i32, i32* @SOCK_DGRAM
%12 = call i32 @socket(i32 %10, i32 %11, i32 0)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @errno
%17 = call i32 @error(i32 1, i32 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %2
%19 = load i32, i32* %6
%20 = call i32 @run_tests(i32 %19)
%21 = load i32, i32* %6
%22 = call i64 @close(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* @errno
%26 = call i32 @error(i32 1, i32 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %24, %18
ret i32 0
}

LLVM IR (-O2):
@PF_INET6 = global i32 0
@SOCK_DGRAM = global i32 0
@errno = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [6 x i8] c"close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @parse_opts(i32 %0, i8** %1)
%4 = load i32, i32* @PF_INET6
%5 = load i32, i32* @SOCK_DGRAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @errno
%10 = tail call i32 @error(i32 1, i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %2
%12 = tail call i32 @run_tests(i32 %6)
%13 = tail call i64 @close(i32 %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i32, i32* @errno
%17 = tail call i32 @error(i32 1, i32 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %11
ret i32 0
}