#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 *, char, ...);
void show_distribution(int *distribution, int distribution_size, double maximum,
                       char field_separator, char column_separator) {
  int i;
  double distribution_increment = maximum / distribution_size;
  if (column_separator == ' ') {
    printf("Amount%c Frequency\n", field_separator);
    for (i = 0; i < distribution_size; i++) {
      printf("%.2f%c %d\n", i * distribution_increment, field_separator,
             distribution[i]);
    }
  } else {
    printf("%c Amount %c Frequency %c\n", column_separator, column_separator,
           column_separator);
    for (i = 0; i < distribution_size; i++) {
      printf("%c %.2f %c %d %c\n", column_separator, i * distribution_increment,
             column_separator, distribution[i], column_separator);
    }
  }
}


x86 assembly (clang, -O0):
<show_distribution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %cl,-0x19(%rbp)
mov    %al,-0x1a(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsbl -0x1a(%rbp),%eax
cmp    $0x20,%eax
jne    11b8 <show_distribution+0xa8>
lea    0xeab(%rip),%rdi
movsbl -0x19(%rbp),%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b3 <show_distribution+0xa3>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movsbl -0x19(%rbp),%edx
mov    -0x8(%rbp),%rcx
movslq -0x20(%rbp),%rsi
mov    (%rcx,%rsi,4),%ecx
lea    0xe79(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1167 <show_distribution+0x57>
jmp    122c <show_distribution+0x11c>
mov    -0x1a(%rbp),%al
movsbl -0x1a(%rbp),%edx
movsbl -0x1a(%rbp),%ecx
lea    0xe55(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1227 <show_distribution+0x117>
mov    -0x1a(%rbp),%al
cvtsi2sdl -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsbl -0x1a(%rbp),%edx
mov    -0x8(%rbp),%rcx
movslq -0x20(%rbp),%rsi
mov    (%rcx,%rsi,4),%ecx
movsbl -0x1a(%rbp),%r8d
lea    0xe2b(%rip),%rdi
movsbl %al,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11db <show_distribution+0xcb>
jmp    122c <show_distribution+0x11c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_distribution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %esi,%r15d
mov    %rdi,%r13
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm0
cmp    $0x20,%bpl
movsd  %xmm0,(%rsp)
jne    1190 <show_distribution+0x80>
movsbl %dl,%r12d
lea    0xebf(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15d,%r15d
jle    11ec <show_distribution+0xdc>
mov    %r15d,%ebp
lea    0xeb6(%rip),%r14
xor    %ebx,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%eax
mov    0x0(%r13,%rbx,4),%ecx
movsbl %al,%esi
mov    %r14,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <show_distribution+0x50>
jmp    11ec <show_distribution+0xdc>
movsbl %bpl,%r14d
lea    0xe84(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15d,%r15d
jle    11ec <show_distribution+0xdc>
mov    %r15d,%r12d
xor    %ebx,%ebx
lea    0xe80(%rip),%r15
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  (%rsp),%xmm0
mov    0x0(%r13,%rbx,4),%ecx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebp,%r8d
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11c0 <show_distribution+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Amount%c Frequency\0A\00"
@.str.1 = [11 x i8] c"%.2f%c %d\0A\00"
@.str.2 = [27 x i8] c"%c Amount %c Frequency %c\0A\00"
@.str.3 = [18 x i8] c"%c %.2f %c %d %c\0A\00"
define void @show_distribution(i32* %0, i32 %1, double %2, i8 signext %3, i8 signext %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
%12 = alloca double
store i32* %0, i32** %6
store i32 %1, i32* %7
store double %2, double* %8
store i8 %3, i8* %9
store i8 %4, i8* %10
%13 = load double, double* %8
%14 = load i32, i32* %7
%15 = sitofp i32 %14 to double
%16 = fdiv double %13, %15
store double %16, double* %12
%17 = load i8, i8* %10
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %45
20: ; preds = %5
%21 = load i8, i8* %9
%22 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8 signext %21)
store i32 0, i32* %11
br label %23
23: ; preds = %41, %20
%24 = load i32, i32* %11
%25 = load i32, i32* %7
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = load i32, i32* %11
%29 = sitofp i32 %28 to double
%30 = load double, double* %12
%31 = fmul double %29, %30
%32 = fptosi double %31 to i8
%33 = load i8, i8* %9
%34 = sext i8 %33 to i32
%35 = load i32*, i32** %6
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8 signext %32, i32 %34, i32 %39)
br label %41
41: ; preds = %27
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %23
44: ; preds = %23
br label %76
45: ; preds = %5
%46 = load i8, i8* %10
%47 = load i8, i8* %10
%48 = sext i8 %47 to i32
%49 = load i8, i8* %10
%50 = sext i8 %49 to i32
%51 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8 signext %46, i32 %48, i32 %50)
store i32 0, i32* %11
br label %52
52: ; preds = %72, %45
%53 = load i32, i32* %11
%54 = load i32, i32* %7
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %75
56: ; preds = %52
%57 = load i8, i8* %10
%58 = load i32, i32* %11
%59 = sitofp i32 %58 to double
%60 = load double, double* %12
%61 = fmul double %59, %60
%62 = load i8, i8* %10
%63 = sext i8 %62 to i32
%64 = load i32*, i32** %6
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = load i8, i8* %10
%70 = sext i8 %69 to i32
%71 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8 signext %57, double %61, i32 %63, i32 %68, i32 %70)
br label %72
72: ; preds = %56
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %52
75: ; preds = %52
br label %76
76: ; preds = %75, %44
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Amount%c Frequency\0A\00"
@.str.1 = [11 x i8] c"%.2f%c %d\0A\00"
@.str.2 = [27 x i8] c"%c Amount %c Frequency %c\0A\00"
@.str.3 = [18 x i8] c"%c %.2f %c %d %c\0A\00"
define void @show_distribution(i32* nocapture %0, i32 %1, double %2, i8 signext %3, i8 signext %4) {
%6 = sitofp i32 %1 to double
%7 = fdiv double %2, %6
%8 = sext i8 %4 to i32
%9 = icmp eq i8 %4, 32
br i1 %9, label %10, label %27
10: ; preds = %5
%11 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8 signext %3)
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %42
13: ; preds = %10
%14 = sext i8 %3 to i32
%15 = zext i32 %1 to i64
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ 0, %13 ], [ %25, %16 ]
%18 = trunc i64 %17 to i32
%19 = sitofp i32 %18 to double
%20 = fmul double %7, %19
%21 = fptosi double %20 to i8
%22 = getelementptr inbounds i32, i32* %0, i64 %17
%23 = load i32, i32* %22
%24 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8 signext %21, i32 %14, i32 %23)
%25 = add nuw nsw i64 %17, 1
%26 = icmp eq i64 %25, %15
br i1 %26, label %42, label %16
27: ; preds = %5
%28 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8 signext %4, i32 %8, i32 %8)
%29 = icmp sgt i32 %1, 0
br i1 %29, label %30, label %42
30: ; preds = %27
%31 = zext i32 %1 to i64
br label %32
32: ; preds = %30, %32
%33 = phi i64 [ 0, %30 ], [ %40, %32 ]
%34 = trunc i64 %33 to i32
%35 = sitofp i32 %34 to double
%36 = fmul double %7, %35
%37 = getelementptr inbounds i32, i32* %0, i64 %33
%38 = load i32, i32* %37
%39 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8 signext %4, double %36, i32 %8, i32 %38, i32 %8)
%40 = add nuw nsw i64 %33, 1
%41 = icmp eq i64 %40, %31
br i1 %41, label %42, label %32
42: ; preds = %32, %16, %27, %10
ret void
}