#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  char name[50];
  double meal_rate, total_meal, total_pay, total_buy, money_back, money_give;
  printf("Enter the member info below: \nname:");
  gets(name);
  printf("Enter meal rate:>\n");
  scanf("%lf", &meal_rate);
  printf("\nTotal pay:");
  scanf("%lf", &total_pay);
  printf("\nTotal meal:");
  scanf("%lf", &total_meal);
  total_buy = meal_rate * total_meal;
  if (total_buy > total_pay) {
    money_give = total_buy - total_pay;
    printf("\nName:%s\nTotal meal:%.2f\nMeal rate:%.2f\nTotal pay:%.2f\n", name,
           total_meal, meal_rate, total_pay);
    printf("Total buy:%.2f\nMoney give:%.2f", total_buy, money_give);
  } else {
    money_back = total_pay - total_buy;
    printf("\nName:%s\nTotal meal:%.2f\nMeal rate:%.2f\nTotal pay:%.2f\n", name,
           total_meal, meal_rate, total_pay);
    printf("Total buy:%.2f\nMoney back:%.2f", total_buy, money_back);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <gets@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x58(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    121c <main+0xec>
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x40(%rbp),%rsi
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe5c(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x60(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
lea    0xe7c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1264 <main+0x134>
movsd  -0x58(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
lea    -0x40(%rbp),%rsi
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
lea    0xe0f(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x60(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
lea    0xe4e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x30(%rsp),%rdi
call   1050 <gets@plt>
lea    0xf53(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rbx
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm2
ucomisd %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
jbe    1203 <main+0xc3>
movapd %xmm3,%xmm4
subsd  %xmm2,%xmm4
movsd  %xmm4,0x8(%rsp)
lea    0xe53(%rip),%rdi
lea    0x30(%rsp),%rsi
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
jmp    122b <main+0xeb>
movapd %xmm2,%xmm4
subsd  %xmm3,%xmm4
movsd  %xmm4,0x8(%rsp)
lea    0xe29(%rip),%rdi
lea    0x30(%rsp),%rsi
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xe6d(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Enter the member info below: \0Aname:\00"
@.str.1 = [19 x i8] c"Enter meal rate:>\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [12 x i8] c"\0ATotal pay:\00"
@.str.4 = [13 x i8] c"\0ATotal meal:\00"
@.str.5 = [56 x i8] c"\0AName:%s\0ATotal meal:%.2f\0AMeal rate:%.2f\0ATotal pay:%.2f\0A\00"
@.str.6 = [31 x i8] c"Total buy:%.2f\0AMoney give:%.2f\00"
@.str.7 = [31 x i8] c"Total buy:%.2f\0AMoney back:%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%18 = load double, double* %3
%19 = load double, double* %4
%20 = fmul double %18, %19
store double %20, double* %6
%21 = load double, double* %6
%22 = load double, double* %5
%23 = fcmp ogt double %21, %22
br i1 %23, label %24, label %36
24: ; preds = %0
%25 = load double, double* %6
%26 = load double, double* %5
%27 = fsub double %25, %26
store double %27, double* %8
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%29 = load double, double* %4
%30 = load double, double* %3
%31 = load double, double* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %28, double %29, double %30, double %31)
%33 = load double, double* %6
%34 = load double, double* %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %33, double %34)
br label %48
36: ; preds = %0
%37 = load double, double* %5
%38 = load double, double* %6
%39 = fsub double %37, %38
store double %39, double* %7
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%41 = load double, double* %4
%42 = load double, double* %3
%43 = load double, double* %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %40, double %41, double %42, double %43)
%45 = load double, double* %6
%46 = load double, double* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), double %45, double %46)
br label %48
48: ; preds = %36, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Enter the member info below: \0Aname:\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [12 x i8] c"\0ATotal pay:\00"
@.str.4 = [13 x i8] c"\0ATotal meal:\00"
@.str.5 = [56 x i8] c"\0AName:%s\0ATotal meal:%.2f\0AMeal rate:%.2f\0ATotal pay:%.2f\0A\00"
@.str.6 = [31 x i8] c"Total buy:%.2f\0AMoney give:%.2f\00"
@.str.7 = [31 x i8] c"Total buy:%.2f\0AMoney back:%.2f\00"
@str = [18 x i8] c"Enter meal rate:>\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @gets(i8* %5)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%17 = load double, double* %2
%18 = load double, double* %3
%19 = fmul double %17, %18
%20 = load double, double* %4
%21 = fcmp ogt double %19, %20
br i1 %21, label %22, label %26
22: ; preds = %0
%23 = fsub double %19, %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %5, double %18, double %17, double %20)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %19, double %23)
br label %30
26: ; preds = %0
%27 = fsub double %20, %19
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %5, double %18, double %17, double %20)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), double %19, double %27)
br label %30
30: ; preds = %26, %22
ret i32 0
}