#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 */
double lua_check_number(int, char *);
scalar_t__ lua_getparam(int);
int /*<<< orphan*/ lua_pushnumber(double);
void math_min(void) {
  int i = 1;
  double dmin = lua_check_number(i, "min");
  while (lua_getparam(++i) != 0) {
    double d = lua_check_number(i, "min");
    if (d < dmin)
      dmin = d;
  }
  lua_pushnumber(dmin);
}


x86 assembly (clang, -O0):
<math_min>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    0xeb7(%rip),%rsi
call   1030 <lua_check_number@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x4(%rbp)
call   1050 <lua_getparam@plt>
cmp    $0x0,%rax
je     11a2 <math_min+0x72>
mov    -0x4(%rbp),%edi
lea    0xe8b(%rip),%rsi
call   1030 <lua_check_number@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    119d <math_min+0x6d>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1153 <math_min+0x23>
movsd  -0x10(%rbp),%xmm0
call   1040 <lua_pushnumber@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_min>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%rsi
mov    $0x1,%edi
call   1030 <lua_check_number@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1050 <lua_getparam@plt>
test   %rax,%rax
je     11a4 <math_min+0x74>
mov    $0x3,%ebx
lea    0xe97(%rip),%r14
nopl   0x0(%rax)
lea    -0x1(%rbx),%edi
mov    %r14,%rsi
call   1030 <lua_check_number@plt>
minsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1050 <lua_getparam@plt>
movsd  0x10(%rsp),%xmm0
add    $0x1,%ebx
movsd  %xmm0,0x8(%rsp)
test   %rax,%rax
jne    1170 <math_min+0x40>
jmp    11aa <math_min+0x7a>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1040 <lua_pushnumber@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"min\00"
define void @math_min() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 1, i32* %1
%4 = load i32, i32* %1
%5 = call double @lua_check_number(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store double %5, double* %2
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %1
%8 = add nsw i32 %7, 1
store i32 %8, i32* %1
%9 = call i64 @lua_getparam(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = load i32, i32* %1
%13 = call double @lua_check_number(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store double %13, double* %3
%14 = load double, double* %3
%15 = load double, double* %2
%16 = fcmp olt double %14, %15
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = load double, double* %3
store double %18, double* %2
br label %19
19: ; preds = %17, %11
br label %6
20: ; preds = %6
%21 = load double, double* %2
%22 = call i32 @lua_pushnumber(double %21)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"min\00"
define void @math_min() {
%1 = tail call double @lua_check_number(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @lua_getparam(i32 2)
%3 = icmp eq i64 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %10, %4 ], [ 2, %0 ]
%6 = phi double [ %9, %4 ], [ %1, %0 ]
%7 = tail call double @lua_check_number(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = fcmp olt double %7, %6
%9 = select i1 %8, double %7, double %6
%10 = add nuw nsw i32 %5, 1
%11 = tail call i64 @lua_getparam(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %0
%14 = phi double [ %1, %0 ], [ %9, %4 ]
%15 = tail call i32 @lua_pushnumber(double %14)
ret void
}