#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 sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
scalar_t__ connect(int, struct sockaddr const *, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int connect_poll(int sockfd, const struct sockaddr *addr, socklen_t len) {
  int count;
  for (count = 0; count <= 10; count++) {
    if (connect(sockfd, addr, len) == 0)
      return 0;
    sleep(60);
  }
  return -1;
}


x86 assembly (clang, -O0):
<connect_poll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jg     1180 <connect_poll+0x60>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <connect@plt>
cmp    $0x0,%rax
jne    1168 <connect_poll+0x48>
movl   $0x0,-0x4(%rbp)
jmp    1187 <connect_poll+0x67>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <connect_poll+0x19>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connect_poll>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <connect@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <connect@plt>
test   %rax,%rax
je     1280 <connect_poll+0x160>
mov    $0x3c,%edi
call   1040 <sleep@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
define i32 @connect_poll(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store %struct.sockaddr* %1, %struct.sockaddr** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %21, %3
%10 = load i32, i32* %8
%11 = icmp sle i32 %10, 10
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %5
%14 = load %struct.sockaddr*, %struct.sockaddr** %6
%15 = load i32, i32* %7
%16 = call i64 @connect(i32 %13, %struct.sockaddr* %14, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %4
br label %25
19: ; preds = %12
%20 = call i32 @sleep(i32 60)
br label %21
21: ; preds = %19
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
br label %9
24: ; preds = %9
store i32 -1, i32* %4
br label %25
25: ; preds = %24, %18
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
define i32 @connect_poll(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %48, label %6
6: ; preds = %3
%7 = tail call i32 @sleep(i32 60)
%8 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %48, label %10
10: ; preds = %6
%11 = tail call i32 @sleep(i32 60)
%12 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %48, label %14
14: ; preds = %10
%15 = tail call i32 @sleep(i32 60)
%16 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %48, label %18
18: ; preds = %14
%19 = tail call i32 @sleep(i32 60)
%20 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%21 = icmp eq i64 %20, 0
br i1 %21, label %48, label %22
22: ; preds = %18
%23 = tail call i32 @sleep(i32 60)
%24 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %48, label %26
26: ; preds = %22
%27 = tail call i32 @sleep(i32 60)
%28 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%29 = icmp eq i64 %28, 0
br i1 %29, label %48, label %30
30: ; preds = %26
%31 = tail call i32 @sleep(i32 60)
%32 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%33 = icmp eq i64 %32, 0
br i1 %33, label %48, label %34
34: ; preds = %30
%35 = tail call i32 @sleep(i32 60)
%36 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%37 = icmp eq i64 %36, 0
br i1 %37, label %48, label %38
38: ; preds = %34
%39 = tail call i32 @sleep(i32 60)
%40 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%41 = icmp eq i64 %40, 0
br i1 %41, label %48, label %42
42: ; preds = %38
%43 = tail call i32 @sleep(i32 60)
%44 = tail call i64 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%45 = icmp eq i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %42
%47 = tail call i32 @sleep(i32 60)
br label %48
48: ; preds = %46, %42, %38, %34, %30, %26, %22, %18, %14, %10, %6, %3
%49 = phi i32 [ 0, %3 ], [ 0, %6 ], [ 0, %10 ], [ 0, %14 ], [ 0, %18 ], [ 0, %22 ], [ 0, %26 ], [ 0, %30 ], [ 0, %34 ], [ 0, %38 ], [ 0, %42 ], [ -1, %46 ]
ret i32 %49
}