#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 SETTINGS {
  int dummy;
};

/* Variables and functions */
int pkt_card_chan_set(struct SETTINGS *, int);
int pkt_card_channel_range(struct SETTINGS *mySettings) {
  int i;
  for (i = 1; i < 15; i++) {
    if (pkt_card_chan_set(mySettings, i) == -1)
      return (--i);
  }
  return (--i);
}


x86 assembly (clang, -O0):
<pkt_card_channel_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xf,-0x14(%rbp)
jge    1166 <pkt_card_channel_range+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <pkt_card_chan_set@plt>
cmp    $0xffffffff,%eax
jne    1153 <pkt_card_channel_range+0x43>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    %eax,-0x4(%rbp)
jmp    1172 <pkt_card_channel_range+0x62>
jmp    1158 <pkt_card_channel_range+0x48>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <pkt_card_channel_range+0x13>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkt_card_channel_range>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1,%ebp
mov    $0x1,%esi
call   1030 <pkt_card_chan_set@plt>
cmp    $0xffffffff,%eax
je     1277 <pkt_card_channel_range+0x167>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <pkt_card_chan_set@plt>
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x2,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x3,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x4,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x5,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x6,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x7,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x8,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0x9,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0xa,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0xb,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1030 <pkt_card_chan_set@plt>
mov    $0xc,%ebp
cmp    $0xffffffff,%eax
je     1279 <pkt_card_channel_range+0x169>
mov    $0xe,%ebp
mov    %rbx,%rdi
mov    $0xe,%esi
call   1030 <pkt_card_chan_set@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
sub    %ecx,%ebp
jmp    1279 <pkt_card_channel_range+0x169>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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