#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 *, ...);
double vie_calcul(int vie_total, int vie_restante) {
  double pourcent_vie;
  pourcent_vie = vie_restante / vie_total * 100;
  printf("Il vous reste %f / %d de vie\n", vie_restante, vie_total);
  if (vie_restante <= 0)
    printf("Vous etes mort dans d'attroce souffrance\n");
  else
    printf("Soit %f pourcent de vie, toute mes félicitations vous etes "
           "toujours en vie\n",
           vie_restante, vie_total, pourcent_vie);
  return (pourcent_vie);
}


x86 assembly (clang, -O0):
<vie_calcul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
imul   $0x64,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     1162 <vie_calcul+0x52>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117b <vie_calcul+0x6b>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
lea    0xed4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vie_calcul>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    %esi,%eax
cltd
idiv   %edi
imul   $0x64,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
lea    0xec1(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    1165 <vie_calcul+0x45>
lea    0xecb(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1171 <vie_calcul+0x51>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Il vous reste %f / %d de vie\0A\00"
@.str.1 = [42 x i8] c"Vous etes mort dans d'attroce souffrance\0A\00"
@.str.2 = [77 x i8] c"Soit %f pourcent de vie, toute mes f\C3\A9licitations vous etes toujours en vie\0A\00"
define double @vie_calcul(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = sdiv i32 %6, %7
%9 = mul nsw i32 %8, 100
%10 = sitofp i32 %9 to double
store double %10, double* %5
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %23
18: ; preds = %2
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = load double, double* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20, double %21)
br label %23
23: ; preds = %18, %16
%24 = load double, double* %5
ret double %24
}

LLVM IR (-O2):
@.str = [30 x i8] c"Il vous reste %f / %d de vie\0A\00"
@.str.2 = [77 x i8] c"Soit %f pourcent de vie, toute mes f\C3\A9licitations vous etes toujours en vie\0A\00"
@str = [41 x i8] c"Vous etes mort dans d'attroce souffrance\00"
define double @vie_calcul(i32 %0, i32 %1) {
%3 = sdiv i32 %1, %0
%4 = mul nsw i32 %3, 100
%5 = sitofp i32 %4 to double
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %0)
%7 = icmp slt i32 %1, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %0, double %5)
br label %12
12: ; preds = %10, %8
ret double %5
}