#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*/ graph_header(long);
int /*<<< orphan*/ printf(char *, ...);
void graph(double regions[], long nr_regions) {
  printf("\n");
  graph_header(nr_regions);
  int *ptr;
  int i, j;
  int perc_width = 10;
  for (i = 0; i < perc_width; ++i) {
    double perc_index = 100 - ((i + 1) * perc_width);
    printf("%4.0f %% ", perc_index + perc_width);
    for (j = 0; j < nr_regions; ++j) {
      double val = regions[j];
      if (val < 1) {
        printf(" ");
      } else if (val >= perc_index) {
        printf("*");
      } else {
        printf(" ");
      }
    }
    printf(" | \n");
  }
  graph_header(nr_regions);
  printf("\n");
}


x86 assembly (clang, -O0):
<graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <graph_header@plt>
movl   $0xa,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1249 <graph+0x129>
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
imul   -0x24(%rbp),%ecx
mov    $0x64,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
addsd  %xmm1,%xmm0
lea    0xe78(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    122d <graph+0x10d>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe3a(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11e4 <graph+0xc4>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121a <graph+0xfa>
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1207 <graph+0xe7>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <graph+0xf5>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121a <graph+0xfa>
jmp    121f <graph+0xff>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119e <graph+0x7e>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1155 <graph+0x35>
mov    -0x10(%rbp),%rdi
call   1030 <graph_header@plt>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<graph>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1050 <graph_header@plt>
xor    %r13d,%r13d
lea    0xea3(%rip),%r15
lea    0xea6(%rip),%r12
jmp    118e <graph+0x4e>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
cmp    $0xa,%r13d
je     120b <graph+0xcb>
mov    %r13d,%eax
add    $0x1,%r13d
add    %eax,%eax
add    $0x2,%eax
lea    (%rax,%rax,4),%eax
mov    $0x64,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,(%rsp)
addsd  0xe48(%rip),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
test   %rbx,%rbx
jle    1180 <graph+0x40>
xor    %ebp,%ebp
jmp    11ed <graph+0xad>
nopl   0x0(%rax,%rax,1)
movsd  0xe30(%rip),%xmm1
ucomisd %xmm0,%xmm1
cmova  %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1180 <graph+0x40>
movsd  (%r14,%rbp,8),%xmm0
ucomisd (%rsp),%xmm0
mov    $0x20,%eax
mov    $0x20,%edi
jb     11d0 <graph+0x90>
mov    $0x2a,%edi
jmp    11d0 <graph+0x90>
mov    %rbx,%rdi
call   1050 <graph_header@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [10 x i8] c"%4.0f %% \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [5 x i8] c" | \0A\00"
define void @graph(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double* %0, double** %3
store i64 %1, i64* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i64, i64* %4
%13 = call i32 @graph_header(i64 %12)
store i32 10, i32* %8
store i32 0, i32* %6
br label %14
14: ; preds = %60, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %63
18: ; preds = %14
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %8
%22 = mul nsw i32 %20, %21
%23 = sub nsw i32 100, %22
%24 = sitofp i32 %23 to double
store double %24, double* %9
%25 = load double, double* %9
%26 = load i32, i32* %8
%27 = sitofp i32 %26 to double
%28 = fadd double %25, %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %28)
store i32 0, i32* %7
br label %30
30: ; preds = %55, %18
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = load i64, i64* %4
%34 = icmp slt i64 %32, %33
br i1 %34, label %35, label %58
35: ; preds = %30
%36 = load double*, double** %3
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
store double %40, double* %10
%41 = load double, double* %10
%42 = fcmp olt double %41, 1.000000e+00
br i1 %42, label %43, label %45
43: ; preds = %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %54
45: ; preds = %35
%46 = load double, double* %10
%47 = load double, double* %9
%48 = fcmp oge double %46, %47
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %53
51: ; preds = %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
br label %54
54: ; preds = %53, %43
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %30
58: ; preds = %30
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %58
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %14
63: ; preds = %14
%64 = load i64, i64* %4
%65 = call i32 @graph_header(i64 %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"%4.0f %% \00"
@str = [4 x i8] c" | \00"
define void @graph(double* nocapture %0, i64 %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @graph_header(i64 %1)
%5 = icmp sgt i64 %1, 0
br label %6
6: ; preds = %2, %25
%7 = phi i32 [ 0, %2 ], [ %8, %25 ]
%8 = add nuw nsw i32 %7, 1
%9 = mul nsw i32 %8, -10
%10 = add nsw i32 %9, 100
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 1.000000e+01
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %12)
br i1 %5, label %14, label %25
14: ; preds = %6, %14
%15 = phi i64 [ %23, %14 ], [ 0, %6 ]
%16 = getelementptr inbounds double, double* %0, i64 %15
%17 = load double, double* %16
%18 = fcmp olt double %17, 1.000000e+00
%19 = fcmp ult double %17, %11
%20 = select i1 %18, i1 true, i1 %19
%21 = select i1 %20, i32 32, i32 42
%22 = tail call i32 @putchar(i32 %21)
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %1
br i1 %24, label %25, label %14
25: ; preds = %14, %6
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%27 = icmp eq i32 %8, 10
br i1 %27, label %28, label %6
28: ; preds = %25
%29 = tail call i32 @graph_header(i64 %1)
%30 = tail call i32 @putchar(i32 10)
ret void
}