#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 */
scalar_t__ nvram_probe(int);
int nvram_detect(void) {
  if (nvram_probe(2))
    return 2;
  if (nvram_probe(3))
    return 3;
  if (nvram_probe(4))
    return 4;
  if (nvram_probe(5))
    return 5;
  return 1;
}


x86 assembly (clang, -O0):
<nvram_detect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%edi
call   1030 <nvram_probe@plt>
cmp    $0x0,%rax
je     1138 <nvram_detect+0x28>
movl   $0x2,-0x4(%rbp)
jmp    119f <nvram_detect+0x8f>
mov    $0x3,%edi
call   1030 <nvram_probe@plt>
cmp    $0x0,%rax
je     1158 <nvram_detect+0x48>
movl   $0x3,-0x4(%rbp)
jmp    119f <nvram_detect+0x8f>
mov    $0x4,%edi
call   1030 <nvram_probe@plt>
cmp    $0x0,%rax
je     1178 <nvram_detect+0x68>
movl   $0x4,-0x4(%rbp)
jmp    119f <nvram_detect+0x8f>
mov    $0x5,%edi
call   1030 <nvram_probe@plt>
cmp    $0x0,%rax
je     1198 <nvram_detect+0x88>
movl   $0x5,-0x4(%rbp)
jmp    119f <nvram_detect+0x8f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nvram_detect>:
push   %rbx
mov    $0x2,%ebx
mov    $0x2,%edi
call   1030 <nvram_probe@plt>
test   %rax,%rax
jne    1166 <nvram_detect+0x56>
mov    $0x3,%ebx
mov    $0x3,%edi
call   1030 <nvram_probe@plt>
test   %rax,%rax
jne    1166 <nvram_detect+0x56>
mov    $0x4,%ebx
mov    $0x4,%edi
call   1030 <nvram_probe@plt>
test   %rax,%rax
jne    1166 <nvram_detect+0x56>
mov    $0x5,%edi
call   1030 <nvram_probe@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0x1(,%rcx,4),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @nvram_detect() {
%1 = alloca i32
%2 = call i64 @nvram_probe(i32 2)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i32 2, i32* %1
br label %18
5: ; preds = %0
%6 = call i64 @nvram_probe(i32 3)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 3, i32* %1
br label %18
9: ; preds = %5
%10 = call i64 @nvram_probe(i32 4)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 4, i32* %1
br label %18
13: ; preds = %9
%14 = call i64 @nvram_probe(i32 5)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 5, i32* %1
br label %18
17: ; preds = %13
store i32 1, i32* %1
br label %18
18: ; preds = %17, %16, %12, %8, %4
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
define i32 @nvram_detect() {
%1 = tail call i64 @nvram_probe(i32 2)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = tail call i64 @nvram_probe(i32 3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = tail call i64 @nvram_probe(i32 4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i64 @nvram_probe(i32 5)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 1, i32 5
br label %13
13: ; preds = %9, %6, %3, %0
%14 = phi i32 [ 2, %0 ], [ 3, %3 ], [ 4, %6 ], [ %12, %9 ]
ret i32 %14
}