int main(void) {
  int counter = 0;
  int winner = -1;
  float number = 0;
  float largest = -1;
  while (counter < 10) {
    if (counter == 0) {
      printf("%s%d%s", "Enter the ", counter + 1, "st salesperson's number: ");
      scanf("%f", &number);
    } else if (counter == 1) {
      printf("%s %d %s", "Enter the ", counter + 1,
             "nd salesperson's number: ");
      scanf("%f", &number);
    } else if (counter == 2) {
      printf("%s %d %s", "Enter the ", counter + 1,
             "rd salesperson's number: ");
      scanf("%f", &number);
    } else {
      printf("%s %d %s", "Enter the ", counter + 1,
             "th salesperson's number: ");
      scanf("%f", &number);
    }
    if (number >= largest) {
      largest = number;
    }
    counter++;
  }
  printf("%s %0.2f", "The winner is: ", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb3(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    128a <main+0x16a>
cmpl   $0x0,-0x8(%rbp)
jne    119f <main+0x7f>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
lea    0xe91(%rip),%rdi
lea    0xe91(%rip),%rsi
lea    0xe95(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1263 <main+0x143>
cmpl   $0x1,-0x8(%rbp)
jne    11e2 <main+0xc2>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
lea    0xe7d(%rip),%rdi
lea    0xe4e(%rip),%rsi
lea    0xe78(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    125e <main+0x13e>
cmpl   $0x2,-0x8(%rbp)
jne    1225 <main+0x105>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
lea    0xe3a(%rip),%rdi
lea    0xe0b(%rip),%rsi
lea    0xe4f(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1b(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1259 <main+0x139>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
lea    0xe01(%rip),%rdi
lea    0xdd2(%rip),%rsi
lea    0xe30(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    125e <main+0x13e>
jmp    1263 <main+0x143>
movss  -0x10(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     127c <main+0x15c>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf0(%rip),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0xc(%rsp)
movss  0xec2(%rip),%xmm1
mov    $0x1,%ebx
lea    0xee9(%rip),%r14
lea    0xeba(%rip),%r15
lea    0xed8(%rip),%r13
lea    0xc(%rsp),%rbp
lea    0xf0c(%rip),%r12
jmp    11bd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
lea    0xeba(%rip),%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm1
movaps 0x10(%rsp),%xmm2
movaps %xmm2,%xmm0
cmpless %xmm1,%xmm0
andps  %xmm0,%xmm1
andnps %xmm2,%xmm0
orps   %xmm1,%xmm0
add    $0x1,%ebx
movaps %xmm0,%xmm1
cmp    $0xb,%ebx
je     1220 <main+0x100>
lea    -0x1(%rbx),%eax
cmp    $0x2,%eax
movaps %xmm1,0x10(%rsp)
je     11f0 <main+0xd0>
cmp    $0x1,%eax
je     1170 <main+0x50>
test   %eax,%eax
jne    1210 <main+0xf0>
lea    0xe2a(%rip),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
lea    0xe2d(%rip),%rcx
jmp    1182 <main+0x62>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
lea    0xe54(%rip),%rcx
jmp    1182 <main+0x62>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %r12,%rcx
jmp    1182 <main+0x62>
cvtss2sd %xmm0,%xmm0
lea    0xe5f(%rip),%rdi
lea    0xe61(%rip),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s%d%s\00"
@.str.1 = [11 x i8] c"Enter the \00"
@.str.2 = [26 x i8] c"st salesperson's number: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [9 x i8] c"%s %d %s\00"
@.str.5 = [26 x i8] c"nd salesperson's number: \00"
@.str.6 = [26 x i8] c"rd salesperson's number: \00"
@.str.7 = [26 x i8] c"th salesperson's number: \00"
@.str.8 = [9 x i8] c"%s %0.2f\00"
@.str.9 = [16 x i8] c"The winner is: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store i32 -1, i32* %3
store float 0.000000e+00, float* %4
store float -1.000000e+00, float* %5
br label %6
6: ; preds = %46, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %49
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
br label %40
17: ; preds = %9
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
br label %39
25: ; preds = %17
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
br label %38
33: ; preds = %25
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
br label %38
38: ; preds = %33, %28
br label %39
39: ; preds = %38, %20
br label %40
40: ; preds = %39, %12
%41 = load float, float* %4
%42 = load float, float* %5
%43 = fcmp oge float %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load float, float* %4
store float %45, float* %5
br label %46
46: ; preds = %44, %40
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %6
49: ; preds = %6
%50 = load float, float* %5
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s%d%s\00"
@.str.1 = [11 x i8] c"Enter the \00"
@.str.2 = [26 x i8] c"st salesperson's number: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [9 x i8] c"%s %d %s\00"
@.str.5 = [26 x i8] c"nd salesperson's number: \00"
@.str.6 = [26 x i8] c"rd salesperson's number: \00"
@.str.7 = [26 x i8] c"th salesperson's number: \00"
@.str.8 = [9 x i8] c"%s %0.2f\00"
@.str.9 = [16 x i8] c"The winner is: \00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
br label %3
3: ; preds = %0, %15
%4 = phi float [ -1.000000e+00, %0 ], [ %19, %15 ]
%5 = phi i32 [ 0, %0 ], [ %20, %15 ]
switch i32 %5, label %12 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
]
6: ; preds = %3
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %15
8: ; preds = %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %15
10: ; preds = %3
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %15
12: ; preds = %3
%13 = add nuw nsw i32 %5, 1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
br label %15
15: ; preds = %8, %12, %10, %6
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %1)
%17 = load float, float* %1
%18 = fcmp oge float %17, %4
%19 = select i1 %18, float %17, float %4
%20 = add nuw nsw i32 %5, 1
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %3
22: ; preds = %15
%23 = fpext float %19 to double
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), double %23)
ret i32 0
}