#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 data_elementsplaced(int, int);
int data_elementsremaining(int p, int item) {
  int i = data_elementsplaced(p, item);
  if (item == 1)
    return 5 - i;
  if (item == 2)
    return 4 - i;
  if (item == 3)
    return (30 - i) / 2;
  return 0;
}


x86 assembly (clang, -O0):
<data_elementsremaining>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <data_elementsplaced@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1146 <data_elementsremaining+0x36>
mov    $0x5,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <data_elementsremaining+0x79>
cmpl   $0x2,-0xc(%rbp)
jne    1160 <data_elementsremaining+0x50>
mov    $0x4,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <data_elementsremaining+0x79>
cmpl   $0x3,-0xc(%rbp)
jne    1182 <data_elementsremaining+0x72>
mov    $0x1e,%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1189 <data_elementsremaining+0x79>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_elementsremaining>:
push   %rbx
mov    %esi,%ebx
call   1030 <data_elementsplaced@plt>
mov    %eax,%ecx
cmp    $0x3,%ebx
je     1132 <data_elementsremaining+0x22>
cmp    $0x2,%ebx
je     1144 <data_elementsremaining+0x34>
xor    %eax,%eax
cmp    $0x1,%ebx
jne    1142 <data_elementsremaining+0x32>
mov    $0x5,%eax
jmp    1149 <data_elementsremaining+0x39>
mov    $0x1e,%edx
sub    %ecx,%edx
mov    %edx,%eax
shr    $0x1f,%eax
add    %edx,%eax
sar    %eax
pop    %rbx
ret
mov    $0x4,%eax
sub    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @data_elementsremaining(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = call i32 @data_elementsplaced(i32 %7, i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* %6
%14 = sub nsw i32 5, %13
store i32 %14, i32* %3
br label %29
15: ; preds = %2
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %6
%20 = sub nsw i32 4, %19
store i32 %20, i32* %3
br label %29
21: ; preds = %15
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* %6
%26 = sub nsw i32 30, %25
%27 = sdiv i32 %26, 2
store i32 %27, i32* %3
br label %29
28: ; preds = %21
store i32 0, i32* %3
br label %29
29: ; preds = %28, %24, %18, %12
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @data_elementsremaining(i32 %0, i32 %1) {
%3 = tail call i32 @data_elementsplaced(i32 %0, i32 %1)
switch i32 %1, label %11 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
]
4: ; preds = %2
%5 = sub nsw i32 5, %3
br label %11
6: ; preds = %2
%7 = sub nsw i32 4, %3
br label %11
8: ; preds = %2
%9 = sub nsw i32 30, %3
%10 = sdiv i32 %9, 2
br label %11
11: ; preds = %2, %8, %6, %4
%12 = phi i32 [ %5, %4 ], [ %7, %6 ], [ %10, %8 ], [ 0, %2 ]
ret i32 %12
}