#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 *, int *);
int main(void) {
  int grams_of_fat, total_calories;
  float fat_fraction, percent;
  printf("This program will tell you how much of the calories in\n");
  printf("a food are from the food's fat content.\n\n");
  printf("How many grams of fat are in one serving?  ");
  scanf("%d", &grams_of_fat);
  printf("How many total calories are in one serving?  ");
  scanf("%d", &total_calories);
  fat_fraction = (grams_of_fat * 9.0) / total_calories;
  percent = fat_fraction * 100;
  if (grams_of_fat == 1) {
    printf("\nA food with 1 gram of fat ");
  } else {
    printf("\nA food with %d grams of fat ", grams_of_fat);
  }
  if (total_calories == 1) {
    printf("and 1 calorie per serving\n");
  } else {
    printf("and %d calories per serving\n", total_calories);
  }
  printf("has %.2f%% of those calories from fat.\n\n", percent);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf3e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf20(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xe4e(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11d9 <main+0xb9>
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <main+0xca>
mov    -0x8(%rbp),%esi
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    1207 <main+0xe7>
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <main+0xf8>
mov    -0xc(%rbp),%esi
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xf19(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xfaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xfda(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    (%rsp),%ebp
cmp    $0x1,%ebx
jne    11a2 <main+0x72>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b2 <main+0x82>
lea    0xedc(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
cmp    $0x1,%esi
jne    11c8 <main+0x98>
lea    0xf88(%rip),%rdi
call   1030 <puts@plt>
jmp    11d6 <main+0xa6>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2sd %ebx,%xmm0
mulsd  0xe1e(%rip),%xmm0
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mulss  0xe12(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xebf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"This program will tell you how much of the calories in\0A\00"
@.str.1 = [42 x i8] c"a food are from the food's fat content.\0A\0A\00"
@.str.2 = [44 x i8] c"How many grams of fat are in one serving? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"How many total calories are in one serving? \00"
@.str.5 = [28 x i8] c"\0AA food with 1 gram of fat \00"
@.str.6 = [30 x i8] c"\0AA food with %d grams of fat \00"
@.str.7 = [27 x i8] c"and 1 calorie per serving\0A\00"
@.str.8 = [29 x i8] c"and %d calories per serving\0A\00"
@.str.9 = [41 x i8] c"has %.2f%% of those calories from fat.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %2
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 9.000000e+00
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to double
%17 = fdiv double %14, %16
%18 = fptrunc double %17 to float
store float %18, float* %4
%19 = load float, float* %4
%20 = fmul float %19, 1.000000e+02
store float %20, float* %5
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %28
25: ; preds = %0
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %23
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %36
33: ; preds = %28
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %31
%37 = load float, float* %5
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), double %38)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [44 x i8] c"How many grams of fat are in one serving? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [46 x i8] c"How many total calories are in one serving? \00"
@.str.5 = [28 x i8] c"\0AA food with 1 gram of fat \00"
@.str.6 = [30 x i8] c"\0AA food with %d grams of fat \00"
@.str.8 = [29 x i8] c"and %d calories per serving\0A\00"
@.str.9 = [41 x i8] c"has %.2f%% of those calories from fat.\0A\0A\00"
@str = [55 x i8] c"This program will tell you how much of the calories in\00"
@str.10 = [41 x i8] c"a food are from the food's fat content.\0A\00"
@str.11 = [26 x i8] c"and 1 calorie per serving\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = icmp eq i32 %11, 1
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %11)
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
br label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %19)
br label %25
25: ; preds = %23, %21
%26 = sitofp i32 %11 to double
%27 = fmul double %26, 9.000000e+00
%28 = sitofp i32 %12 to double
%29 = fdiv double %27, %28
%30 = fptrunc double %29 to float
%31 = fmul float %30, 1.000000e+02
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0), double %32)
ret i32 0
}