#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 DS2480Try(int);
int DS2480Detect(int portnum) {
  int retry = 0;
  while (retry++ < 10) {
    if (DS2480Try(portnum) == 1)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<DS2480Detect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0xa,%eax
jge    1158 <DS2480Detect+0x48>
mov    -0x8(%rbp),%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
jne    1153 <DS2480Detect+0x43>
movl   $0x1,-0x4(%rbp)
jmp    115f <DS2480Detect+0x4f>
jmp    1122 <DS2480Detect+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DS2480Detect>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1030 <DS2480Try@plt>
mov    $0x1,%ebx
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
cmp    $0x1,%eax
je     1193 <DS2480Detect+0x83>
mov    %ebp,%edi
call   1030 <DS2480Try@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @DS2480Detect(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %14, %1
%6 = load i32, i32* %4
%7 = add nsw i32 %6, 1
store i32 %7, i32* %4
%8 = icmp slt i32 %6, 10
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load i32, i32* %3
%11 = call i32 @DS2480Try(i32 %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %2
br label %16
14: ; preds = %9
br label %5
15: ; preds = %5
store i32 0, i32* %2
br label %16
16: ; preds = %15, %13
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
define i32 @DS2480Detect(i32 %0) {
%2 = tail call i32 @DS2480Try(i32 %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %32, label %4
4: ; preds = %1
%5 = tail call i32 @DS2480Try(i32 %0)
%6 = icmp eq i32 %5, 1
br i1 %6, label %32, label %7
7: ; preds = %4
%8 = tail call i32 @DS2480Try(i32 %0)
%9 = icmp eq i32 %8, 1
br i1 %9, label %32, label %10
10: ; preds = %7
%11 = tail call i32 @DS2480Try(i32 %0)
%12 = icmp eq i32 %11, 1
br i1 %12, label %32, label %13
13: ; preds = %10
%14 = tail call i32 @DS2480Try(i32 %0)
%15 = icmp eq i32 %14, 1
br i1 %15, label %32, label %16
16: ; preds = %13
%17 = tail call i32 @DS2480Try(i32 %0)
%18 = icmp eq i32 %17, 1
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = tail call i32 @DS2480Try(i32 %0)
%21 = icmp eq i32 %20, 1
br i1 %21, label %32, label %22
22: ; preds = %19
%23 = tail call i32 @DS2480Try(i32 %0)
%24 = icmp eq i32 %23, 1
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = tail call i32 @DS2480Try(i32 %0)
%27 = icmp eq i32 %26, 1
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i32 @DS2480Try(i32 %0)
%30 = icmp eq i32 %29, 1
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %28, %25, %22, %19, %16, %13, %10, %7, %4, %1
%33 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ 1, %10 ], [ 1, %13 ], [ 1, %16 ], [ 1, %19 ], [ 1, %22 ], [ 1, %25 ], [ %31, %28 ]
ret i32 %33
}