#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 */
double fmod(double, double);
int /*<<< orphan*/ printf(char *, double, ...);
double trunc(double);
void do_nothing(double value) {
  double brazilian_current[12] = {100.0, 50.0, 20.0, 10.0, 5.0,  2.0,
                                  1.0,   0.50, 0.25, 0.10, 0.05, 0.01};
  int array_size = 12;
  printf("Calculating cash notes, amount: %.3f\n", value);
  int i = 0;
  for (; i < array_size; ++i) {
    double base = brazilian_current[i];
    double quotient = trunc(value / base);
    printf("Real value: %.2f, we'll give you %.0f cash notes\n", base,
           quotient);
    value = fmod(value, base);
  }
  if (value > 0.001) {
    printf("\nOw no, missed %.2f cents... Do you accept a lollipop?\n\n",
           value);
  }
}


x86 assembly (clang, -O0):
<do_nothing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x60,%edx
call   1050 <memcpy@plt>
movl   $0xc,-0x74(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    0xef8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    11f5 <do_nothing+0xb5>
movslq -0x78(%rbp),%rax
movsd  -0x70(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x80(%rbp),%xmm0
call   1060 <trunc@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm1
ff
lea    0xeca(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
call   1040 <fmod@plt>
movsd  %xmm0,-0x8(%rbp)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1186 <do_nothing+0x46>
movsd  -0x8(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121f <do_nothing+0xdf>
movsd  -0x8(%rbp),%xmm0
lea    0xeb0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_nothing>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,(%rsp)
lea    0xf2b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
xor    %ebx,%ebx
lea    0xeb6(%rip),%r15
lea    0xf35(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%r15,1),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
divsd  %xmm1,%xmm0
call   1050 <trunc@plt>
movapd %xmm0,%xmm1
mov    %r14,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <fmod@plt>
add    $0x8,%rbx
cmp    $0x60,%rbx
jne    1170 <do_nothing+0x40>
ucomisd 0xe40(%rip),%xmm0
jbe    11d9 <do_nothing+0xa9>
lea    0xeff(%rip),%rdi
mov    $0x1,%al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.do_nothing.brazilian_current = [12 x double] [double 1.000000e+02, double 5.000000e+01, double 2.000000e+01, double 1.000000e+01, double 5.000000e+00, double 2.000000e+00, double 1.000000e+00, double 5.000000e-01, double 2.500000e-01, double 1.000000e-01, double 5.000000e-02, double 1.000000e-02]
@.str = [38 x i8] c"Calculating cash notes, amount: %.3f\0A\00"
@.str.1 = [50 x i8] c"Real value: %.2f, we'll give you %.0f cash notes\0A\00"
@.str.2 = [57 x i8] c"\0AOw no, missed %.2f cents... Do you accept a lollipop?\0A\0A\00"
define void @do_nothing(double %0) {
%2 = alloca double
%3 = alloca [12 x double]
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = bitcast [12 x double]* %3 to i8*
store i32 12, i32* %4
%9 = load double, double* %2
%10 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %9)
store i32 0, i32* %5
br label %11
11: ; preds = %30, %1
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [12 x double], [12 x double]* %3, i64 0, i64 %17
%19 = load double, double* %18
store double %19, double* %6
%20 = load double, double* %2
%21 = load double, double* %6
%22 = fdiv double %20, %21
%23 = call double @llvm.trunc.f64(double %22)
store double %23, double* %7
%24 = load double, double* %6
%25 = load double, double* %7
%26 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), double %24, double %25)
%27 = load double, double* %2
%28 = load double, double* %6
%29 = call double @fmod(double %27, double %28)
store double %29, double* %2
br label %30
30: ; preds = %15
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %11
33: ; preds = %11
%34 = load double, double* %2
%35 = fcmp ogt double %34, 1.000000e-03
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load double, double* %2
%38 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %39
39: ; preds = %36, %33
ret void
}

LLVM IR (-O2):
@__const.do_nothing.brazilian_current = [12 x double] [double 1.000000e+02, double 5.000000e+01, double 2.000000e+01, double 1.000000e+01, double 5.000000e+00, double 2.000000e+00, double 1.000000e+00, double 5.000000e-01, double 2.500000e-01, double 1.000000e-01, double 5.000000e-02, double 1.000000e-02]
@.str = [38 x i8] c"Calculating cash notes, amount: %.3f\0A\00"
@.str.1 = [50 x i8] c"Real value: %.2f, we'll give you %.0f cash notes\0A\00"
@.str.2 = [57 x i8] c"\0AOw no, missed %.2f cents... Do you accept a lollipop?\0A\0A\00"
define void @do_nothing(double %0) {
%2 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %0)
br label %3
3: ; preds = %1, %3
%4 = phi i64 [ 0, %1 ], [ %12, %3 ]
%5 = phi double [ %0, %1 ], [ %11, %3 ]
%6 = getelementptr inbounds [12 x double], [12 x double]* @__const.do_nothing.brazilian_current, i64 0, i64 %4
%7 = load double, double* %6
%8 = fdiv double %5, %7
%9 = tail call double @llvm.trunc.f64(double %8)
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), double %7, double %9)
%11 = tail call double @fmod(double %5, double %7)
%12 = add nuw nsw i64 %4, 1
%13 = icmp eq i64 %12, 12
br i1 %13, label %14, label %3
14: ; preds = %3
%15 = fcmp ogt double %11, 1.000000e-03
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), double %11)
br label %18
18: ; preds = %16, %14
ret void
}