#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float principal, rate, days, interest;
  const int yearInDays = 365;
  printf("Enter loan principal (-1 to end): ");
  scanf("%f", &principal);
  while ((int)principal != -1) {
    printf("Enter interest rate: ");
    scanf("%f", &rate);
    printf("Enter term of the loan in days: ");
    scanf("%f", &days);
    interest = principal * rate * days / yearInDays;
    printf("The interest charge is $%.2f\n", interest);
    printf("\n\nEnter loan principal (-1 to end): ");
    scanf("%f", &principal);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x16d,-0x18(%rbp)
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cvttss2si -0x8(%rbp),%eax
cmp    $0xffffffff,%eax
je     11f8 <main+0xd8>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  0xe4b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1154 <main+0x34>
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    $0x18,%rsp
lea    0xf29(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cvttss2si 0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     1208 <main+0xe8>
lea    0xea1(%rip),%rbx
lea    0xeb3(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xec8(%rip),%rbp
lea    0xedf(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
mulss  0x14(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
divss  0xe26(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cvttss2si 0xc(%rsp),%eax
cmp    $0xffffffff,%eax
jne    1190 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter loan principal (-1 to end): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [22 x i8] c"Enter interest rate: \00"
@.str.3 = [33 x i8] c"Enter term of the loan in days: \00"
@.str.4 = [30 x i8] c"The interest charge is $%.2f\0A\00"
@.str.5 = [37 x i8] c"\0A\0AEnter loan principal (-1 to end): \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
store i32 0, i32* %1
store i32 365, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
br label %9
9: ; preds = %13, %0
%10 = load float, float* %2
%11 = fptosi float %10 to i32
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%18 = load float, float* %2
%19 = load float, float* %3
%20 = fmul float %18, %19
%21 = load float, float* %4
%22 = fmul float %20, %21
%23 = fdiv float %22, 3.650000e+02
store float %23, float* %5
%24 = load float, float* %5
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
br label %9
29: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter loan principal (-1 to end): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [22 x i8] c"Enter interest rate: \00"
@.str.3 = [33 x i8] c"Enter term of the loan in days: \00"
@.str.4 = [30 x i8] c"The interest charge is $%.2f\0A\00"
@.str.5 = [37 x i8] c"\0A\0AEnter loan principal (-1 to end): \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = load float, float* %1
%10 = fptosi float %9 to i32
%11 = icmp eq i32 %10, -1
br i1 %11, label %30, label %12
12: ; preds = %0, %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%17 = load float, float* %1
%18 = load float, float* %2
%19 = fmul float %17, %18
%20 = load float, float* %3
%21 = fmul float %19, %20
%22 = fdiv float %21, 3.650000e+02
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), double %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%27 = load float, float* %1
%28 = fptosi float %27 to i32
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %12
30: ; preds = %12, %0
ret i32 0
}