#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 */
float findSmallest(float *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int n;
  float arr[100], min;
  printf("Enter number of elements: ");
  scanf("%d", &n);
  for (size_t i = 0; i < n; i++) {
    scanf("%f", &arr[i]);
  }
  min = findSmallest(arr, n);
  printf("The Smallest number is: %.2f", min);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movq   $0x0,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11bb <main+0x8b>
mov    -0x1b0(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1b0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
jmp    116d <main+0x3d>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <findSmallest@plt>
movss  %xmm0,-0x1a4(%rbp)
ff
movss  -0x1a4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xebb(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     119f <main+0x6f>
lea    0x10(%rsp),%r12
lea    0xea9(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%r14
add    $0x4,%r12
cmp    %r14,%rbx
jb     1180 <main+0x50>
lea    0x10(%rsp),%rdi
mov    %r14d,%esi
call   1030 <findSmallest@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [29 x i8] c"The Smallest number is: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x float]
%4 = alloca float
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i64 0, i64* %5
br label %8
8: ; preds = %17, %0
%9 = load i64, i64* %5
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = icmp ult i64 %9, %11
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i64, i64* %5
%15 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %14
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %15)
br label %17
17: ; preds = %13
%18 = load i64, i64* %5
%19 = add i64 %18, 1
store i64 %19, i64* %5
br label %8
20: ; preds = %8
%21 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 0
%22 = load i32, i32* %2
%23 = call float @findSmallest(float* %21, i32 %22)
store float %23, float* %4
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [29 x i8] c"The Smallest number is: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x float]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x float]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %15, %0
%10 = phi i32 [ 0, %0 ], [ %20, %15 ]
%11 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%12 = call float @findSmallest(float* %11, i32 %10)
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %13)
ret i32 0
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %16
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %17)
%19 = add nuw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp ult i64 %19, %21
br i1 %22, label %15, label %9
}