#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, float *);
int main() {
  float sales, commission;
  FILE *fin, *fout;
  fin = fopen("d:\\sales.dat", "r");
  fout = fopen("d:\\commission.dat", "w");
  while (fscanf(fin, "%f", &sales) != EOF) {
    fprintf(fout, "Your sales for the year were %8.2f \n", sales);
    if (sales < 30000)
      commission = sales / 100 * 5;
    else
      commission = sales / 100 * 10;
    fprintf(fout, "Your commission is %8.2f", commission);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xec2(%rip),%rdi
lea    0xecd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebb(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     121b <main+0xeb>
mov    -0x20(%rbp),%rdi
movss  -0x8(%rbp),%xmm0
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
movss  0xe52(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11df <main+0xaf>
movss  -0x8(%rbp),%xmm0
movss  0xe43(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe3b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1201 <main+0xd1>
movss  -0x8(%rbp),%xmm0
movss  0xe1c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe0c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x20(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
lea    0xe4a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    116d <main+0x3d>
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
push   %rax
lea    0xece(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xec7(%rip),%rdi
lea    0xed2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xec5(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %r14,%rdi
call   1030 <fscanf@plt>
mov    0x2e66(%rip),%r15
cmp    (%r15),%rax
je     11fd <main+0xcd>
lea    0xecd(%rip),%r12
lea    0xe9e(%rip),%r13
lea    0x4(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
mov    %rbx,%rdi
lea    0xe86(%rip),%rsi
call   1040 <fprintf@plt>
movss  0x4(%rsp),%xmm0
xor    %eax,%eax
movss  0xe3b(%rip),%xmm1
ucomiss %xmm0,%xmm1
seta   %al
divss  0xe31(%rip),%xmm0
lea    0xe2e(%rip),%rcx
mulss  (%rcx,%rax,4),%xmm0
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <fprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1030 <fscanf@plt>
cmp    (%r15),%rax
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"d:\\sales.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"d:\\commission.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%f\00"
@EOF = global i64 0
@.str.5 = [37 x i8] c"Your sales for the year were %8.2f \0A\00"
@.str.6 = [25 x i8] c"Your commission is %8.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32*
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %5
br label %8
8: ; preds = %27, %0
%9 = load i32*, i32** %4
%10 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %8
%14 = load i32*, i32** %5
%15 = load float, float* %2
%16 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), float %15)
%17 = load float, float* %2
%18 = fcmp olt float %17, 3.000000e+04
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load float, float* %2
%21 = fdiv float %20, 1.000000e+02
%22 = fmul float %21, 5.000000e+00
store float %22, float* %3
br label %27
23: ; preds = %13
%24 = load float, float* %2
%25 = fdiv float %24, 1.000000e+02
%26 = fmul float %25, 1.000000e+01
store float %26, float* %3
br label %27
27: ; preds = %23, %19
%28 = load i32*, i32** %5
%29 = load float, float* %3
%30 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), float %29)
br label %8
31: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"d:\\sales.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"d:\\commission.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%f\00"
@EOF = global i64 0
@.str.5 = [37 x i8] c"Your sales for the year were %8.2f \0A\00"
@.str.6 = [25 x i8] c"Your commission is %8.2f\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %20, label %8
8: ; preds = %0, %8
%9 = load float, float* %1
%10 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), float %9)
%11 = load float, float* %1
%12 = fcmp olt float %11, 3.000000e+04
%13 = fdiv float %11, 1.000000e+02
%14 = select i1 %12, float 5.000000e+00, float 1.000000e+01
%15 = fmul float %13, %14
%16 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), float %15)
%17 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %8
20: ; preds = %8, %0
ret i32 0
}