#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 */
scalar_t__ EAFNOSUPPORT;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ perror(char *);
int socket(int, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int sk;
  sk = socket(32, SOCK_STREAM, 0);
  if (sk == -1) {
    if (errno == EAFNOSUPPORT)
      perror("AF_IUCV address family not supported");
    return -1;
  } else
    close(sk);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1193 <main+0x63>
mov    0x2e70(%rip),%rax
mov    (%rax),%rax
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%rax
jne    1187 <main+0x57>
lea    0xe7e(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a2 <main+0x72>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
mov    $0x20,%edi
xor    %edx,%edx
call   1050 <socket@plt>
cmp    $0xffffffff,%eax
je     1156 <main+0x26>
mov    %eax,%edi
call   1030 <close@plt>
jmp    1171 <main+0x41>
mov    0x2e7b(%rip),%rax
mov    (%rax),%rax
mov    0x2e69(%rip),%rcx
mov    $0xffffffff,%ebx
cmp    (%rcx),%rax
je     1175 <main+0x45>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe84(%rip),%rdi
call   1040 <perror@plt>
jmp    1171 <main+0x41>

LLVM IR (-O0):
@SOCK_STREAM = global i32 0
@errno = global i64 0
@EAFNOSUPPORT = global i64 0
@.str = [37 x i8] c"AF_IUCV address family not supported\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @SOCK_STREAM
%4 = call i32 @socket(i32 32, i32 %3, i32 0)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = load i64, i64* @EAFNOSUPPORT
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
store i32 -1, i32* %1
br label %18
14: ; preds = %0
%15 = load i32, i32* %2
%16 = call i32 @close(i32 %15)
br label %17
17: ; preds = %14
store i32 0, i32* %1
br label %18
18: ; preds = %17, %13
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@SOCK_STREAM = global i32 0
@errno = global i64 0
@EAFNOSUPPORT = global i64 0
@.str = [37 x i8] c"AF_IUCV address family not supported\00"
define i32 @main() {
%1 = load i32, i32* @SOCK_STREAM
%2 = tail call i32 @socket(i32 32, i32 %1, i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = load i64, i64* @errno
%6 = load i64, i64* @EAFNOSUPPORT
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = tail call i32 @close(i32 %2)
br label %12
12: ; preds = %4, %8, %10
%13 = phi i32 [ 0, %10 ], [ -1, %8 ], [ -1, %4 ]
ret i32 %13
}