int main() {
  struct employee {
    char name[30], post[5];
    float salary;
  };
  struct employee emp[3], high;
  int i, h;
  for (i = 0; i < 3; i++) {
    printf("\nEnter emp #%d detail\n", i + 1);
    printf("Name: ");
    scanf("%s", &emp[i].name);
    printf("Post: ");
    scanf("%s", &emp[i].post);
    printf("Salary: ");
    scanf("%f", &emp[i].salary);
  }
  h = 0;
  high = emp[h];
  for (i = 1; i < 3; i++) {
    if (emp[i].salary > high.salary) {
      h = i;
      high = emp[h];
    }
  }
  printf("\nHighest Earner Detail\n");
  printf("Name: %s\nPost: %s\nSalary: %.2f\n", high.name, high.post,
         high.salary);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xac(%rbp)
cmpl   $0x3,-0xac(%rbp)
jge    1216 <main+0xe6>
mov    -0xac(%rbp),%esi
add    $0x1,%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xac(%rbp),%rax
lea    -0x80(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xac(%rbp),%rax
lea    -0x80(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
add    $0x1e,%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xac(%rbp),%rax
lea    -0x80(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
add    $0x24,%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    114c <main+0x1c>
movl   $0x0,-0xb0(%rbp)
movslq -0xb0(%rbp),%rax
lea    -0x80(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
lea    -0xa8(%rbp),%rdi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0xac(%rbp)
cmpl   $0x3,-0xac(%rbp)
jge    12c6 <main+0x196>
movslq -0xac(%rbp),%rcx
lea    -0x80(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movss  0x24(%rax),%xmm0
ucomiss -0x84(%rbp),%xmm0
jbe    12ad <main+0x17d>
mov    -0xac(%rbp),%eax
mov    %eax,-0xb0(%rbp)
movslq -0xb0(%rbp),%rax
lea    -0x80(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
lea    -0xa8(%rbp),%rdi
mov    $0x28,%edx
call   1040 <memcpy@plt>
jmp    12b2 <main+0x182>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    124d <main+0x11d>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa8(%rbp),%rsi
lea    -0xa8(%rbp),%rdx
add    $0x1e,%rdx
movss  -0x84(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd53(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
lea    0xeb8(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rbx
lea    0x40(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9c(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x5e(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe83(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x64(%rsp),%rsi
lea    0xe76(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x68(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x86(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8c(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x90(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xae(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb4(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x60(%rsp),%rax
mov    %rax,0x30(%rsp)
movaps 0x40(%rsp),%xmm0
movaps 0x50(%rsp),%xmm1
movaps %xmm0,0x10(%rsp)
movaps %xmm1,0x20(%rsp)
movss  0x8c(%rsp),%xmm0
movss  0x34(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jbe    12e1 <main+0x1b1>
mov    0x88(%rsp),%rax
mov    %rax,0x30(%rsp)
movups 0x68(%rsp),%xmm0
movups 0x78(%rsp),%xmm1
movaps %xmm1,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movss  0x34(%rsp),%xmm1
movss  0xb4(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jbe    131c <main+0x1ec>
mov    0xb0(%rsp),%rax
mov    %rax,0x30(%rsp)
movaps 0x90(%rsp),%xmm0
movaps 0xa0(%rsp),%xmm1
movaps %xmm1,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movss  0x34(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
lea    0xd2b(%rip),%rdi
call   1030 <puts@plt>
lea    0x2e(%rsp),%rdx
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcf0(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.employee = type { [30 x i8], [5 x i8], float }
@.str = [23 x i8] c"\0AEnter emp #%d detail\0A\00"
@.str.1 = [7 x i8] c"Name: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [7 x i8] c"Post: \00"
@.str.4 = [9 x i8] c"Salary: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [24 x i8] c"\0AHighest Earner Detail\0A\00"
@.str.7 = [32 x i8] c"Name: %s\0APost: %s\0ASalary: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x %struct.employee]
%3 = alloca %struct.employee
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %31, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %34
9: ; preds = %6
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %2, i64 0, i64 %15
%17 = getelementptr inbounds %struct.employee, %struct.employee* %16, i32 0, i32 0
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [30 x i8]* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %2, i64 0, i64 %21
%23 = getelementptr inbounds %struct.employee, %struct.employee* %22, i32 0, i32 1
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [5 x i8]* %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %2, i64 0, i64 %27
%29 = getelementptr inbounds %struct.employee, %struct.employee* %28, i32 0, i32 2
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %29)
br label %31
31: ; preds = %9
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %6
34: ; preds = %6
store i32 0, i32* %5
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %2, i64 0, i64 %36
%38 = bitcast %struct.employee* %3 to i8*
%39 = bitcast %struct.employee* %37 to i8*
store i32 1, i32* %4
br label %40
40: ; preds = %60, %34
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 3
br i1 %42, label %43, label %63
43: ; preds = %40
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %2, i64 0, i64 %45
%47 = getelementptr inbounds %struct.employee, %struct.employee* %46, i32 0, i32 2
%48 = load float, float* %47
%49 = getelementptr inbounds %struct.employee, %struct.employee* %3, i32 0, i32 2
%50 = load float, float* %49
%51 = fcmp ogt float %48, %50
br i1 %51, label %52, label %59
52: ; preds = %43
%53 = load i32, i32* %4
store i32 %53, i32* %5
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %2, i64 0, i64 %55
%57 = bitcast %struct.employee* %3 to i8*
%58 = bitcast %struct.employee* %56 to i8*
br label %59
59: ; preds = %52, %43
br label %60
60: ; preds = %59
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %40
63: ; preds = %40
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%65 = getelementptr inbounds %struct.employee, %struct.employee* %3, i32 0, i32 0
%66 = getelementptr inbounds [30 x i8], [30 x i8]* %65, i64 0, i64 0
%67 = getelementptr inbounds %struct.employee, %struct.employee* %3, i32 0, i32 1
%68 = getelementptr inbounds [5 x i8], [5 x i8]* %67, i64 0, i64 0
%69 = getelementptr inbounds %struct.employee, %struct.employee* %3, i32 0, i32 2
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* %66, i8* %68, double %71)
ret i32 0
}

LLVM IR (-O2):
%struct.employee = type { [30 x i8], [5 x i8], float }
@.str = [23 x i8] c"\0AEnter emp #%d detail\0A\00"
@.str.1 = [7 x i8] c"Name: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [7 x i8] c"Post: \00"
@.str.4 = [9 x i8] c"Salary: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.7 = [32 x i8] c"Name: %s\0APost: %s\0ASalary: %.2f\0A\00"
@str = [23 x i8] c"\0AHighest Earner Detail\00"
define i32 @main() {
%1 = alloca [3 x %struct.employee]
%2 = alloca %struct.employee
%3 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 0, i32 0, i64 0
%4 = getelementptr inbounds %struct.employee, %struct.employee* %2, i64 0, i32 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 0, i32 0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [30 x i8]* %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 0, i32 1
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [5 x i8]* %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 0, i32 2
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 2)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 1, i32 0
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [30 x i8]* %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 1, i32 1
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [5 x i8]* %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%23 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 1, i32 2
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 3)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 2, i32 0
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [30 x i8]* %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 2, i32 1
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), [5 x i8]* %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%33 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 2, i32 2
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %33)
%35 = getelementptr inbounds %struct.employee, %struct.employee* %2, i64 0, i32 2
%36 = load float, float* %23
%37 = load float, float* %35
%38 = fcmp ogt float %36, %37
br i1 %38, label %39, label %42
39: ; preds = %0
%40 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 1, i32 0, i64 0
%41 = load float, float* %35
br label %42
42: ; preds = %0, %39
%43 = phi float [ %37, %0 ], [ %41, %39 ]
%44 = load float, float* %33
%45 = fcmp ogt float %44, %43
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = getelementptr inbounds [3 x %struct.employee], [3 x %struct.employee]* %1, i64 0, i64 2, i32 0, i64 0
%48 = load float, float* %35
br label %49
49: ; preds = %46, %42
%50 = phi float [ %48, %46 ], [ %43, %42 ]
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%52 = getelementptr inbounds %struct.employee, %struct.employee* %2, i64 0, i32 1, i64 0
%53 = fpext float %50 to double
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* %4, i8* %52, double %53)
ret i32 0
}