#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 findLargest(float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int n;
  float arr[100], max;
  printf("Enter number of elements: ");
  scanf("%d", &n);
  for (size_t i = 0; i < n; i++) {
    scanf("%f", &arr[i]);
  }
  max = findLargest(arr);
  printf("The largest number is: %.2f", max);
  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
call   1030 <findLargest@plt>
movss  %xmm0,-0x1a4(%rbp)
ff
movss  -0x1a4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe3f(%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   %rbx
sub    $0x1a0,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     119f <main+0x6f>
lea    0x10(%rsp),%r15
lea    0xeae(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jb     1180 <main+0x50>
lea    0x10(%rsp),%rdi
call   1030 <findLargest@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
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 = [28 x i8] c"The largest 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 = call float @findLargest(float* %21)
store float %22, float* %4
%23 = load float, float* %4
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %24)
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 = [28 x i8] c"The largest 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 %14
9: ; preds = %14, %0
%10 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 0
%11 = call float @findLargest(float* %10)
%12 = fpext float %11 to double
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %12)
ret i32 0
14: ; preds = %0, %14
%15 = phi i64 [ %18, %14 ], [ 0, %0 ]
%16 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %15
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %16)
%18 = add nuw i64 %15, 1
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp ult i64 %18, %20
br i1 %21, label %14, label %9
}