#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 next_smallest(int);
int test_next_smallest() {
  return 0b1001 == next_smallest(0b1010) && 0b10101 == next_smallest(0b10110) &&
         0b10110 == next_smallest(0b11001) && 0 == next_smallest(0) &&
         ~0 == next_smallest(~0);
}


x86 assembly (clang, -O0):
<test_next_smallest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xa,%edi
call   1030 <next_smallest@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x9,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11a3 <test_next_smallest+0x93>
mov    $0x16,%edi
call   1030 <next_smallest@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x15,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11a3 <test_next_smallest+0x93>
mov    $0x19,%edi
call   1030 <next_smallest@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x16,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11a3 <test_next_smallest+0x93>
xor    %edi,%edi
call   1030 <next_smallest@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x1(%rbp)
jne    11a3 <test_next_smallest+0x93>
mov    $0xffffffff,%edi
call   1030 <next_smallest@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_next_smallest>:
push   %rbx
mov    $0xa,%edi
call   1030 <next_smallest@plt>
xor    %ebx,%ebx
cmp    $0x9,%eax
jne    115f <test_next_smallest+0x4f>
mov    $0x16,%edi
call   1030 <next_smallest@plt>
cmp    $0x15,%eax
jne    115f <test_next_smallest+0x4f>
mov    $0x19,%edi
call   1030 <next_smallest@plt>
cmp    $0x16,%eax
jne    115f <test_next_smallest+0x4f>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <next_smallest@plt>
test   %eax,%eax
jne    115f <test_next_smallest+0x4f>
mov    $0xffffffff,%edi
call   1030 <next_smallest@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @test_next_smallest() {
%1 = call i32 @next_smallest(i32 10)
%2 = icmp eq i32 9, %1
br i1 %2, label %3, label %15
3: ; preds = %0
%4 = call i32 @next_smallest(i32 22)
%5 = icmp eq i32 21, %4
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = call i32 @next_smallest(i32 25)
%8 = icmp eq i32 22, %7
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = call i32 @next_smallest(i32 0)
%11 = icmp eq i32 0, %10
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @next_smallest(i32 -1)
%14 = icmp eq i32 -1, %13
br label %15
15: ; preds = %12, %9, %6, %3, %0
%16 = phi i1 [ false, %9 ], [ false, %6 ], [ false, %3 ], [ false, %0 ], [ %14, %12 ]
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
define i32 @test_next_smallest() {
%1 = tail call i32 @next_smallest(i32 10)
%2 = icmp eq i32 %1, 9
br i1 %2, label %3, label %16
3: ; preds = %0
%4 = tail call i32 @next_smallest(i32 22)
%5 = icmp eq i32 %4, 21
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = tail call i32 @next_smallest(i32 25)
%8 = icmp eq i32 %7, 22
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i32 @next_smallest(i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = tail call i32 @next_smallest(i32 -1)
%14 = icmp eq i32 %13, -1
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %9, %6, %3, %0
%17 = phi i32 [ 0, %9 ], [ 0, %6 ], [ 0, %3 ], [ 0, %0 ], [ %15, %12 ]
ret i32 %17
}